[Commented] (MSHADE-259) Shade plugin attaches the test jar which causes it deployed twice during release of project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Commented] (MSHADE-259) Shade plugin attaches the test jar which causes it deployed twice during release of project

Michael Osipov (Jira)

    [ https://issues.apache.org/jira/browse/MSHADE-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17316938#comment-17316938 ]

David Artiga commented on MSHADE-259:
-------------------------------------

The [PR|https://github.com/apache/maven-shade-plugin/pull/14] was closed long ago but the issue still happening. [~mattf] [~struberg]

> 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)