You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/01/14 18:07:05 UTC

[maven-resolver] branch MRESOLVER-233 updated (c3344e9 -> a1946d9)

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

michaelo pushed a change to branch MRESOLVER-233
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git.


    omit c3344e9  [MRESOLVER-233] Make org.e.a.artifact.AbstractArtifact.newInstance() protected abstract
     new a1946d9  [MRESOLVER-233] Add protected abstract org.e.a.artifact.AbstractArtifact.newInstance()

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   (c3344e9)
            \
             N -- N -- N   refs/heads/MRESOLVER-233 (a1946d9)

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:

[maven-resolver] 01/01: [MRESOLVER-233] Add protected abstract org.e.a.artifact.AbstractArtifact.newInstance()

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

michaelo pushed a commit to branch MRESOLVER-233
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit a1946d9a0aebccb565ff6aeaf1ab3f250ede0218
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Thu Dec 30 15:28:51 2021 +0100

    [MRESOLVER-233] Add protected abstract org.e.a.artifact.AbstractArtifact.newInstance()
    
    This closes #143
---
 .../eclipse/aether/artifact/AbstractArtifact.java  | 18 ++++-------
 .../eclipse/aether/artifact/DefaultArtifact.java   | 25 +++++++++------
 .../aether/util/artifact/DelegatingArtifact.java   |  6 ++--
 .../eclipse/aether/util/artifact/SubArtifact.java  | 37 +++++++---------------
 4 files changed, 39 insertions(+), 47 deletions(-)

diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
index f18b398..7a9fab9 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java
@@ -8,9 +8,9 @@ package org.eclipse.aether.artifact;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -90,18 +90,14 @@ public abstract class AbstractArtifact
 
     /**
      * Creates a new artifact with the specified coordinates, properties and file.
-     * 
+     *
      * @param version The version of the artifact, may be {@code null}.
      * @param properties The properties of the artifact, may be {@code null} if none. The method may assume immutability
      *            of the supplied map, i.e. need not copy it.
      * @param file The resolved file of the artifact, may be {@code null}.
      * @return The new artifact instance, never {@code null}.
      */
