使用你自己的 Shader 实现

默认情况下,插件提供 DefaultShader 实现,但在 1.6 版中,您可以使用自己的实现。

使用您的实现创建一个标准的 Maven 项目。

Dependency to Plexus annotations

    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-component-annotations</artifactId>
      <version>1.5.5</version>
    </dependency>

Create your Shader

@Component( role = Shader.class, hint = "mock" )
public class MockShader
    implements Shader
{
  // implement the interface here
}

// Use the plexus component metadata plugin in your job to generate Plexus metadata

      <plugin>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-component-metadata</artifactId>
        <version>1.5.5</version>
        <executions>
          <execution>
            <goals>
              <goal>generate-metadata</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

假设您的项目具有坐标 org.foo.bar:wine:1.0,您必须将其添加为 shade 插件的依赖项。

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.2.4</version>
        <dependencies>
          <dependency>
            <groupId>org.foo.bar</groupId>
            <artifactId>wine</artifactId>
            <version>1.0</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <shaderHint>mock</shaderHint>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>

现在 mojo 将使用您自己的实现。