[
https://issues.apache.org/jira/browse/MSHADE-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17048268#comment-17048268
]
Chesnay Schepler commented on MSHADE-259:
-----------------------------------------
This issue still occurs with 3.2.2; according to the install-plugin
debug-output the test-jar is attached twice and not properly replaced.
{code:java}
[DEBUG] Configuring mojo
org.apache.maven.plugins:maven-install-plugin:2.5.2:install from plugin realm
ClassRealm[plugin>org.apache.maven.plugins:maven-install-plugin:2.5.2, parent:
sun.misc.Launcher$AppClassLoader@7852e922]
[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-install-plugin:2.5.2:install' with basic
configurator -->
[DEBUG] (f) artifact = org.apache.flink:flink-metrics-core:jar:1.11-SNAPSHOT
[DEBUG] (f) attachedArtifacts =
[org.apache.flink:flink-metrics-core:test-jar:tests:1.11-SNAPSHOT,
org.apache.flink:flink-metrics-core:test-jar:tests:1.11-SNAPSHOT]
{code}
Happens with maven 3.2.5 and 3.6.1, and maven-install-plugin 2.5.2 / 3.0.0-M1 .
> Shade plugin attaches the test jar which causes it deployed twice during
> release of project
> -------------------------------------------------------------------------------------------
>
> Key: MSHADE-259
> URL: https://issues.apache.org/jira/browse/MSHADE-259
> Project: Maven Shade Plugin
> Issue Type: Bug
> Affects Versions: 3.1.0
> Reporter: Nishith Agarwal
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> When using shade plugin to relocate the packages of a dependency for an
> application maven project for main artifact as well as test jar (using option
> shadeTestJar), it attaches the test-jar using
> {{projectHelper.attachArtifact( project, "jar", "tests", shadedTests )}},
> this causes the duplicate entry of test artifact which causes issues (build
> failure) during release as maven-deploy-plugin tries to deploy the test-jar
> twice to nexus which causes the 2nd deploy fail.
> To shade the test jar I need to add {{maven-jar-plugin}} with goal
> {{test-jar}} so that a test jar is created which then can be used by shade
> plugin to perform the shading and relocation of packages in the test jar.
> {{maven-jar-plugin}} itself also attaches the test-jar artifact.
> Here is the section of the pom.xml file which was used to create the
> test-jar, shade it and then deploy it.
> {code}
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <version>3.0.2</version>
> <executions>
> <execution>
> <phase>package</phase>
> <goals>
> <goal>test-jar</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-shade-plugin</artifactId>
> <version>3.1.0</version>
> <executions>
> <execution>
> <phase>package</phase>
> <goals>
> <goal>shade</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
> <shadeTestJar>true</shadeTestJar>
> <minimizeJar>false</minimizeJar>
> <createDependencyReducedPom>false</createDependencyReducedPom>
> <createSourcesJar>false</createSourcesJar>
> <artifactSet>
> <includes>
> <include>com.google.code.gson:gson</include>
> </includes>
> </artifactSet>
> <relocations>
> <relocation>
> <pattern>com.google.gson</pattern>
>
> <shadedPattern>io.sample.shaded.com.google.gson</shadedPattern>
> </relocation>
> </relocations>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-deploy-plugin</artifactId>
> <version>2.8.2</version>
> <configuration>
> <deployAtEnd>true</deployAtEnd>
> </configuration>
> </plugin>
> {code}
> Here is the issue/logs captured during release of application project
> {code}
> # maven-jar-plugin attaches following test artifact to maven project
> artifact:io.sample:sample-app:test-jar:tests:1.0.0
> # maven-shade-plugin attaches following test artifact to maven project
> artifact:io.sample:sample-app:jar:tests:1.0.0
> # maven-deploy-plugin tries to deploy the above 2 test artifacts to nexus and
> fails on 2nd deploy
> [INFO] [INFO] Uploading:
> http://maven-nexus.mycompany.com/nexus/content/repositories/releases/io/sample/sample-app/1.0.0/sample-app-1.0.0-tests.jar
> [INFO] [INFO] Uploaded:
> http://maven-nexus.mycompany.com/nexus/content/repositories/releases/io/sample/sample-app/1.0.0/sample-app-1.0.0-tests.jar
> (233 KB at 3412.8 KB/sec)
> [INFO] [INFO] Uploading:
> http://maven-nexus.mycompany.com/nexus/content/repositories/releases/io/sample/sample-app/1.0.0/sample-app-1.0.0-tests.jar
> [INFO] [INFO]
> ------------------------------------------------------------------------
> [INFO] [INFO] Reactor Summary:
> [INFO] [INFO]
> [INFO] [INFO] sample-app ........................ FAILURE [ 5.283 s]
> [INFO] [INFO]
> ------------------------------------------------------------------------
> [INFO] [INFO] BUILD FAILURE
> [INFO] [INFO]
> ------------------------------------------------------------------------
> [INFO] [INFO] Total time: 05:01 min
> [INFO] [INFO] Finished at: 2017-08-23T22:13:55+00:00
> [INFO] [INFO] Final Memory: 160M/1167M
> [INFO] [INFO]
> ------------------------------------------------------------------------
> [INFO] [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on
> project sample-app: Failed to deploy artifacts: Could not transfer artifact
> io.sample:sample-app:jar:tests:1.0.0 from/to releases
> (http://maven-nexus.mycompany.com/nexus/content/repositories/releases):
> Failed to transfer file:
> http://maven-nexus.mycompany.com/nexus/content/repositories/releases/io/sample/sample-app/1.0.0/sample-app-1.0.0-tests.jar.
> Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)