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/27 19:57:28 UTC
[maven-resolver] branch master updated: Revert "[MRESOLVER-233] Add protected abstract org.e.a.artifact.AbstractArtifact.newInstance()"
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new fb94663 Revert "[MRESOLVER-233] Add protected abstract org.e.a.artifact.AbstractArtifact.newInstance()"
fb94663 is described below
commit fb94663a2fa53ae06df768fafb6364cf89d3f250
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Thu Jan 27 20:55:20 2022 +0100
Revert "[MRESOLVER-233] Add protected abstract org.e.a.artifact.AbstractArtifact.newInstance()"
This reverts commit a1946d9a0aebccb565ff6aeaf1ab3f250ede0218.
Unfortunately, this breaks binary compatibility as documented by the Java
language specification in chapter 13.4.16, `abstract` methods:
https://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.4.16
Needs to be backed off until a package change will allow this (Resolver 3).
---
.../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, 47 insertions(+), 39 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 7a9fab9..f18b398 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,14 +90,18 @@ 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}.
*/
- protected abstract Artifact newInstance( String version, Map<String, String> properties, File file );
+ private Artifact newInstance( String version, Map<String, String> properties, File file )
+ {
+ return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, file,
+ properties );
+ }
public Artifact setVersion( String version )
{
@@ -138,7 +142,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}.
*/
@@ -171,7 +175,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.
@@ -201,7 +205,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 0d79918..f385e2c 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,13 +249,6 @@ 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 eeb9dca..00fbcd4 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,7 +105,6 @@ public abstract class DelegatingArtifact
return delegate.getFile();
}
- @Override
public Artifact setFile( File file )
{
Artifact artifact = delegate.setFile( file );
@@ -126,7 +125,6 @@ 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 d7e68d9..950ccc4 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,6 +21,7 @@ package org.eclipse.aether.util.artifact;
import java.io.File;
import java.util.Map;
+import java.util.Objects;
import static java.util.Objects.requireNonNull;
@@ -50,7 +51,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.
@@ -65,7 +66,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.
@@ -81,7 +82,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.
@@ -97,7 +98,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.
@@ -125,12 +126,6 @@ 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();
@@ -171,11 +166,29 @@ 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 = "";