apache / apache/maven-shade-plugin
[MSHADE-259] Shade plugin attaches the test jar which causes it deployed twice during release of project
- Dominant language
- Java
- Stars
- 188
- Forks
- 103
- Avg merge
- 16h 39m
- Merged PRs (30d)
- 4
Description
**[Nishith Agarwal](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=nagarwal)** opened **[MSHADE-259](https://issues.apache.org/jira/browse/MSHADE-259?redirect=false)** and commented
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.
```
org.apache.maven.plugins
maven-jar-plugin
3.0.2
package
test-jar
org.apache.maven.plugins
maven-shade-plugin
3.1.0
package
shade
true
false
false
false
com.google.code.gson:gson
com.google.gson
io.sample.shaded.com.google.gson
org.apache.maven.plugins
maven-deploy-plugin
2.8.2
true
```
Here is the issue/logs captured during release of application project
```
1. maven-jar-plugin attaches following test artifact to maven project
artifact:io.sample:sample-app:test-jar:tests:1.0.0
1. maven-shade-plugin attaches following test artifact to maven project
artifact:io.sample:sample-app:jar:tests:1.0.0
1. 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]
```
---
**Affects:** 3.1.0
**Issue Links:**
- [FLINK-15832](https://issues.apache.org/jira/browse/FLINK-15832) Test jars are installed twice
(_**"causes"**_)
**Remote Links:**
- [GitHub Pull Request #14
](https://github.com/apache/maven-shade-plugin/pull/14)
2 votes, 8 watchers
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the shade plugin path that calls projectHelper.attachArtifact with the "tests" classifier, using the Maven Jar Plugin and Maven Deploy Plugin configuration in the report as the reproduction. Review the linked pull request and the FLINK-15832 reference, then verify that a shaded test jar is not attached twice and that release deployment succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100