-    private Artifact newInstance( String version, Map<String, String> properties, File file )
-    {
-        return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, file,
-                                    properties );
-    }
+    protected abstract Artifact newInstance( String version, Map<String, String> properties, File file );
 
     public Artifact setVersion( String version )
     {
@@ -142,7 +138,7 @@ public abstract class AbstractArtifact
     /**
      * Copies the specified artifact properties. This utility method should be used when creating new artifact instances
      * with caller-supplied properties.
-     * 
+     *
      * @param properties The properties to copy, may be {@code null}.
      * @return The copied and read-only properties, never {@code null}.
      */
@@ -175,7 +171,7 @@ public abstract class AbstractArtifact
 
     /**
      * Compares this artifact with the specified object.
-     * 
+     *
      * @param obj The object to compare this artifact against, may be {@code null}.
      * @return {@code true} if and only if the specified object is another {@link Artifact} with equal coordinates,
      *         properties and file, {@code false} otherwise.
@@ -205,7 +201,7 @@ public abstract class AbstractArtifact
 
     /**
      * Returns a hash code for this artifact.
-     * 
+     *
      * @return A hash code for the artifact.
      */
     @Override
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
index f385e2c..0d79918 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java
@@ -8,9 +8,9 @@ package org.eclipse.aether.artifact;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -53,7 +53,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates. If not specified in the artifact coordinates, the
      * artifact's extension defaults to {@code jar} and classifier to an empty string.
-     * 
+     *
      * @param coords The artifact coordinates in the format
      *            {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
      *
@@ -68,7 +68,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates and properties. If not specified in the artifact
      * coordinates, the artifact's extension defaults to {@code jar} and classifier to an empty string.
-     * 
+     *
      * @param coords The artifact coordinates in the format
      *            {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
      * @param properties The artifact properties, may be {@code null}.
@@ -101,7 +101,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates and no classifier. Passing {@code null} for any of the
      * coordinates is equivalent to specifying an empty string.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code null}.
      * @param artifactId The artifact identifier of the artifact, may be {@code null}.
      * @param extension The file extension of the artifact, may be {@code null}.
@@ -115,7 +115,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates. Passing {@code null} for any of the coordinates is
      * equivalent to specifying an empty string.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code null}.
      * @param artifactId The artifact identifier of the artifact, may be {@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -132,7 +132,7 @@ public final class DefaultArtifact
      * equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to
      * determine the artifact's classifier and file extension if the corresponding arguments for this constructor are
      * {@code null}.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code null}.
      * @param artifactId The artifact identifier of the artifact, may be {@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -152,7 +152,7 @@ public final class DefaultArtifact
      * will be used to determine the artifact's classifier and file extension if the corresponding arguments for this
      * constructor are {@code null}. If the artifact type specifies properties, those will get merged with the
      * properties passed directly into the constructor, with the latter properties taking precedence.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code null}.
      * @param artifactId The artifact identifier of the artifact, may be {@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -215,7 +215,7 @@ public final class DefaultArtifact
     /**
      * Creates a new artifact with the specified coordinates, properties and file. Passing {@code null} for any of the
      * coordinates is equivalent to specifying an empty string.
-     * 
+     *
      * @param groupId The group identifier of the artifact, may be {@code null}.
      * @param artifactId The artifact identifier of the artifact, may be {@code null}.
      * @param classifier The classifier of the artifact, may be {@code null}.
@@ -249,6 +249,13 @@ public final class DefaultArtifact
         this.properties = properties;
     }
 
+    @Override
+    protected Artifact newInstance( String version, Map<String, String> properties, File file )
+    {
+        return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, file,
+                                    properties );
+    }
+
     private static String emptify( String str )
     {
         return ( str == null ) ? "" : str;
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java
index 00fbcd4..eeb9dca 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java
@@ -8,9 +8,9 @@ package org.eclipse.aether.util.artifact;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -105,6 +105,7 @@ public abstract class DelegatingArtifact
         return delegate.getFile();
     }
 
+    @Override
     public Artifact setFile( File file )
     {
         Artifact artifact = delegate.setFile( file );
@@ -125,6 +126,7 @@ public abstract class DelegatingArtifact
         return delegate.getProperties();
     }
 
+    @Override
     public Artifact setProperties( Map<String, String> properties )
     {
         Artifact artifact = delegate.setProperties( properties );
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java
index 950ccc4..d7e68d9 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java
@@ -8,9 +8,9 @@ package org.eclipse.aether.util.artifact;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -21,7 +21,6 @@ package org.eclipse.aether.util.artifact;
 
 import java.io.File;
 import java.util.Map;
-import java.util.Objects;
 
 import static java.util.Objects.requireNonNull;
 
@@ -51,7 +50,7 @@ public final class SubArtifact
      * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
      * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
      * used to refer to the GPG signature of an artifact.
-     * 
+     *
      * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
      * @param classifier The classifier for this artifact, may be {@code null} if none.
      * @param extension The extension for this artifact, may be {@code null} if none.
@@ -66,7 +65,7 @@ public final class SubArtifact
      * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
      * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
      * used to refer to the GPG signature of an artifact.
-     * 
+     *
      * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
      * @param classifier The classifier for this artifact, may be {@code null} if none.
      * @param extension The extension for this artifact, may be {@code null} if none.
@@ -82,7 +81,7 @@ public final class SubArtifact
      * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
      * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
      * used to refer to the GPG signature of an artifact.
-     * 
+     *
      * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
      * @param classifier The classifier for this artifact, may be {@code null} if none.
      * @param extension The extension for this artifact, may be {@code null} if none.
@@ -98,7 +97,7 @@ public final class SubArtifact
      * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
      * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
      * used to refer to the GPG signature of an artifact.
-     * 
+     *
      * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
      * @param classifier The classifier for this artifact, may be {@code null} if none.
      * @param extension The extension for this artifact, may be {@code null} if none.
@@ -126,6 +125,12 @@ public final class SubArtifact
         this.properties = properties;
     }
 
+    @Override
+    protected Artifact newInstance( String version, Map<String, String> properties, File file )
+    {
+        return new SubArtifact( mainArtifact.setVersion( version ), classifier, extension, file, properties );
+    }
+
     public String getGroupId()
     {
         return mainArtifact.getGroupId();
@@ -166,29 +171,11 @@ public final class SubArtifact
         return file;
     }
 
-    public Artifact setFile( File file )
-    {
-        if ( Objects.equals( this.file, file ) )
-        {
-            return this;
-        }
-        return new SubArtifact( mainArtifact, classifier, extension, file, properties );
-    }
-
     public Map<String, String> getProperties()
     {
         return properties;
     }
 
-    public Artifact setProperties( Map<String, String> properties )
-    {
-        if ( this.properties.equals( properties ) || ( properties == null && this.properties.isEmpty() ) )
-        {
-            return this;
-        }
-        return new SubArtifact( mainArtifact, classifier, extension, properties, file );
-    }
-
     private static String expand( String pattern, String replacement )
     {
         String result = "";