Skip to content

Commit 4f16d5e

Browse files
authored
[MRESOLVER-547] Just use setVersion (#483)
No need for full copy, Artifact is already immutable. Moreover, the instance may be not DefaultArtifact but something else. And finally, setVersion already have "optimization" to return this if version is same as the one we want to copy with. --- https://issues.apache.org/jira/browse/MRESOLVER-547
1 parent c1b24c6 commit 4f16d5e

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

.github/workflows/maven-verify.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
jobs:
2525
build:
2626
name: Verify
27-
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3
27+
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
2828
with:
2929
ff-site-run: false
3030
maven-matrix: '[ "3.9.6" ]'

maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/bf/BfDependencyCollector.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
import org.eclipse.aether.RepositorySystemSession;
4646
import org.eclipse.aether.RequestTrace;
4747
import org.eclipse.aether.artifact.Artifact;
48-
import org.eclipse.aether.artifact.ArtifactType;
49-
import org.eclipse.aether.artifact.DefaultArtifact;
5048
import org.eclipse.aether.collection.CollectRequest;
5149
import org.eclipse.aether.collection.DependencyManager;
5250
import org.eclipse.aether.collection.DependencySelector;
@@ -431,14 +429,7 @@ private void resolveArtifactDescriptorAsync(Args args, DependencyProcessingConte
431429
private ArtifactDescriptorResult resolveDescriptorForVersion(
432430
Args args, DependencyProcessingContext context, Results results, Dependency dependency, Version version) {
433431
Artifact original = dependency.getArtifact();
434-
Artifact newArtifact = new DefaultArtifact(
435-
original.getGroupId(),
436-
original.getArtifactId(),
437-
original.getClassifier(),
438-
original.getExtension(),
439-
version.toString(),
440-
original.getProperties(),
441-
(ArtifactType) null);
432+
Artifact newArtifact = original.setVersion(version.toString());
442433
Dependency newDependency =
443434
new Dependency(newArtifact, dependency.getScope(), dependency.isOptional(), dependency.getExclusions());
444435
DependencyProcessingContext newContext = context.copy();

0 commit comments

Comments
 (0)