You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/04/01 05:56:53 UTC

[maven] branch MNG-5868 updated (8ce1d29 -> d1c4f72)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch MNG-5868
in repository https://gitbox.apache.org/repos/asf/maven.git.


    omit 8ce1d29  [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
     add 9f07b03  [MNG-6261] - using File apis to compare
     add e4e33f7  [MNG-6261] Relative parent POM resolution failing in 3.5.0 with complex multimodule builds
     add 732e7de  [MNG-6529] ProjectBuilder.build(List<Project> ...) honor request.isResolveDependency
     add c6bdafe  [MNG-5965] Parallel build multiplies work if multiple goals are given
     add 6c4c2e3  Change to keep only 5 artifacts on master and on branches only 1 artifact.
     add c7ab987  [MNG-6544] Replace CacheUtils#{eq,hash} with Objects
     add 71128cb  spelling: vertices
     add 9c94626  [MNG-6213] Validate scope in dependencyManagement
     add 391a111  [MNG-6526] Upgrade to Wagon 3.3.1
     add eab62f1  [MNG-6520] Update namespaces for maven-assembly to 2.0.0
     add 33e4f20  [MNG-6548] Lifecycle plugin version upgrades
     add d9facde  [MNG-6530] Introduce system property to disable global model cache
     add a939654  [MNG-6256] Surround parameter of echo command with double quotes
     add 8e5ecf0  fixed link (that goes to implementation in maven-core)
     add 375cd7b  [MNG-6559] Fix mailing list URL (#230)
     add fdf5d92  renamed variables for better understanding
     add 396291b  [MNG-6069] Migrate to non deprecated parts of Commons CLI (#153)
     add 2928dc6  refactoring: extracted initParent() method
     add 049b7a7  refactoring: reduced try/catch scope
     add ae1c32a  [MNG-6533] Test: ProjectBuildingException miss reference to MavenProject
     add 8b7055f  [MNG-6533] Prefer passing the interim project in ProjectBuildingResult
     add 27332cf  [MNG-6533] ProjectBuilder report ModelProblem instead of Exception
     add 24c762d  [MNG-6533] catch InvalidArtifactRTException runtime exception
     add bb3ec5d  [MNG-5995] Remove dependency to maven-compat (#185)
     add 7e3e545  [MNG-6573] Use Maven 3.6.0 for CI
     add 15c6471  [MNG-6558] ToolchainsBuildingResult event is not sent on EventSpy
     add b7249af  Revert [MNG-6069] Migrate to non deprecated parts of Commons CLI
     add 8f9075d  [MNG-6571] cache VersionRange instances, they are immutable
     add 6bd8bb9  [MNG-6571] forgot to put new instance in cache
     add 657fbb7  Revert "[MNG-6571] forgot to put new instance in cache"
     add 961746f  [MNG-6571] separate caches for create from spec and version
     add 4decfcf  [MNG-6591] Upgrade to Wagon 3.3.2
     add c674bcf  [MNG-6495] ModelResolver cannot be null
     add bd4a3a0  [MNG-6593] track input location for super-pom content
     add 9dd4732  Revert "[MNG-6548] Lifecycle plugin version upgrades"
     add 37676a2  [MNG-6599] use version from parent if necessary, like groupId
     add 4bec550  [MNG-6600] add inputlocation tracking for default lifecycle executions
     add 0b10fe7  [MNG-6597] add input location tracking for plugins configuration
     add 49c8f17  [MNG-6601] add input location tracking for m-site-p converted reports
     add f5a1374  [MNG-6572] use int or long instead of BigIntegers for little numbers in ComparableVersion
     add 0be2644  [MNG-6538]  Upgrade maven-resolver to 1.3.3
     add 5306cd0  [MNG-6506] [MNG-6543] Upgrade Plexus Classworlds to 2.6.0
     add a7acfe7  [MNG-6611] Update animal-sniffer-maven-plugin to version 1.17
     new d1c4f72  [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (8ce1d29)
            \
             N -- N -- N   refs/heads/MNG-5868 (d1c4f72)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CONTRIBUTING.md                                    |   4 +-
 Jenkinsfile                                        |  10 +-
 apache-maven/README.txt                            |   2 +-
 apache-maven/src/bin/mvn.cmd                       |   4 +-
 apache-maven/src/main/assembly/bin.xml             |   4 +-
 apache-maven/src/main/assembly/component.xml       |   4 +-
 apache-maven/src/main/assembly/dir.xml             |   4 +-
 apache-maven/src/main/assembly/src.xml             |   4 +-
 .../org/apache/maven/artifact/ArtifactUtils.java   |   2 +-
 .../artifact/versioning/ComparableVersion.java     | 227 ++++++++++--
 .../maven/artifact/versioning/VersionRange.java    |  33 +-
 .../artifact/versioning/ComparableVersionTest.java |  90 +++++
 .../artifact/versioning/VersionRangeTest.java      |  19 +
 .../apache/maven/bridge/MavenRepositorySystem.java | 100 +++++-
 .../internal/DefaultLifecyclePluginAnalyzer.java   |  22 +-
 .../multithreaded/ConcurrencyDependencyGraph.java  |   9 +-
 .../multithreaded/MultiThreadedBuilder.java        |  10 +-
 .../plugin/DefaultLifecycleBindingsInjector.java   |  14 +-
 .../java/org/apache/maven/plugin/CacheUtils.java   |  53 +--
 .../maven/project/DefaultProjectBuilder.java       | 382 ++++++++++++---------
 .../project/DefaultProjectBuildingHelper.java      |   6 +-
 .../org/apache/maven/project/ProjectSorter.java    |   2 +-
 .../internal/ConcurrencyDependencyGraphTest.java   |   2 +-
 .../apache/maven/project/ProjectBuilderTest.java   | 161 +++++++++
 .../resources/projects/artifactMissingVersion.xml  |  34 ++
 .../pom.xml => resources/projects/badPom.xml}      |  10 +-
 .../projects/basic-resolveDependencies.xml         |  15 +
 .../main/java/org/apache/maven/cli/MavenCli.java   |   6 +-
 .../java/org/apache/maven/cli/MavenCliTest.java    |  38 ++
 .../maven/model/building/DefaultModelBuilder.java  |   3 +-
 .../maven/model/building/FileModelSource.java      |  23 ++
 .../maven/model/building/ModelBuildingRequest.java |   4 +-
 .../maven/model/building/ModelProblemUtils.java    |   4 +
 .../model/plugin/DefaultReportingConverter.java    |  54 ++-
 .../model/superpom/DefaultSuperPomProvider.java    |  11 +-
 .../model/validation/DefaultModelValidator.java    |  10 +-
 maven-model-builder/src/site/apt/index.apt         |   4 +-
 .../maven/model/building/FileModelSourceTest.java  |  75 ++++
 .../validation/DefaultModelValidatorTest.java      |  10 +
 ...ier.xml => bad-dependency-management-scope.xml} |  38 +-
 maven-model/pom.xml                                |   1 +
 pom.xml                                            |  17 +-
 42 files changed, 1231 insertions(+), 294 deletions(-)
 create mode 100644 maven-core/src/test/resources/projects/artifactMissingVersion.xml
 copy maven-core/src/test/{projects/default-maven/cyclic-reference/pom.xml => resources/projects/badPom.xml} (53%)
 create mode 100644 maven-core/src/test/resources/projects/basic-resolveDependencies.xml
 create mode 100644 maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java
 copy maven-model-builder/src/test/resources/poms/validation/{bad-import-scope-classifier.xml => bad-dependency-management-scope.xml} (53%)


[maven] 01/01: [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MNG-5868
in repository https://gitbox.apache.org/repos/asf/maven.git

commit d1c4f72cc40389fb90fdfbcdf06c61dfdd1c9c26
Author: Christian Schulte <sc...@apache.org>
AuthorDate: Thu Dec 17 22:43:47 2015 +0100

    [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
    
    o Updated to restore the behaviour consensus had been reached in MNG-5387.
    o Kept 'MavenProject.getAttachedArtifacts' to return an unmodifiable list.
    o Updated to log an information message when an existing artifact got replaced.
---
 .../maven/project/DefaultMavenProjectHelper.java   | 13 ++++----
 .../org/apache/maven/project/MavenProject.java     | 39 ++++++++++++++++------
 2 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
index 1972242..d65aa73 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
@@ -94,16 +94,15 @@ public class DefaultMavenProjectHelper
         attachArtifact( project, artifact );
     }
 
-    /**
-     * 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 )
     {
+        final int size = project.getAttachedArtifacts().size();
         project.addAttachedArtifact( artifact );
+
+        if ( project.getAttachedArtifacts().size() == size && this.getLogger().isInfoEnabled() )
+        {
+            this.getLogger().info( String.format( "Replaced artifact %s.", artifact ) );
+        }
     }
 
     public void addResource( MavenProject project, String resourceDirectory, List<String> includes,
diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index fd7ab40..32a7267 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -909,19 +909,38 @@ public class MavenProject
     }
 
     /**
-     * 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.
+     * Adds or replaces an artifact.
      *
-     * @param artifact the artifact to add or replace.
-     * @throws DuplicateArtifactAttachmentException
+     * @param artifact The artifact to add or replace.
+     *
+     * @deprecated Please use {@link MavenProjectHelper}
+     * @see https://issues.apache.org/jira/browse/MNG-5868
+     * @see https://issues.apache.org/jira/browse/MNG-5387
+     * @see https://issues.apache.org/jira/browse/MNG-4013
+     * @see https://issues.apache.org/jira/browse/MNG-3119
      */
+    @Deprecated
     public void addAttachedArtifact( Artifact artifact )
-        throws DuplicateArtifactAttachmentException
     {
-        getAttachedArtifacts().add( artifact );
+        getAttachedArtifacts();
+        assert this.attachedArtifacts != null : "Unexpected missing attached artifacts.";
+
+        boolean replaced = false;
+        for ( int i = 0, s0 = this.attachedArtifacts.size(); i < s0; i++ )
+        {
+            final Artifact a = this.attachedArtifacts.get( i );
+
+            if ( a.equals( artifact ) )
+            {
+                this.attachedArtifacts.set( i, artifact );
+                replaced = true;
+            }
+        }
+
+        if ( !replaced )
+        {
+            this.attachedArtifacts.add( artifact );
+        }
     }
 
     public List<Artifact> getAttachedArtifacts()
@@ -930,7 +949,7 @@ public class MavenProject
         {
             attachedArtifacts = new ArrayList<>();
         }
-        return attachedArtifacts;
+        return Collections.unmodifiableList( attachedArtifacts );
     }
 
     public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId,