Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.2.3
-
None
Description
During the check of an issue MSHADE-195 i stumbled over several things...
If you take a look here and the log output excerpt:
INFO] Minimized 2341 -> 1293 [INFO] Minimized 3282 -> 2234 [INFO] Replacing original artifact with shaded artifact. [INFO] Replacing /Users/kama/ws-git/apache/mshade/mshade-195/target/MSHADE-195-example-1-SNAPSHOT.jar with /Users/kama/ws-git/apache/mshade/mshade-195/target/MSHADE-195-example-1-SNAPSHOT-shaded.jar [INFO] Replacing original source artifact with shaded source artifact. [INFO] Replacing /Users/kama/ws-git/apache/mshade/mshade-195/target/MSHADE-195-example-1-SNAPSHOT-sources.jar with /Users/kama/ws-git/apache/mshade/mshade-195/target/MSHADE-195-example-1-SNAPSHOT-shaded-sources.jar [INFO] Dependency-reduced POM written at: /Users/kama/ws-git/apache/mshade/mshade-195/dependency-reduced-pom.xml [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ MSHADE-195-example --- [INFO] Installing /Users/kama/ws-git/apache/mshade/mshade-195/target/MSHADE-195-example-1-SNAPSHOT.jar to /Users/kama/.m2/repository/com/example/MSHADE-195-example/1-SNAPSHOT/MSHADE-195-example-1-SNAPSHOT.jar [INFO] Installing /Users/kama/ws-git/apache/mshade/mshade-195/dependency-reduced-pom.xml to /Users/kama/.m2/repository/com/example/MSHADE-195-example/1-SNAPSHOT/MSHADE-195-example-1-SNAPSHOT.pom [INFO] Installing /Users/kama/ws-git/apache/mshade/mshade-195/target/MSHADE-195-example-1-SNAPSHOT-sources.jar to /Users/kama/.m2/repository/com/example/MSHADE-195-example/1-SNAPSHOT/MSHADE-195-example-1-SNAPSHOT-sources.jar [INFO] Installing /Users/kama/ws-git/apache/mshade/mshade-195/target/MSHADE-195-example-1-SNAPSHOT-sources.jar to /Users/kama/.m2/repository/com/example/MSHADE-195-example/1-SNAPSHOT/MSHADE-195-example-1-SNAPSHOT-sources.jar [INFO]
Install plugin tries to install two identical artifacts which will work for maven-install-plugin but would fail a deploy to repository manager (for releases) etc.
So after diving into the problem i found the following code in maven-core (MavenProject.java):
/** * Add or replace an artifact. This method is now deprecated. Use the @{MavenProjectHelper} to attach artifacts to a * project. In spite of the 'throws' declaration on this API, this method has never thrown an exception since Maven * 3.0.x. Historically, it logged and ignored a second addition of the same g/a/v/c/t. Now it replaces the file for * the artifact, so that plugins (e.g. shade) can change the pathname of the file for a particular set of * coordinates. * * @param artifact the artifact to add or replace. * @throws DuplicateArtifactAttachmentException */ public void addAttachedArtifact( Artifact artifact ) throws DuplicateArtifactAttachmentException { getAttachedArtifacts().add( artifact ); } public List<Artifact> getAttachedArtifacts() { if ( attachedArtifacts == null ) { attachedArtifacts = new ArrayList<>(); } return attachedArtifacts; }
So taking a look into MavenProjectHelper.java and the implementation (DefaultMavenProjectHelper.java).
/** * Add an attached artifact or replace the file for an existing artifact. * * @see MavenProject#addAttachedArtifact(org.apache.maven.artifact.Artifact) * @param project project reference. * @param artifact artifact to add or replace. */ public void attachArtifact( MavenProject project, Artifact artifact ) { project.addAttachedArtifact( artifact ); }
which means that there is not check if an artifacts is already attached.
Attachments
Issue Links
- breaks
-
MNG-7316 REGRESSION: MavenProject.getAttachedArtifacts() is read-only
-
- Closed
-
- causes
-
MNG-7636 Partially revert MNG-5868 to restore backward compatibility (see MNG-7316)
-
- Closed
-
- fixes
-
MDEPLOY-254 Maven Deploy Plugin deploy jar twice : Maven 3.3.3
-
- Closed
-
-
MINSTALL-159 Prevent adding several times the same file for install
-
- Closed
-
- is duplicated by
-
MNG-5387 Add ability to replace an artifact in mid-build
-
- Closed
-
-
MNG-5939 Problem doing release when sources are generate as well
-
- Closed
-
-
MSHARED-820 Check for duplicated attachment of the same artifact
-
- Closed
-
- is related to
-
MSHADE-195 createSourcesJar with source:jar-no-fork causes sources.jar to be deployed twice, causing the build to fail
-
- Closed
-
-
MNG-5384 Declarative artifacts
-
- Open
-
- relates to
-
MNG-5387 Add ability to replace an artifact in mid-build
-
- Closed
-
- links to
- mentioned in
-
Page Loading...