Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3F680200498 for ; Tue, 29 Aug 2017 19:56:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3DA3116739C; Tue, 29 Aug 2017 17:56:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5FC6416739E for ; Tue, 29 Aug 2017 19:56:11 +0200 (CEST) Received: (qmail 98348 invoked by uid 500); 29 Aug 2017 17:56:10 -0000 Mailing-List: contact issues-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list issues@maven.apache.org Received: (qmail 98330 invoked by uid 99); 29 Aug 2017 17:56:10 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Aug 2017 17:56:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id E04C4188B30 for ; Tue, 29 Aug 2017 17:56:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id daUi6FA6sSSp for ; Tue, 29 Aug 2017 17:56:08 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id ED08F6103B for ; Tue, 29 Aug 2017 17:56:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 98B0EE0E29 for ; Tue, 29 Aug 2017 17:56:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id BA5FE24158 for ; Tue, 29 Aug 2017 17:56:00 +0000 (UTC) Date: Tue, 29 Aug 2017 17:56:00 +0000 (UTC) From: "Karl Heinz Marbaise (JIRA)" To: issues@maven.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (MNG-5868) Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 29 Aug 2017 17:56:12 -0000 [ https://issues.apache.org/jira/browse/MNG-5868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Karl Heinz Marbaise updated MNG-5868: ------------------------------------- Fix Version/s: (was: 3.5.2) 3.5.x-candidate > Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure > --------------------------------------------------------------------------------------------------------- > > Key: MNG-5868 > URL: https://issues.apache.org/jira/browse/MNG-5868 > Project: Maven > Issue Type: Bug > Components: core > Affects Versions: 3.2.3 > Reporter: Karl Heinz Marbaise > Assignee: Karl Heinz Marbaise > Fix For: 3.5.x-candidate > > > During the check of an issue MSHADE-195 i stumbled over several things... > If you take a look here and the log output excerpt: > {noformat} > 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] > {noformat} > 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): > {code: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 getAttachedArtifacts() > { > if ( attachedArtifacts == null ) > { > attachedArtifacts = new ArrayList<>(); > } > return attachedArtifacts; > } > {code} > So taking a look into MavenProjectHelper.java and the implementation (DefaultMavenProjectHelper.java). > {code: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 ); > } > {code} > which means that there is not check if an artifacts is already attached. -- This message was sent by Atlassian JIRA (v6.4.14#64029)