我试图使用maven-shade-plugin来区分Java 6和Java 7工件。我对this link的理解是,原始工件将被阴影部分替换
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT.jar with /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT-SHADED.jar
[INFO] Replacing original test artifact with shaded test artifact.
[INFO] Replacing /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT-tests.jar with /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT-SHADED-tests.jar
[INFO] Dependency-reduced POM written at: /Users/carlos/path/Libraries/xml/dependency-reduced-pom.xml
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xml ---
[INFO] Installing /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT.jar to /Users/carlos/.m2/repository/com/company/xml/1.5.0-SNAPSHOT/xml-1.5.0-SNAPSHOT.jar
[INFO] Installing /Users/carlos/path/Libraries/xml/dependency-reduced-pom.xml to /Users/carlos/.m2/repository/com/company/xml/1.5.0-SNAPSHOT/xml-1.5.0-SNAPSHOT.pom
[INFO] Installing /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT-tests.jar to /Users/carlos/.m2/repository/com/company/xml/1.5.0-SNAPSHOT/xml-1.5.0-SNAPSHOT-tests.jar
[INFO] Installing /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT-sources.jar to /Users/carlos/.m2/repository/com/company/xml/1.5.0-SNAPSHOT/xml-1.5.0-SNAPSHOT-sources.jar
[INFO] Installing /Users/carlos/path/Libraries/xml/target/xml-1.5.0-SNAPSHOT-tests.jar to /Users/carlos/.m2/repository/com/company/xml/1.5.0-SNAPSHOT/xml-1.5.0-SNAPSHOT-tests.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.724 s
[INFO] Finished at: 2015-02-19T15:53:50-05:00
[INFO] Final Memory: 22M/631M
[INFO] ------------------------------------------------------------------------
但是,它是在没有SHADED分类器的情况下安装的。这是我的shade插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadeTestJar>true</shadeTestJar>
<shadedClassifierName>SHADED</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
有谁能告诉我如何使用正确的分类器安装它?另外,我使用它而不是maven-jar-plugin,因为我还需要能够对测试罐进行分类。
答案 0 :(得分:4)
您在插件配置中缺少<shadedArtifactAttached>true</shadedArtifactAttached>
。没有它,阴影jar将仍然是项目的主要工件,因此不会应用分类器(因为主工件没有分类器)。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadeTestJar>true</shadeTestJar>
<shadedClassifierName>SHADED</shadedClassifierName>
<shadedArtifactAttached>true</shadedArtifactAttached>
</configuration>
</execution>
</executions>
</plugin>