From e733004eb173d1521f381f537223025b7ccc6409 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Fri, 18 Jun 2010 02:48:46 +0000 Subject: [PATCH] o Restored backward-compat with Maven 2.x git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@955820 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultLegacyArtifactCollector.java | 9 ---- .../project/artifact/MavenMetadataSource.java | 54 +++++++++---------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java index 0cc4d29095..1a76f667d2 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java @@ -537,15 +537,6 @@ private void recurse( ArtifactResolutionResult result, { break; } - - Artifact relocated = rGroup.getRelocatedArtifact(); - if ( relocated != null && !artifact.equals( relocated ) ) - { - relocated.setDependencyFilter( artifact.getDependencyFilter() ); - artifact = relocated; - child.setArtifact( artifact ); - metadataRequest.setArtifact( artifact ); - } } while( !childKey.equals( child.getKey() ) ); diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 7f862b7b4f..ca2ccedc8d 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -535,23 +535,23 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact, MetadataR MavenProject project; Artifact pomArtifact; - Artifact relocatedArtifact = artifact; + Artifact relocatedArtifact = null; boolean done = false; do { project = null; pomArtifact = - repositorySystem.createProjectArtifact( relocatedArtifact.getGroupId(), - relocatedArtifact.getArtifactId(), - relocatedArtifact.getVersion(), relocatedArtifact.getScope() ); + repositorySystem.createProjectArtifact( artifact.getGroupId(), + artifact.getArtifactId(), + artifact.getVersion(), artifact.getScope() ); - if ( "pom".equals( relocatedArtifact.getType() ) ) + if ( "pom".equals( artifact.getType() ) ) { - pomArtifact.setFile( relocatedArtifact.getFile() ); + pomArtifact.setFile( artifact.getFile() ); } - if ( Artifact.SCOPE_SYSTEM.equals( relocatedArtifact.getScope() ) ) + if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { done = true; } @@ -581,27 +581,27 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact, MetadataR if ( missingParentPom != null ) { throw new ArtifactMetadataRetrievalException( "Failed to process POM for " - + relocatedArtifact.getId() + ": " + missingParentPom.getMessage(), + + artifact.getId() + ": " + missingParentPom.getMessage(), missingParentPom.getException(), - relocatedArtifact ); + artifact ); } String message; if ( e.getCause() instanceof MultipleArtifactsNotFoundException ) { - message = "Missing POM for " + relocatedArtifact.getId(); + message = "Missing POM for " + artifact.getId(); } else if ( e.getCause() instanceof ArtifactResolutionException ) { throw new ArtifactMetadataRetrievalException( "Failed to retrieve POM for " - + relocatedArtifact.getId() + ": " + e.getCause().getMessage(), e.getCause(), - relocatedArtifact ); + + artifact.getId() + ": " + e.getCause().getMessage(), e.getCause(), + artifact ); } else { message = - "Invalid POM for " + relocatedArtifact.getId() + "Invalid POM for " + artifact.getId() + ", transitive dependencies (if any) will not be available" + ", enable debug logging for more details"; } @@ -623,36 +623,34 @@ else if ( e.getCause() instanceof ArtifactResolutionException ) { relocation = distMgmt.getRelocation(); - relocatedArtifact.setDownloadUrl( distMgmt.getDownloadUrl() ); + artifact.setDownloadUrl( distMgmt.getDownloadUrl() ); pomArtifact.setDownloadUrl( distMgmt.getDownloadUrl() ); } if ( relocation != null ) { - if ( relocatedArtifact == artifact ) - { - relocatedArtifact = ArtifactUtils.copyArtifact( artifact ); - } - if ( relocation.getGroupId() != null ) { - relocatedArtifact.setGroupId( relocation.getGroupId() ); + artifact.setGroupId( relocation.getGroupId() ); + relocatedArtifact = artifact; project.setGroupId( relocation.getGroupId() ); } if ( relocation.getArtifactId() != null ) { - relocatedArtifact.setArtifactId( relocation.getArtifactId() ); + artifact.setArtifactId( relocation.getArtifactId() ); + relocatedArtifact = artifact; project.setArtifactId( relocation.getArtifactId() ); } if ( relocation.getVersion() != null ) { // note: see MNG-3454. This causes a problem, but fixing it may break more. - relocatedArtifact.setVersionRange( VersionRange.createFromVersion( relocation.getVersion() ) ); + artifact.setVersionRange( VersionRange.createFromVersion( relocation.getVersion() ) ); + relocatedArtifact = artifact; project.setVersion( relocation.getVersion() ); } if ( artifact.getDependencyFilter() != null - && !artifact.getDependencyFilter().include( relocatedArtifact ) ) + && !artifact.getDependencyFilter().include( artifact ) ) { return null; } @@ -665,14 +663,14 @@ else if ( e.getCause() instanceof ArtifactResolutionException ) { MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest( repositoryRequest ); - metadataRequest.setArtifact( relocatedArtifact ); + metadataRequest.setArtifact( artifact ); available = retrieveAvailableVersions( metadataRequest ); - relocatedArtifact.setAvailableVersions( available ); + artifact.setAvailableVersions( available ); } String message = - "\n This artifact has been relocated to " + relocatedArtifact.getGroupId() + ":" - + relocatedArtifact.getArtifactId() + ":" + relocatedArtifact.getVersion() + ".\n"; + "\n This artifact has been relocated to " + artifact.getGroupId() + ":" + + artifact.getArtifactId() + ":" + artifact.getVersion() + ".\n"; if ( relocation.getMessage() != null ) { @@ -706,7 +704,7 @@ else if ( e.getCause() instanceof ArtifactResolutionException ) ProjectRelocation rel = new ProjectRelocation(); rel.project = project; rel.pomArtifact = pomArtifact; - rel.relocatedArtifact = ( relocatedArtifact == artifact ) ? null : relocatedArtifact; + rel.relocatedArtifact = relocatedArtifact; return rel; }