diff --git a/.gitignore b/.gitignore index bba4583caf..f8ca4f4ba0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ bin/ *.iml .idea out/ - .DS_Store /bootstrap /dependencies.xml diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 9794928cab..09180fc8eb 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -80,7 +80,7 @@ wagon-file - org.sonatype.aether + org.eclipse.aether aether-connector-wagon diff --git a/init-git-svn.sh b/init-git-svn.sh deleted file mode 100755 index 28ea5be9be..0000000000 --- a/init-git-svn.sh +++ /dev/null @@ -1,4 +0,0 @@ -cd .git;wget http://git.apache.org/authors.txt; cd .. -git config svn.authorsfile ".git/authors.txt" -git svn init --prefix=origin/ --tags=tags --trunk=trunk --branches=branches https://svn.apache.org/repos/asf/maven/maven-3 -git svn rebase diff --git a/maven-aether-provider/pom.xml b/maven-aether-provider/pom.xml index f6985d97b1..926c51e2c3 100644 --- a/maven-aether-provider/pom.xml +++ b/maven-aether-provider/pom.xml @@ -50,23 +50,23 @@ under the License. maven-repository-metadata - org.sonatype.aether + org.eclipse.aether aether-api - org.sonatype.aether + org.eclipse.aether aether-spi - org.sonatype.aether + org.eclipse.aether aether-util - org.sonatype.aether + org.eclipse.aether aether-impl - org.sonatype.aether + org.eclipse.aether aether-connector-wagon test @@ -87,6 +87,19 @@ under the License. org.codehaus.plexus plexus-utils + + com.google.inject + guice + 3.0 + no_aop + true + + + aopalliance + aopalliance + + + diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java index b7da0d1a62..85158037d6 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java @@ -20,10 +20,10 @@ package org.apache.maven.repository.internal; */ import org.apache.maven.model.Repository; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.RepositoryPolicy; -import org.sonatype.aether.util.artifact.DefaultArtifact; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.RepositoryPolicy; /** * Warning: This is an internal utility class that is only public for technical reasons, it is not part @@ -49,11 +49,11 @@ public class ArtifactDescriptorUtils public static RemoteRepository toRemoteRepository( Repository repository ) { - RemoteRepository result = - new RemoteRepository( repository.getId(), repository.getLayout(), repository.getUrl() ); - result.setPolicy( true, toRepositoryPolicy( repository.getSnapshots() ) ); - result.setPolicy( false, toRepositoryPolicy( repository.getReleases() ) ); - return result; + RemoteRepository.Builder builder = + new RemoteRepository.Builder( repository.getId(), repository.getLayout(), repository.getUrl() ); + builder.setSnapshotPolicy( toRepositoryPolicy( repository.getSnapshots() ) ); + builder.setReleasePolicy( toRepositoryPolicy( repository.getReleases() ) ); + return builder.build(); } public static RepositoryPolicy toRepositoryPolicy( org.apache.maven.model.RepositoryPolicy policy ) diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java index a86428b028..60a183c499 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java @@ -21,6 +21,7 @@ package org.apache.maven.repository.internal; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -28,6 +29,9 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import javax.inject.Inject; +import javax.inject.Named; + import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.License; @@ -45,51 +49,55 @@ import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.resolution.UnresolvableModelException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.sonatype.aether.RepositoryEvent.EventType; -import org.sonatype.aether.RepositoryException; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.artifact.ArtifactType; -import org.sonatype.aether.artifact.ArtifactTypeRegistry; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.Exclusion; -import org.sonatype.aether.impl.ArtifactDescriptorReader; -import org.sonatype.aether.impl.ArtifactResolver; -import org.sonatype.aether.impl.RemoteRepositoryManager; -import org.sonatype.aether.impl.RepositoryEventDispatcher; -import org.sonatype.aether.impl.VersionResolver; -import org.sonatype.aether.transfer.ArtifactNotFoundException; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.artifact.ArtifactProperties; -import org.sonatype.aether.util.artifact.DefaultArtifact; -import org.sonatype.aether.util.artifact.DefaultArtifactType; -import org.sonatype.aether.util.listener.DefaultRepositoryEvent; -import org.sonatype.aether.repository.WorkspaceRepository; -import org.sonatype.aether.resolution.ArtifactDescriptorException; -import org.sonatype.aether.resolution.ArtifactDescriptorRequest; -import org.sonatype.aether.resolution.ArtifactDescriptorResult; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResolutionException; -import org.sonatype.aether.resolution.ArtifactResult; -import org.sonatype.aether.resolution.VersionRequest; -import org.sonatype.aether.resolution.VersionResolutionException; -import org.sonatype.aether.resolution.VersionResult; -import org.sonatype.aether.spi.locator.Service; -import org.sonatype.aether.spi.locator.ServiceLocator; -import org.sonatype.aether.spi.log.Logger; -import org.sonatype.aether.spi.log.NullLogger; +import org.eclipse.aether.RepositoryException; +import org.eclipse.aether.RepositoryEvent.EventType; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactProperties; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.artifact.DefaultArtifactType; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.Exclusion; +import org.eclipse.aether.impl.ArtifactDescriptorReader; +import org.eclipse.aether.impl.ArtifactResolver; +import org.eclipse.aether.impl.RemoteRepositoryManager; +import org.eclipse.aether.impl.RepositoryEventDispatcher; +import org.eclipse.aether.impl.VersionResolver; +import org.eclipse.aether.repository.WorkspaceRepository; +import org.eclipse.aether.resolution.ArtifactDescriptorException; +import org.eclipse.aether.resolution.ArtifactDescriptorPolicy; +import org.eclipse.aether.resolution.ArtifactDescriptorPolicyRequest; +import org.eclipse.aether.resolution.ArtifactDescriptorRequest; +import org.eclipse.aether.resolution.ArtifactDescriptorResult; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.resolution.VersionRequest; +import org.eclipse.aether.resolution.VersionResolutionException; +import org.eclipse.aether.resolution.VersionResult; +import org.eclipse.aether.spi.locator.Service; +import org.eclipse.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.spi.log.Logger; +import org.eclipse.aether.spi.log.LoggerFactory; +import org.eclipse.aether.spi.log.NullLoggerFactory; +import org.eclipse.aether.transfer.ArtifactNotFoundException; /** * @author Benjamin Bentmann */ +@Named @Component( role = ArtifactDescriptorReader.class ) public class DefaultArtifactDescriptorReader implements ArtifactDescriptorReader, Service { - @Requirement - private Logger logger = NullLogger.INSTANCE; + @SuppressWarnings( "unused" ) + @Requirement( role = LoggerFactory.class ) + private Logger logger = NullLoggerFactory.LOGGER; @Requirement private RemoteRepositoryManager remoteRepositoryManager; @@ -106,9 +114,27 @@ public class DefaultArtifactDescriptorReader @Requirement private ModelBuilder modelBuilder; + public DefaultArtifactDescriptorReader() + { + // enable no-arg constructor + } + + @Inject + DefaultArtifactDescriptorReader( RemoteRepositoryManager remoteRepositoryManager, VersionResolver versionResolver, + ArtifactResolver artifactResolver, ModelBuilder modelBuilder, + RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory ) + { + setRemoteRepositoryManager( remoteRepositoryManager ); + setVersionResolver( versionResolver ); + setArtifactResolver( artifactResolver ); + setModelBuilder( modelBuilder ); + setLoggerFactory( loggerFactory ); + setRepositoryEventDispatcher( repositoryEventDispatcher ); + } + public void initService( ServiceLocator locator ) { - setLogger( locator.getService( Logger.class ) ); + setLoggerFactory( locator.getService( LoggerFactory.class ) ); setRemoteRepositoryManager( locator.getService( RemoteRepositoryManager.class ) ); setVersionResolver( locator.getService( VersionResolver.class ) ); setArtifactResolver( locator.getService( ArtifactResolver.class ) ); @@ -120,12 +146,18 @@ public class DefaultArtifactDescriptorReader } } - public DefaultArtifactDescriptorReader setLogger( Logger logger ) + public DefaultArtifactDescriptorReader setLoggerFactory( LoggerFactory loggerFactory ) { - this.logger = ( logger != null ) ? logger : NullLogger.INSTANCE; + this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() ); return this; } + void setLogger( LoggerFactory loggerFactory ) + { + // plexus support + setLoggerFactory( loggerFactory ); + } + public DefaultArtifactDescriptorReader setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) { if ( remoteRepositoryManager == null ) @@ -227,6 +259,8 @@ public class DefaultArtifactDescriptorReader } result.setProperties( properties ); + + setArtifactProperties( result, model ); } return result; @@ -236,7 +270,7 @@ public class DefaultArtifactDescriptorReader ArtifactDescriptorResult result ) throws ArtifactDescriptorException { - RequestTrace trace = DefaultRequestTrace.newChild( request.getTrace(), request ); + RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); Set visited = new LinkedHashSet(); for ( Artifact artifact = request.getArtifact();; ) @@ -261,7 +295,7 @@ public class DefaultArtifactDescriptorReader RepositoryException exception = new RepositoryException( "Artifact relocations form a cycle: " + visited ); invalidDescriptor( session, trace, artifact, exception ); - if ( session.isIgnoreInvalidArtifactDescriptor() ) + if ( ( getPolicy( session, artifact, request ) & ArtifactDescriptorPolicy.IGNORE_INVALID ) != 0 ) { return null; } @@ -286,7 +320,7 @@ public class DefaultArtifactDescriptorReader if ( e.getCause() instanceof ArtifactNotFoundException ) { missingDescriptor( session, trace, artifact, (Exception) e.getCause() ); - if ( session.isIgnoreMissingArtifactDescriptor() ) + if ( ( getPolicy( session, artifact, request ) & ArtifactDescriptorPolicy.IGNORE_MISSING ) != 0 ) { return null; } @@ -331,7 +365,7 @@ public class DefaultArtifactDescriptorReader } } invalidDescriptor( session, trace, artifact, e ); - if ( session.isIgnoreInvalidArtifactDescriptor() ) + if ( ( getPolicy( session, artifact, request ) & ArtifactDescriptorPolicy.IGNORE_INVALID ) != 0 ) { return null; } @@ -381,6 +415,23 @@ public class DefaultArtifactDescriptorReader return relocation; } + private void setArtifactProperties( ArtifactDescriptorResult result, Model model ) + { + String downloadUrl = null; + DistributionManagement distMngt = model.getDistributionManagement(); + if ( distMngt != null ) + { + downloadUrl = distMngt.getDownloadUrl(); + } + if ( downloadUrl != null && downloadUrl.length() > 0 ) + { + Artifact artifact = result.getArtifact(); + Map props = new HashMap( artifact.getProperties() ); + props.put( ArtifactProperties.DOWNLOAD_URL, downloadUrl ); + result.setArtifact( artifact.setProperties( props ) ); + } + } + private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); @@ -420,23 +471,33 @@ public class DefaultArtifactDescriptorReader private void missingDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact, Exception exception ) { - DefaultRepositoryEvent event = - new DefaultRepositoryEvent( EventType.ARTIFACT_DESCRIPTOR_MISSING, session, trace ); + RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.ARTIFACT_DESCRIPTOR_MISSING ); + event.setTrace( trace ); event.setArtifact( artifact ); event.setException( exception ); - repositoryEventDispatcher.dispatch( event ); + repositoryEventDispatcher.dispatch( event.build() ); } private void invalidDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact, Exception exception ) { - DefaultRepositoryEvent event = - new DefaultRepositoryEvent( EventType.ARTIFACT_DESCRIPTOR_INVALID, session, trace ); + RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.ARTIFACT_DESCRIPTOR_INVALID ); + event.setTrace( trace ); event.setArtifact( artifact ); event.setException( exception ); - repositoryEventDispatcher.dispatch( event ); + repositoryEventDispatcher.dispatch( event.build() ); + } + + private int getPolicy( RepositorySystemSession session, Artifact artifact, ArtifactDescriptorRequest request ) + { + ArtifactDescriptorPolicy policy = session.getArtifactDescriptorPolicy(); + if ( policy == null ) + { + return ArtifactDescriptorPolicy.STRICT; + } + return policy.getPolicy( session, new ArtifactDescriptorPolicyRequest( artifact, request.getRequestContext() ) ); } } diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java index 25b24c2c3f..2d4fa7d673 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCache.java @@ -20,8 +20,8 @@ package org.apache.maven.repository.internal; */ import org.apache.maven.model.building.ModelCache; -import org.sonatype.aether.RepositoryCache; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositoryCache; +import org.eclipse.aether.RepositorySystemSession; /** * A model builder cache backed by the repository system cache. diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java index 96b9fc3652..08ad432273 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java @@ -31,15 +31,15 @@ import org.apache.maven.model.building.ModelSource; import org.apache.maven.model.resolution.InvalidRepositoryException; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.model.resolution.UnresolvableModelException; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.ArtifactResolver; -import org.sonatype.aether.impl.RemoteRepositoryManager; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResolutionException; -import org.sonatype.aether.util.artifact.DefaultArtifact; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.impl.ArtifactResolver; +import org.eclipse.aether.impl.RemoteRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; /** * A model resolver to assist building of dependency POMs. This resolver gives priority to those repositories that have @@ -93,7 +93,7 @@ class DefaultModelResolver public void addRepository( Repository repository ) throws InvalidRepositoryException { - if ( !repositoryIds.add( repository.getId() ) ) + if ( session.isIgnoreArtifactDescriptorRepositories() || !repositoryIds.add( repository.getId() ) ) { return; } diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultServiceLocator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultServiceLocator.java deleted file mode 100644 index 032f5461c9..0000000000 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultServiceLocator.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.maven.repository.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.sonatype.aether.impl.ArtifactDescriptorReader; -import org.sonatype.aether.impl.MetadataGeneratorFactory; -import org.sonatype.aether.impl.VersionRangeResolver; -import org.sonatype.aether.impl.VersionResolver; - -/** - * A simple service locator that is already setup with all components from this library. To acquire a complete - * repository system, clients need to add some repository connectors for remote transfers. Note: This component - * is meant to assists those clients that employ the repository systems outside of an IoC container, Maven plugins - * should instead always use regular dependency injection to acquire the repository system. - * - * @author Benjamin Bentmann - * @deprecated use {@link MavenServiceLocator} instead, which is more explicit. - */ -public class DefaultServiceLocator - extends org.sonatype.aether.impl.internal.DefaultServiceLocator -{ - - /** - * Creates a new service locator that already knows about all service implementations included this library. - */ - public DefaultServiceLocator() - { - addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class ); - addService( VersionResolver.class, DefaultVersionResolver.class ); - addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class ); - addService( MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class ); - addService( MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class ); - } - -} diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java index 87c69fb0d0..a7ff573bbc 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java @@ -19,55 +19,65 @@ package org.apache.maven.repository.internal; * under the License. */ +import java.io.FileInputStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.inject.Inject; +import javax.inject.Named; + import org.apache.maven.artifact.repository.metadata.Versioning; +import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.sonatype.aether.RepositoryEvent.EventType; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.SyncContext; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.listener.DefaultRepositoryEvent; -import org.sonatype.aether.util.metadata.DefaultMetadata; -import org.sonatype.aether.util.version.GenericVersionScheme; -import org.sonatype.aether.version.InvalidVersionSpecificationException; -import org.sonatype.aether.version.Version; -import org.sonatype.aether.version.VersionConstraint; -import org.sonatype.aether.version.VersionScheme; -import org.sonatype.aether.impl.MetadataResolver; -import org.sonatype.aether.impl.RepositoryEventDispatcher; -import org.sonatype.aether.impl.SyncContextFactory; -import org.sonatype.aether.impl.VersionRangeResolver; -import org.sonatype.aether.metadata.Metadata; -import org.sonatype.aether.repository.ArtifactRepository; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.resolution.MetadataRequest; -import org.sonatype.aether.resolution.MetadataResult; -import org.sonatype.aether.resolution.VersionRangeRequest; -import org.sonatype.aether.resolution.VersionRangeResolutionException; -import org.sonatype.aether.resolution.VersionRangeResult; -import org.sonatype.aether.spi.locator.Service; -import org.sonatype.aether.spi.locator.ServiceLocator; -import org.sonatype.aether.spi.log.Logger; -import org.sonatype.aether.spi.log.NullLogger; +import org.codehaus.plexus.util.IOUtil; +import org.eclipse.aether.RepositoryEvent.EventType; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.SyncContext; +import org.eclipse.aether.impl.MetadataResolver; +import org.eclipse.aether.impl.RepositoryEventDispatcher; +import org.eclipse.aether.impl.SyncContextFactory; +import org.eclipse.aether.impl.VersionRangeResolver; +import org.eclipse.aether.metadata.DefaultMetadata; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.resolution.MetadataRequest; +import org.eclipse.aether.resolution.MetadataResult; +import org.eclipse.aether.resolution.VersionRangeRequest; +import org.eclipse.aether.resolution.VersionRangeResolutionException; +import org.eclipse.aether.resolution.VersionRangeResult; +import org.eclipse.aether.spi.locator.Service; +import org.eclipse.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.spi.log.Logger; +import org.eclipse.aether.spi.log.LoggerFactory; +import org.eclipse.aether.spi.log.NullLoggerFactory; +import org.eclipse.aether.util.version.GenericVersionScheme; +import org.eclipse.aether.version.InvalidVersionSpecificationException; +import org.eclipse.aether.version.Version; +import org.eclipse.aether.version.VersionConstraint; +import org.eclipse.aether.version.VersionScheme; /** * @author Benjamin Bentmann */ +@Named @Component( role = VersionRangeResolver.class ) public class DefaultVersionRangeResolver implements VersionRangeResolver, Service { - @Requirement - private Logger logger = NullLogger.INSTANCE; + private static final String MAVEN_METADATA_XML = "maven-metadata.xml"; + + @SuppressWarnings( "unused" ) + @Requirement( role = LoggerFactory.class ) + private Logger logger = NullLoggerFactory.LOGGER; @Requirement private MetadataResolver metadataResolver; @@ -78,20 +88,41 @@ public class DefaultVersionRangeResolver @Requirement private RepositoryEventDispatcher repositoryEventDispatcher; + public DefaultVersionRangeResolver() + { + // enable default constructor + } + + @Inject + DefaultVersionRangeResolver( MetadataResolver metadataResolver, SyncContextFactory syncContextFactory, + RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory ) + { + setMetadataResolver( metadataResolver ); + setSyncContextFactory( syncContextFactory ); + setLoggerFactory( loggerFactory ); + setRepositoryEventDispatcher( repositoryEventDispatcher ); + } + public void initService( ServiceLocator locator ) { - setLogger( locator.getService( Logger.class ) ); + setLoggerFactory( locator.getService( LoggerFactory.class ) ); setMetadataResolver( locator.getService( MetadataResolver.class ) ); setSyncContextFactory( locator.getService( SyncContextFactory.class ) ); setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) ); } - public DefaultVersionRangeResolver setLogger( Logger logger ) + public DefaultVersionRangeResolver setLoggerFactory( LoggerFactory loggerFactory ) { - this.logger = ( logger != null ) ? logger : NullLogger.INSTANCE; + this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() ); return this; } + void setLogger( LoggerFactory loggerFactory ) + { + // plexus support + setLoggerFactory( loggerFactory ); + } + public DefaultVersionRangeResolver setMetadataResolver( MetadataResolver metadataResolver ) { if ( metadataResolver == null ) @@ -142,7 +173,7 @@ public class DefaultVersionRangeResolver result.setVersionConstraint( versionConstraint ); - if ( versionConstraint.getRanges().isEmpty() ) + if ( versionConstraint.getRange() == null ) { result.addVersion( versionConstraint.getVersion() ); } @@ -178,13 +209,13 @@ public class DefaultVersionRangeResolver private Map getVersions( RepositorySystemSession session, VersionRangeResult result, VersionRangeRequest request ) { - RequestTrace trace = DefaultRequestTrace.newChild( request.getTrace(), request ); + RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); Map versionIndex = new HashMap(); Metadata metadata = new DefaultMetadata( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), - MavenMetadata.MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT ); + MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT ); List metadataRequests = new ArrayList( request.getRepositories().size() ); @@ -238,26 +269,40 @@ public class DefaultVersionRangeResolver { Versioning versioning = null; - if ( metadata != null ) + FileInputStream fis = null; + try { - SyncContext syncContext = syncContextFactory.newInstance( session, true ); + if ( metadata != null ) + { + SyncContext syncContext = syncContextFactory.newInstance( session, true ); - try - { - syncContext.acquire( null, Collections.singleton( metadata ) ); + try + { + syncContext.acquire( null, Collections.singleton( metadata ) ); - versioning = MavenMetadata.read( metadata.getFile() ).getVersioning(); - } - catch ( Exception e ) - { - invalidMetadata( session, trace, metadata, repository, e ); - result.addException( e ); - } - finally - { - syncContext.release(); + if ( metadata.getFile() != null && metadata.getFile().exists() ) + { + fis = new FileInputStream( metadata.getFile() ); + org.apache.maven.artifact.repository.metadata.Metadata m = + new MetadataXpp3Reader().read( fis, false ); + versioning = m.getVersioning(); + } + } + finally + { + syncContext.close(); + } } } + catch ( Exception e ) + { + invalidMetadata( session, trace, metadata, repository, e ); + result.addException( e ); + } + finally + { + IOUtil.close( fis ); + } return ( versioning != null ) ? versioning : new Versioning(); } @@ -265,12 +310,13 @@ public class DefaultVersionRangeResolver private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata, ArtifactRepository repository, Exception exception ) { - DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace ); + RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID ); + event.setTrace( trace ); event.setMetadata( metadata ); event.setException( exception ); event.setRepository( repository ); - repositoryEventDispatcher.dispatch( event ); + repositoryEventDispatcher.dispatch( event.build() ); } -} +} \ No newline at end of file diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java index cf34483480..9fcfc996bc 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java @@ -20,6 +20,7 @@ package org.apache.maven.repository.internal; */ import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -27,65 +28,68 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.inject.Inject; +import javax.inject.Named; + import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotVersion; import org.apache.maven.artifact.repository.metadata.Versioning; +import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.aether.RepositoryCache; -import org.sonatype.aether.RepositoryEvent.EventType; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.SyncContext; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.MetadataResolver; -import org.sonatype.aether.impl.RepositoryEventDispatcher; -import org.sonatype.aether.impl.SyncContextFactory; -import org.sonatype.aether.impl.VersionResolver; -import org.sonatype.aether.impl.internal.CacheUtils; -import org.sonatype.aether.metadata.Metadata; -import org.sonatype.aether.repository.ArtifactRepository; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.repository.WorkspaceRepository; -import org.sonatype.aether.resolution.MetadataRequest; -import org.sonatype.aether.resolution.MetadataResult; -import org.sonatype.aether.resolution.VersionRequest; -import org.sonatype.aether.resolution.VersionResolutionException; -import org.sonatype.aether.resolution.VersionResult; -import org.sonatype.aether.spi.locator.Service; -import org.sonatype.aether.spi.locator.ServiceLocator; -import org.sonatype.aether.spi.log.Logger; -import org.sonatype.aether.spi.log.NullLogger; -import org.sonatype.aether.util.ConfigUtils; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.listener.DefaultRepositoryEvent; -import org.sonatype.aether.util.metadata.DefaultMetadata; +import org.eclipse.aether.RepositoryCache; +import org.eclipse.aether.RepositoryEvent.EventType; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.SyncContext; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.impl.MetadataResolver; +import org.eclipse.aether.impl.RepositoryEventDispatcher; +import org.eclipse.aether.impl.SyncContextFactory; +import org.eclipse.aether.impl.VersionResolver; +import org.eclipse.aether.internal.impl.CacheUtils; +import org.eclipse.aether.metadata.DefaultMetadata; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.repository.WorkspaceRepository; +import org.eclipse.aether.resolution.MetadataRequest; +import org.eclipse.aether.resolution.MetadataResult; +import org.eclipse.aether.resolution.VersionRequest; +import org.eclipse.aether.resolution.VersionResolutionException; +import org.eclipse.aether.resolution.VersionResult; +import org.eclipse.aether.spi.locator.Service; +import org.eclipse.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.spi.log.Logger; +import org.eclipse.aether.spi.log.LoggerFactory; +import org.eclipse.aether.spi.log.NullLoggerFactory; +import org.eclipse.aether.util.ConfigUtils; /** - * Maven meta-version resolver: supports *-SNAPSHOT, RELEASE and LATEST - * meta-version resolution from - * versioning - * element in repositories' maven-metadata.xml. - * * @author Benjamin Bentmann - * @see Versioning */ +@Named @Component( role = VersionResolver.class ) public class DefaultVersionResolver implements VersionResolver, Service { + private static final String MAVEN_METADATA_XML = "maven-metadata.xml"; + private static final String RELEASE = "RELEASE"; private static final String LATEST = "LATEST"; private static final String SNAPSHOT = "SNAPSHOT"; - @Requirement - private Logger logger = NullLogger.INSTANCE; + @SuppressWarnings( "unused" ) + @Requirement( role = LoggerFactory.class ) + private Logger logger = NullLoggerFactory.LOGGER; @Requirement private MetadataResolver metadataResolver; @@ -96,20 +100,41 @@ public class DefaultVersionResolver @Requirement private RepositoryEventDispatcher repositoryEventDispatcher; + public DefaultVersionResolver() + { + // enable no-arg constructor + } + + @Inject + DefaultVersionResolver( MetadataResolver metadataResolver, SyncContextFactory syncContextFactory, + RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory ) + { + setMetadataResolver( metadataResolver ); + setSyncContextFactory( syncContextFactory ); + setLoggerFactory( loggerFactory ); + setRepositoryEventDispatcher( repositoryEventDispatcher ); + } + public void initService( ServiceLocator locator ) { - setLogger( locator.getService( Logger.class ) ); + setLoggerFactory( locator.getService( LoggerFactory.class ) ); setMetadataResolver( locator.getService( MetadataResolver.class ) ); setSyncContextFactory( locator.getService( SyncContextFactory.class ) ); setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) ); } - public DefaultVersionResolver setLogger( Logger logger ) + public DefaultVersionResolver setLoggerFactory( LoggerFactory loggerFactory ) { - this.logger = ( logger != null ) ? logger : NullLogger.INSTANCE; + this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() ); return this; } + void setLogger( LoggerFactory loggerFactory ) + { + // plexus support + setLoggerFactory( loggerFactory ); + } + public DefaultVersionResolver setMetadataResolver( MetadataResolver metadataResolver ) { if ( metadataResolver == null ) @@ -143,6 +168,8 @@ public class DefaultVersionResolver public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) throws VersionResolutionException { + RequestTrace trace = RequestTrace.newChild( request.getTrace(), request ); + Artifact artifact = request.getArtifact(); String version = artifact.getVersion(); @@ -151,7 +178,6 @@ public class DefaultVersionResolver Key cacheKey = null; RepositoryCache cache = session.getCache(); - if ( cache != null && !ConfigUtils.getBoolean( session, false, "aether.versionResolver.noCache" ) ) { cacheKey = new Key( session, request ); @@ -167,81 +193,127 @@ public class DefaultVersionResolver } } + Metadata metadata; + if ( RELEASE.equals( version ) ) { - Map infos = readVersionInfoMap( session, result, Metadata.Nature.RELEASE, null ); - - resolve( result, infos, RELEASE ); + metadata = + new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, + Metadata.Nature.RELEASE ); } else if ( LATEST.equals( version ) ) { - Map infos = - readVersionInfoMap( session, result, Metadata.Nature.RELEASE_OR_SNAPSHOT, null ); - - if ( !resolve( result, infos, LATEST ) ) - { - resolve( result, infos, RELEASE ); - } - - if ( result.getVersion() != null && result.getVersion().endsWith( SNAPSHOT ) ) - { - VersionRequest subRequest = new VersionRequest(); - subRequest.setArtifact( artifact.setVersion( result.getVersion() ) ); - if ( result.getRepository() instanceof RemoteRepository ) - { - subRequest.setRepositories( Collections.singletonList( (RemoteRepository) result.getRepository() ) ); - } - else - { - subRequest.setRepositories( request.getRepositories() ); - } - VersionResult subResult = resolveVersion( session, subRequest ); - result.setVersion( subResult.getVersion() ); - result.setRepository( subResult.getRepository() ); - for ( Exception exception : subResult.getExceptions() ) - { - result.addException( exception ); - } - } + metadata = + new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML, + Metadata.Nature.RELEASE_OR_SNAPSHOT ); } else if ( version.endsWith( SNAPSHOT ) ) { WorkspaceReader workspace = session.getWorkspaceReader(); if ( workspace != null && workspace.findVersions( artifact ).contains( version ) ) { - result.setVersion( version ); + metadata = null; result.setRepository( workspace.getRepository() ); - - return result; } else { - Map infos = - readVersionInfoMap( session, result, Metadata.Nature.SNAPSHOT, version ); + metadata = + new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), version, MAVEN_METADATA_XML, + Metadata.Nature.SNAPSHOT ); + } + } + else + { + metadata = null; + } + if ( metadata == null ) + { + result.setVersion( version ); + } + else + { + List metadataRequests = new ArrayList( request.getRepositories().size() ); + + metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) ); + + for ( RemoteRepository repository : request.getRepositories() ) + { + MetadataRequest metadataRequest = + new MetadataRequest( metadata, repository, request.getRequestContext() ); + metadataRequest.setDeleteLocalCopyIfMissing( true ); + metadataRequest.setFavorLocalRepository( true ); + metadataRequest.setTrace( trace ); + metadataRequests.add( metadataRequest ); + } + + List metadataResults = metadataResolver.resolveMetadata( session, metadataRequests ); + + Map infos = new HashMap(); + + for ( MetadataResult metadataResult : metadataResults ) + { + result.addException( metadataResult.getException() ); + + ArtifactRepository repository = metadataResult.getRequest().getRepository(); + if ( repository == null ) + { + repository = session.getLocalRepository(); + } + + Versioning versioning = readVersions( session, trace, metadataResult.getMetadata(), repository, result ); + merge( artifact, infos, versioning, repository ); + } + + if ( RELEASE.equals( version ) ) + { + resolve( result, infos, RELEASE ); + } + else if ( LATEST.equals( version ) ) + { + if ( !resolve( result, infos, LATEST ) ) + { + resolve( result, infos, RELEASE ); + } + + if ( result.getVersion() != null && result.getVersion().endsWith( SNAPSHOT ) ) + { + VersionRequest subRequest = new VersionRequest(); + subRequest.setArtifact( artifact.setVersion( result.getVersion() ) ); + if ( result.getRepository() instanceof RemoteRepository ) + { + subRequest.setRepositories( Collections.singletonList( (RemoteRepository) result.getRepository() ) ); + } + else + { + subRequest.setRepositories( request.getRepositories() ); + } + VersionResult subResult = resolveVersion( session, subRequest ); + result.setVersion( subResult.getVersion() ); + result.setRepository( subResult.getRepository() ); + for ( Exception exception : subResult.getExceptions() ) + { + result.addException( exception ); + } + } + } + else + { String key = SNAPSHOT + getKey( artifact.getClassifier(), artifact.getExtension() ); - merge( infos, SNAPSHOT, key ); - if ( !resolve( result, infos, key ) ) { result.setVersion( version ); } } - } - else - { - result.setVersion( version ); - return result; + if ( StringUtils.isEmpty( result.getVersion() ) ) + { + throw new VersionResolutionException( result ); + } } - if ( StringUtils.isEmpty( result.getVersion() ) ) - { - throw new VersionResolutionException( result ); - } - - if ( cacheKey != null && isSafelyCacheable( session, artifact ) ) + if ( cacheKey != null && metadata != null && isSafelyCacheable( session, artifact ) ) { cache.put( session, cacheKey, new Record( result.getVersion(), result.getRepository() ) ); } @@ -249,54 +321,6 @@ public class DefaultVersionResolver return result; } - private Map readVersionInfoMap( RepositorySystemSession session, VersionResult result, - Metadata.Nature nature, String version ) - { - VersionRequest request = result.getRequest(); - Artifact artifact = request.getArtifact(); - - Metadata metadata = - new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), version, - MavenMetadata.MAVEN_METADATA_XML, nature ); - - RequestTrace trace = DefaultRequestTrace.newChild( request.getTrace(), request ); - - List metadataRequests = new ArrayList( request.getRepositories().size() + 1 ); - - metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) ); - - for ( RemoteRepository repository : request.getRepositories() ) - { - MetadataRequest metadataRequest = new MetadataRequest( metadata, repository, request.getRequestContext() ); - metadataRequest.setDeleteLocalCopyIfMissing( true ); - metadataRequest.setFavorLocalRepository( true ); - metadataRequest.setTrace( trace ); - - metadataRequests.add( metadataRequest ); - } - - List metadataResults = metadataResolver.resolveMetadata( session, metadataRequests ); - - Map infos = new HashMap(); - - for ( MetadataResult metadataResult : metadataResults ) - { - result.addException( metadataResult.getException() ); - - ArtifactRepository repository = metadataResult.getRequest().getRepository(); - if ( repository == null ) - { - repository = session.getLocalRepository(); - } - - Versioning versioning = readVersions( session, trace, metadataResult.getMetadata(), repository, result ); - - merge( request.getArtifact(), infos, versioning, repository ); - } - - return infos; - } - private boolean resolve( VersionResult result, Map infos, String key ) { VersionInfo info = infos.get( key ); @@ -313,41 +337,50 @@ public class DefaultVersionResolver { Versioning versioning = null; - - if ( metadata == null ) - { - return new Versioning(); - } - - SyncContext syncContext = syncContextFactory.newInstance( session, true ); - + FileInputStream fis = null; try { - syncContext.acquire( null, Collections.singleton( metadata ) ); - - versioning = MavenMetadata.read( metadata.getFile() ).getVersioning(); - - /* - * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata - * of the local repository. This is especially troublesome during snapshot resolution so we try - * to handle that gracefully. - */ - if ( versioning != null && repository instanceof LocalRepository ) + if ( metadata != null ) { - Snapshot snapshot = versioning.getSnapshot(); - if ( snapshot != null && snapshot.getBuildNumber() > 0 ) + SyncContext syncContext = syncContextFactory.newInstance( session, true ); + + try { - Versioning repaired = new Versioning(); - repaired.setLastUpdated( versioning.getLastUpdated() ); - snapshot = new Snapshot(); - snapshot.setLocalCopy( true ); - repaired.setSnapshot( snapshot ); + syncContext.acquire( null, Collections.singleton( metadata ) ); - versioning = repaired; + if ( metadata.getFile() != null && metadata.getFile().exists() ) + { + fis = new FileInputStream( metadata.getFile() ); + org.apache.maven.artifact.repository.metadata.Metadata m = + new MetadataXpp3Reader().read( fis, false ); + versioning = m.getVersioning(); - throw new IOException( "Snapshot information corrupted with remote repository data" - + ", please verify that no remote repository uses the id '" + repository.getId() - + "'" ); + /* + * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata + * of the local repository. This is especially troublesome during snapshot resolution so we try + * to handle that gracefully. + */ + if ( versioning != null && repository instanceof LocalRepository ) + { + if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 ) + { + Versioning repaired = new Versioning(); + repaired.setLastUpdated( versioning.getLastUpdated() ); + Snapshot snapshot = new Snapshot(); + snapshot.setLocalCopy( true ); + repaired.setSnapshot( snapshot ); + versioning = repaired; + + throw new IOException( "Snapshot information corrupted with remote repository data" + + ", please verify that no remote repository uses the id '" + repository.getId() + + "'" ); + } + } + } + } + finally + { + syncContext.close(); } } } @@ -358,7 +391,7 @@ public class DefaultVersionResolver } finally { - syncContext.release(); + IOUtil.close( fis ); } return ( versioning != null ) ? versioning : new Versioning(); @@ -367,12 +400,13 @@ public class DefaultVersionResolver private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata, ArtifactRepository repository, Exception exception ) { - DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace ); + RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID ); + event.setTrace( trace ); event.setMetadata( metadata ); event.setException( exception ); event.setRepository( repository ); - repositoryEventDispatcher.dispatch( event ); + repositoryEventDispatcher.dispatch( event.build() ); } private void merge( Artifact artifact, Map infos, Versioning versioning, @@ -597,4 +631,4 @@ public class DefaultVersionResolver } } -} +} \ No newline at end of file diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java index 4cea6c1b3b..a22d07d27a 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java @@ -21,6 +21,7 @@ package org.apache.maven.repository.internal; import java.io.File; import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; @@ -28,44 +29,72 @@ import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotVersion; import org.apache.maven.artifact.repository.metadata.Versioning; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * @author Benjamin Bentmann */ final class LocalSnapshotMetadata - extends MavenSnapshotMetadata + extends MavenMetadata { + private final Collection artifacts = new ArrayList(); + + private final boolean legacyFormat; + public LocalSnapshotMetadata( Artifact artifact, boolean legacyFormat ) { - super( createLocalMetadata( artifact, legacyFormat ), null, legacyFormat ); + super( createMetadata( artifact, legacyFormat ), null ); + this.legacyFormat = legacyFormat; } public LocalSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) { - super( metadata, file, legacyFormat ); + super( metadata, file ); + this.legacyFormat = legacyFormat; } - private static Metadata createLocalMetadata( Artifact artifact, boolean legacyFormat ) + private static Metadata createMetadata( Artifact artifact, boolean legacyFormat ) { - Metadata metadata = createRepositoryMetadata( artifact, legacyFormat ); - Snapshot snapshot = new Snapshot(); snapshot.setLocalCopy( true ); Versioning versioning = new Versioning(); versioning.setSnapshot( snapshot ); + Metadata metadata = new Metadata(); metadata.setVersioning( versioning ); + metadata.setGroupId( artifact.getGroupId() ); + metadata.setArtifactId( artifact.getArtifactId() ); + metadata.setVersion( artifact.getBaseVersion() ); + + if ( !legacyFormat ) + { + metadata.setModelVersion( "1.1.0" ); + } return metadata; } + public void bind( Artifact artifact ) + { + artifacts.add( artifact ); + } + public MavenMetadata setFile( File file ) { return new LocalSnapshotMetadata( metadata, file, legacyFormat ); } + public Object getKey() + { + return getGroupId() + ':' + getArtifactId() + ':' + getVersion(); + } + + public static Object getKey( Artifact artifact ) + { + return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion(); + } + @Override protected void merge( Metadata recessive ) { @@ -106,4 +135,29 @@ final class LocalSnapshotMetadata artifacts.clear(); } -} + private String getKey( String classifier, String extension ) + { + return classifier + ':' + extension; + } + + public String getGroupId() + { + return metadata.getGroupId(); + } + + public String getArtifactId() + { + return metadata.getArtifactId(); + } + + public String getVersion() + { + return metadata.getVersion(); + } + + public Nature getNature() + { + return Nature.SNAPSHOT; + } + +} \ No newline at end of file diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java index 9476acc57d..ee7c10b0c4 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java @@ -24,12 +24,12 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.MetadataGenerator; -import org.sonatype.aether.installation.InstallRequest; -import org.sonatype.aether.metadata.Metadata; -import org.sonatype.aether.util.ConfigUtils; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.util.ConfigUtils; /** * @author Benjamin Bentmann diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java new file mode 100644 index 0000000000..0432cdb6d0 --- /dev/null +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java @@ -0,0 +1,55 @@ +package org.apache.maven.repository.internal; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.apache.maven.model.building.DefaultModelBuilderFactory; +import org.apache.maven.model.building.ModelBuilder; +import org.eclipse.aether.impl.AetherModule; +import org.eclipse.aether.impl.ArtifactDescriptorReader; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.impl.VersionRangeResolver; +import org.eclipse.aether.impl.VersionResolver; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.name.Names; + +public final class MavenAetherModule + extends AbstractModule +{ + + @Override + protected void configure() + { + install( new AetherModule() ); + bind( ArtifactDescriptorReader.class ) // + .to( DefaultArtifactDescriptorReader.class ).in( Singleton.class ); + bind( VersionResolver.class ) // + .to( DefaultVersionResolver.class ).in( Singleton.class ); + bind( VersionRangeResolver.class ) // + .to( DefaultVersionRangeResolver.class ).in( Singleton.class ); + bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) ) // + .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class ); + bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) ) // + .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class ); + bind( ModelBuilder.class ) // + .toInstance( new DefaultModelBuilderFactory().newInstance() ); + } + + @Provides + @Singleton + Set provideMetadataGeneratorFactories( @Named( "snapshot" ) MetadataGeneratorFactory snapshot, + @Named( "versions" ) MetadataGeneratorFactory versions ) + { + Set factories = new HashSet(); + factories.add( snapshot ); + factories.add( versions ); + return Collections.unmodifiableSet( factories ); + } + +} diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java index 78be415fc7..bdf287831b 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java @@ -23,6 +23,8 @@ import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.Writer; +import java.util.Collections; +import java.util.Map; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; @@ -31,13 +33,15 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.sonatype.aether.RepositoryException; -import org.sonatype.aether.metadata.MergeableMetadata; +import org.eclipse.aether.RepositoryException; +import org.eclipse.aether.metadata.AbstractMetadata; +import org.eclipse.aether.metadata.MergeableMetadata; /** * @author Benjamin Bentmann */ abstract class MavenMetadata + extends AbstractMetadata implements MergeableMetadata { @@ -132,24 +136,15 @@ abstract class MavenMetadata } } - @Override - public String toString() + public Map getProperties() { - StringBuilder buffer = new StringBuilder( 128 ); - if ( getGroupId().length() > 0 ) - { - buffer.append( getGroupId() ); - } - if ( getArtifactId().length() > 0 ) - { - buffer.append( ':' ).append( getArtifactId() ); - } - if ( getVersion().length() > 0 ) - { - buffer.append( ':' ).append( getVersion() ); - } - buffer.append( '/' ).append( getType() ); - return buffer.toString(); + return Collections.emptyMap(); + } + + @Override + public org.eclipse.aether.metadata.Metadata setProperties( Map properties ) + { + return this; } } diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemSession.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemSession.java deleted file mode 100644 index e6dad6ddf1..0000000000 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemSession.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.apache.maven.repository.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.sonatype.aether.collection.DependencyGraphTransformer; -import org.sonatype.aether.collection.DependencyManager; -import org.sonatype.aether.collection.DependencySelector; -import org.sonatype.aether.collection.DependencyTraverser; -import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.artifact.DefaultArtifactType; -import org.sonatype.aether.util.artifact.DefaultArtifactTypeRegistry; -import org.sonatype.aether.util.graph.manager.ClassicDependencyManager; -import org.sonatype.aether.util.graph.selector.AndDependencySelector; -import org.sonatype.aether.util.graph.selector.ExclusionDependencySelector; -import org.sonatype.aether.util.graph.selector.OptionalDependencySelector; -import org.sonatype.aether.util.graph.selector.ScopeDependencySelector; -import org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer; -import org.sonatype.aether.util.graph.transformer.ConflictMarker; -import org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner; -import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator; -import org.sonatype.aether.util.graph.transformer.NearestVersionConflictResolver; -import org.sonatype.aether.util.graph.traverser.FatArtifactTraverser; -import org.sonatype.aether.util.repository.DefaultAuthenticationSelector; -import org.sonatype.aether.util.repository.DefaultMirrorSelector; -import org.sonatype.aether.util.repository.DefaultProxySelector; - -/** - * The base Maven repository system session, without environment configuration (authentication, mirror, - * proxy, ...). - * - *

Warning: This class is not intended for - * usage by Maven plugins, those should always acquire the current repository system session via - * plugin - * parameter injection, since the current repository system session is created by Maven in - * - * DefaultMaven.newRepositorySession(MavenExecutionRequest request).

- * - * @author Benjamin Bentmann - */ -public class MavenRepositorySystemSession - extends DefaultRepositorySystemSession -{ - - /** - * Creates a new Maven repository system session by initializing the session with values typical for - * Maven-based resolution. In more detail, this constructor configures settings relevant for the processing of - * dependency graphs, most other settings remain at their generic default value. Use the various setters to further - * configure the session with authentication, mirror, proxy and other information required for your environment. - * - * @param standalone is this instance expected to be used inside Maven, with Plexus and Maven core components, or - * standalone? If standalone, System properties are used and classical Maven artifact handlers are pre-configured - * to mimic complete Maven repository system session. - */ - public MavenRepositorySystemSession( boolean standalone ) - { - DependencyTraverser depTraverser = new FatArtifactTraverser(); - setDependencyTraverser( depTraverser ); - - DependencyManager depManager = new ClassicDependencyManager(); - setDependencyManager( depManager ); - - DependencySelector depFilter = - new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), - new OptionalDependencySelector(), new ExclusionDependencySelector() ); - setDependencySelector( depFilter ); - - DependencyGraphTransformer transformer = - new ChainedDependencyGraphTransformer( new ConflictMarker(), new JavaEffectiveScopeCalculator(), - new NearestVersionConflictResolver(), - new JavaDependencyContextRefiner() ); - setDependencyGraphTransformer( transformer ); - - setIgnoreInvalidArtifactDescriptor( true ); - setIgnoreMissingArtifactDescriptor( true ); - - if ( standalone ) - { - setMirrorSelector( new DefaultMirrorSelector() ); - setAuthenticationSelector( new DefaultAuthenticationSelector() ); - setProxySelector( new DefaultProxySelector() ); - - DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); - stereotypes.add( new DefaultArtifactType( "pom" ) ); - stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) ); - stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) ); - stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) ); - stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) ); - stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) ); - stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) ); - stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) ); - stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) ); - stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) ); - stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) ); - stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) ); - setArtifactTypeRegistry( stereotypes ); - - setSystemProps( System.getProperties() ); - setConfigProps( System.getProperties() ); - } - } - -} diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java new file mode 100644 index 0000000000..b7ed320158 --- /dev/null +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java @@ -0,0 +1,136 @@ +package org.apache.maven.repository.internal; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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 + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Properties; + +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.artifact.DefaultArtifactType; +import org.eclipse.aether.collection.DependencyGraphTransformer; +import org.eclipse.aether.collection.DependencyManager; +import org.eclipse.aether.collection.DependencySelector; +import org.eclipse.aether.collection.DependencyTraverser; +import org.eclipse.aether.impl.ArtifactDescriptorReader; +import org.eclipse.aether.impl.DefaultServiceLocator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.impl.VersionRangeResolver; +import org.eclipse.aether.impl.VersionResolver; +import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry; +import org.eclipse.aether.util.graph.manager.ClassicDependencyManager; +import org.eclipse.aether.util.graph.selector.AndDependencySelector; +import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; +import org.eclipse.aether.util.graph.selector.OptionalDependencySelector; +import org.eclipse.aether.util.graph.selector.ScopeDependencySelector; +import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; +import org.eclipse.aether.util.graph.transformer.ConflictResolver; +import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; +import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver; +import org.eclipse.aether.util.graph.transformer.JavaScopeSelector; +import org.eclipse.aether.util.graph.transformer.NearestVersionSelector; +import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector; +import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; +import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; + +/** + * A utility class to assist in setting up a Maven-like repository system. Note: This component is meant to + * assist those clients that employ the repository system outside of an IoC container, Maven plugins should instead + * always use regular dependency injection to acquire the repository system. + * + * @author Benjamin Bentmann + */ +public final class MavenRepositorySystemUtils +{ + + private MavenRepositorySystemUtils() + { + // hide constructor + } + + /** + * Creates a new service locator that already knows about all service implementations included in this library. To + * acquire a complete repository system, clients need to add some repository connectors for remote transfers. + * + * @return The new service locator, never {@code null}. + */ + public static DefaultServiceLocator newServiceLocator() + { + DefaultServiceLocator locator = new DefaultServiceLocator(); + locator.addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class ); + locator.addService( VersionResolver.class, DefaultVersionResolver.class ); + locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class ); + locator.addService( MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class ); + locator.addService( MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class ); + return locator; + } + + /** + * Creates a new Maven-like repository system session by initializing the session with values typical for + * Maven-based resolution. In more detail, this method configures settings relevant for the processing of dependency + * graphs, most other settings remain at their generic default value. Use the various setters to further configure + * the session with authentication, mirror, proxy and other information required for your environment. + * + * @return The new repository system session, never {@code null}. + */ + public static DefaultRepositorySystemSession newSession() + { + DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); + + DependencyTraverser depTraverser = new FatArtifactTraverser(); + session.setDependencyTraverser( depTraverser ); + + DependencyManager depManager = new ClassicDependencyManager(); + session.setDependencyManager( depManager ); + + DependencySelector depFilter = + new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), + new OptionalDependencySelector(), new ExclusionDependencySelector() ); + session.setDependencySelector( depFilter ); + + DependencyGraphTransformer transformer = + new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), + new SimpleOptionalitySelector(), new JavaScopeDeriver() ); + new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() ); + session.setDependencyGraphTransformer( transformer ); + + DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); + stereotypes.add( new DefaultArtifactType( "pom" ) ); + stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) ); + stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) ); + stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) ); + stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) ); + stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) ); + stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) ); + stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) ); + stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) ); + stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) ); + stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) ); + stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) ); + session.setArtifactTypeRegistry( stereotypes ); + + session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); + + Properties sysProps = System.getProperties(); + session.setSystemProperties( sysProps ); + session.setConfigProperties( sysProps ); + + return session; + } + +} diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenServiceLocator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenServiceLocator.java deleted file mode 100644 index f0a45f588c..0000000000 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenServiceLocator.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.maven.repository.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.sonatype.aether.impl.ArtifactDescriptorReader; -import org.sonatype.aether.impl.internal.DefaultServiceLocator; -import org.sonatype.aether.impl.MetadataGeneratorFactory; -import org.sonatype.aether.impl.VersionRangeResolver; -import org.sonatype.aether.impl.VersionResolver; - -/** - * A simple service locator that is already setup with all components from this library. To acquire a complete - * repository system, clients need to add some repository connectors for remote transfers. - * - *

Note: This component is meant to assist those clients that employ the repository systems outside of an IoC - * container, Maven plugins should instead always use regular dependency injection to acquire the repository system: - * it is defined as Plexus component in aether-impl with its dependencies.

- * - * @author Benjamin Bentmann - */ -public class MavenServiceLocator - extends DefaultServiceLocator -{ - - /** - * Creates a new service locator that already knows about all service implementations included in this library. - */ - public MavenServiceLocator() - { - addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class ); - addService( VersionResolver.class, DefaultVersionResolver.class ); - addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class ); - addService( MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class ); - addService( MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class ); - } - -} diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java index 0f88cdc1d4..1e6f9097d4 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import org.apache.maven.artifact.repository.metadata.Metadata; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * @author Hervé Boutemy diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java index 3acc3cb636..958eb388cb 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java @@ -22,8 +22,8 @@ package org.apache.maven.repository.internal; import java.io.File; import java.util.Map; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.util.artifact.AbstractArtifact; +import org.eclipse.aether.artifact.AbstractArtifact; +import org.eclipse.aether.artifact.Artifact; /** * @author Benjamin Bentmann @@ -88,16 +88,6 @@ final class RelocatedArtifact } } - public String getBaseVersion() - { - return toBaseVersion( getVersion() ); - } - - public boolean isSnapshot() - { - return isSnapshot( getVersion() ); - } - public String getClassifier() { return artifact.getClassifier(); diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java index 246c786e0b..60b8749a6f 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java @@ -32,7 +32,7 @@ import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotVersion; import org.apache.maven.artifact.repository.metadata.Versioning; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * @author Benjamin Bentmann diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java index 9d3bdc6b20..6cbeec5505 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java @@ -24,12 +24,12 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.deployment.DeployRequest; -import org.sonatype.aether.impl.MetadataGenerator; -import org.sonatype.aether.metadata.Metadata; -import org.sonatype.aether.util.ConfigUtils; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.util.ConfigUtils; /** * @author Benjamin Bentmann diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java index 60e9c3e99c..79ffaade7d 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/SnapshotMetadataGeneratorFactory.java @@ -20,11 +20,11 @@ package org.apache.maven.repository.internal; */ import org.codehaus.plexus.component.annotations.Component; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.deployment.DeployRequest; -import org.sonatype.aether.impl.MetadataGenerator; -import org.sonatype.aether.impl.MetadataGeneratorFactory; -import org.sonatype.aether.installation.InstallRequest; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.installation.InstallRequest; /** * @author Benjamin Bentmann @@ -44,7 +44,7 @@ public class SnapshotMetadataGeneratorFactory return new RemoteSnapshotMetadataGenerator( session, request ); } - public int getPriority() + public float getPriority() { return 10; } diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java index 2fefe02e1d..adaca9dbc7 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java @@ -26,8 +26,8 @@ import java.util.LinkedHashSet; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Versioning; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.util.artifact.ArtifactProperties; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactProperties; /** * @author Benjamin Bentmann diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java index db1c412810..e2f5e82d5b 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java @@ -25,12 +25,12 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.deployment.DeployRequest; -import org.sonatype.aether.impl.MetadataGenerator; -import org.sonatype.aether.installation.InstallRequest; -import org.sonatype.aether.metadata.Metadata; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.metadata.Metadata; /** * @author Benjamin Bentmann diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java index a1e986f5ba..47ef36012b 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGeneratorFactory.java @@ -20,11 +20,11 @@ package org.apache.maven.repository.internal; */ import org.codehaus.plexus.component.annotations.Component; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.deployment.DeployRequest; -import org.sonatype.aether.impl.MetadataGenerator; -import org.sonatype.aether.impl.MetadataGeneratorFactory; -import org.sonatype.aether.installation.InstallRequest; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.installation.InstallRequest; /** * @author Benjamin Bentmann @@ -44,7 +44,7 @@ public class VersionsMetadataGeneratorFactory return new VersionsMetadataGenerator( session, request ); } - public int getPriority() + public float getPriority() { return 5; } diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java deleted file mode 100644 index 3b2f379fba..0000000000 --- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.repository.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.net.MalformedURLException; - -import org.apache.maven.repository.internal.util.ConsoleRepositoryListener; -import org.apache.maven.repository.internal.util.ConsoleTransferListener; -import org.codehaus.plexus.PlexusTestCase; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.RemoteRepository; - -public abstract class AbstractRepositoryTestCase - extends PlexusTestCase -{ - protected RepositorySystem system; - - protected RepositorySystemSession session; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - system = lookup( RepositorySystem.class ); - session = newMavenRepositorySystemSession( system ); - } - - @Override - protected void tearDown() - throws Exception - { - session = null; - system = null; - super.tearDown(); - } - - public static RepositorySystemSession newMavenRepositorySystemSession( RepositorySystem system ) - { - MavenRepositorySystemSession session = new MavenRepositorySystemSession( true ); - - LocalRepository localRepo = new LocalRepository( "target/local-repo" ); - session.setLocalRepositoryManager( system.newLocalRepositoryManager( localRepo ) ); - - session.setTransferListener( new ConsoleTransferListener() ); - session.setRepositoryListener( new ConsoleRepositoryListener() ); - - return session; - } - - public static RemoteRepository newTestRepository() - throws MalformedURLException - { - return new RemoteRepository( "repo", "default", - getTestFile( "target/test-classes/repo" ).toURI().toURL().toString() ); - } -} diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java deleted file mode 100644 index 1feaef808b..0000000000 --- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.repository.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.VersionResolver; -import org.sonatype.aether.resolution.VersionRequest; -import org.sonatype.aether.resolution.VersionResult; -import org.sonatype.aether.util.artifact.DefaultArtifact; - -public class DefaultVersionResolverTest - extends AbstractRepositoryTestCase -{ - private DefaultVersionResolver versionResolver; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - // be sure we're testing the right class, i.e. DefaultVersionResolver.class - versionResolver = (DefaultVersionResolver) lookup( VersionResolver.class, "default" ); - } - - @Override - protected void tearDown() - throws Exception - { - versionResolver = null; - super.tearDown(); - } - - public void testResolveSeparateInstalledClassifiedNonUniqueVersionedArtifacts() - throws Exception - { - VersionRequest requestB = new VersionRequest(); - requestB.addRepository( newTestRepository() ); - Artifact artifactB = - new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", "07.20.3-SNAPSHOT" ); - requestB.setArtifact( artifactB ); - - VersionResult resultB = versionResolver.resolveVersion( session, requestB ); - assertEquals( "07.20.3-20120809.112920-97", resultB.getVersion() ); - - VersionRequest requestA = new VersionRequest(); - requestA.addRepository( newTestRepository() ); - - Artifact artifactA = - new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", "07.20.3-SNAPSHOT" ); - requestA.setArtifact( artifactA ); - - VersionResult resultA = versionResolver.resolveVersion( session, requestA ); - assertEquals( "07.20.3-20120809.112124-88", resultA.getVersion() ); - } - - public void testResolveSeparateInstalledClassifiedNonVersionedArtifacts() - throws Exception - { - VersionRequest requestA = new VersionRequest(); - requestA.addRepository( newTestRepository() ); - String versionA = "07.20.3-20120809.112124-88"; - Artifact artifactA = - new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", versionA ); - requestA.setArtifact( artifactA ); - - VersionResult resultA = versionResolver.resolveVersion( session, requestA ); - assertEquals( versionA, resultA.getVersion() ); - - VersionRequest requestB = new VersionRequest(); - requestB.addRepository( newTestRepository() ); - String versionB = "07.20.3-20120809.112920-97"; - Artifact artifactB = - new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", versionB ); - requestB.setArtifact( artifactB ); - - VersionResult resultB = versionResolver.resolveVersion( session, requestB ); - assertEquals( versionB, resultB.getVersion() ); - } -} diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultServiceLocatorTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java similarity index 77% rename from maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultServiceLocatorTest.java rename to maven-aether-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java index 064b6754da..768835a555 100644 --- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultServiceLocatorTest.java +++ b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java @@ -19,26 +19,26 @@ package org.apache.maven.repository.internal; * under the License. */ -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.impl.MetadataGeneratorFactory; -import org.sonatype.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.spi.locator.ServiceLocator; import junit.framework.TestCase; -public class DefaultServiceLocatorTest +public class MavenRepositorySystemUtilsTest extends TestCase { public void testGetRepositorySystem() { - ServiceLocator locator = new MavenServiceLocator(); + ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); RepositorySystem repoSys = locator.getService( RepositorySystem.class ); assertNotNull( repoSys ); } public void testGetMetadataGeneratorFactories() { - ServiceLocator locator = new MavenServiceLocator(); + ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); assertEquals( 2, locator.getServices( MetadataGeneratorFactory.class ).size() ); } diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java deleted file mode 100644 index 86e3c37f73..0000000000 --- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.apache.maven.repository.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Arrays; -import java.util.List; - -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.collection.CollectRequest; -import org.sonatype.aether.collection.CollectResult; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.resolution.ArtifactDescriptorRequest; -import org.sonatype.aether.resolution.ArtifactDescriptorResult; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResult; -import org.sonatype.aether.util.artifact.DefaultArtifact; - -public class RepositorySystemTest - extends AbstractRepositoryTestCase -{ - public void testResolveVersionRange() - throws Exception - { - //VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request ) - // throws VersionRangeResolutionException; - - } - - public void testResolveVersion() - throws Exception - { - //VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) - // throws VersionResolutionException; - } - - public void testReadArtifactDescriptor() - throws Exception - { - Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" ); - - ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(); - request.setArtifact( artifact ); - request.addRepository( newTestRepository() ); - - ArtifactDescriptorResult result = system.readArtifactDescriptor( session, request ); - - List deps = result.getDependencies(); - assertEquals( 2, deps.size() ); - checkUtSimpleArtifactDependencies( deps.get( 0 ), deps.get( 1 ) ); - } - - /** - * check ut.simple:artifact:1.0 dependencies - */ - private void checkUtSimpleArtifactDependencies( Dependency dep1, Dependency dep2 ) - { - assertEquals( "compile", dep1.getScope() ); - assertFalse( dep1.isOptional() ); - assertEquals( 0, dep1.getExclusions().size() ); - Artifact depArtifact = dep1.getArtifact(); - assertEquals( "ut.simple", depArtifact.getGroupId() ); - assertEquals( "dependency", depArtifact.getArtifactId() ); - assertEquals( "1.0", depArtifact.getVersion() ); - assertEquals( "1.0", depArtifact.getBaseVersion() ); - assertNull( depArtifact.getFile() ); - assertFalse( depArtifact.isSnapshot() ); - assertEquals( "", depArtifact.getClassifier() ); - assertEquals( "jar", depArtifact.getExtension() ); - assertEquals( "java", depArtifact.getProperty( "language", null ) ); - assertEquals( "jar", depArtifact.getProperty( "type", null ) ); - assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) ); - assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) ); - assertEquals( 4, depArtifact.getProperties().size() ); - - assertEquals( "compile", dep2.getScope() ); - assertFalse( dep2.isOptional() ); - assertEquals( 0, dep2.getExclusions().size() ); - depArtifact = dep2.getArtifact(); - assertEquals( "ut.simple", depArtifact.getGroupId() ); - assertEquals( "dependency", depArtifact.getArtifactId() ); - assertEquals( "1.0", depArtifact.getVersion() ); - assertEquals( "1.0", depArtifact.getBaseVersion() ); - assertNull( depArtifact.getFile() ); - assertFalse( depArtifact.isSnapshot() ); - assertEquals( "sources", depArtifact.getClassifier() ); - assertEquals( "jar", depArtifact.getExtension() ); - assertEquals( "java", depArtifact.getProperty( "language", null ) ); - assertEquals( "jar", depArtifact.getProperty( "type", null ) ); // shouldn't it be java-sources given the classifier? - assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) ); // shouldn't it be false given the classifier? - assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) ); - assertEquals( 4, depArtifact.getProperties().size() ); - } - - public void testCollectDependencies() - throws Exception - { - Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" ); - // notice: extension and classifier not really used in this test... - - CollectRequest collectRequest = new CollectRequest(); - collectRequest.setRoot( new Dependency( artifact, null ) ); - collectRequest.addRepository( newTestRepository() ); - - CollectResult collectResult = system.collectDependencies( session, collectRequest ); - - List nodes = collectResult.getRoot().getChildren(); - assertEquals( 2, nodes.size() ); - checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() ); - } - - public void testResolveArtifact() - throws Exception - { - Artifact artifact = new DefaultArtifact( "ut.simple:artifact:1.0" ); - - ArtifactRequest artifactRequest = new ArtifactRequest(); - artifactRequest.setArtifact( artifact ); - artifactRequest.addRepository( newTestRepository() ); - - ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest ); - checkArtifactResult( artifactResult, "artifact-1.0.jar" ); - - artifact = new DefaultArtifact( "ut.simple:artifact:zip:1.0" ); - artifactRequest.setArtifact( artifact ); - artifactResult = system.resolveArtifact( session, artifactRequest ); - checkArtifactResult( artifactResult, "artifact-1.0.zip" ); - - artifact = new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ); - artifactRequest.setArtifact( artifact ); - artifactResult = system.resolveArtifact( session, artifactRequest ); - checkArtifactResult( artifactResult, "artifact-1.0-classifier.zip" ); - } - - private void checkArtifactResult( ArtifactResult result, String filename ) - { - assertFalse( result.isMissing() ); - assertTrue( result.isResolved() ); - Artifact artifact = result.getArtifact(); - assertNotNull( artifact.getFile() ); - assertEquals( filename, artifact.getFile().getName() ); - } - - public void testResolveArtifacts() - throws Exception - { - ArtifactRequest req1 = new ArtifactRequest(); - req1.setArtifact( new DefaultArtifact( "ut.simple:artifact:1.0" ) ); - req1.addRepository( newTestRepository() ); - - ArtifactRequest req2 = new ArtifactRequest(); - req2.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:1.0" ) ); - req2.addRepository( newTestRepository() ); - - ArtifactRequest req3 = new ArtifactRequest(); - req3.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ) ); - req3.addRepository( newTestRepository() ); - - List requests = Arrays.asList( new ArtifactRequest[] { req1, req2, req3 } ); - - List results = system.resolveArtifacts( session, requests ); - - assertEquals( 3, results.size() ); - checkArtifactResult( results.get( 0 ), "artifact-1.0.jar" ); - checkArtifactResult( results.get( 1 ), "artifact-1.0.zip" ); - checkArtifactResult( results.get( 2 ), "artifact-1.0-classifier.zip" ); - } - - public void testResolveMetadata() - throws Exception - { - //List resolveMetadata( RepositorySystemSession session, - // Collection requests ); - } - - public void testInstall() - throws Exception - { - //InstallResult install( RepositorySystemSession session, InstallRequest request ) - // throws InstallationException; - // release, snapshot unique ou non unique, attachement - } - - public void testDeploy() - throws Exception - { - //DeployResult deploy( RepositorySystemSession session, DeployRequest request ) - // throws DeploymentException; - } - - public void testNewLocalRepositoryManager() - throws Exception - { - //LocalRepositoryManager newLocalRepositoryManager( LocalRepository localRepository ); - } - - public void testNewSyncContext() - throws Exception - { - //SyncContext newSyncContext( RepositorySystemSession session, boolean shared ); - } - -} diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java deleted file mode 100644 index 2eec34894c..0000000000 --- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.apache.maven.repository.internal.util; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.PrintStream; - -import org.sonatype.aether.AbstractRepositoryListener; -import org.sonatype.aether.RepositoryEvent; - -public class ConsoleRepositoryListener - extends AbstractRepositoryListener -{ - - private PrintStream out; - - public ConsoleRepositoryListener() - { - this( null ); - } - - public ConsoleRepositoryListener( PrintStream out ) - { - this.out = ( out != null ) ? out : System.out; - } - - public void artifactDeployed( RepositoryEvent event ) - { - println( "artifactDeployed", event.getArtifact() + " to " + event.getRepository() ); - } - - public void artifactDeploying( RepositoryEvent event ) - { - println( "artifactDeploying", event.getArtifact() + " to " + event.getRepository() ); - } - - public void artifactDescriptorInvalid( RepositoryEvent event ) - { - println( "artifactDescriptorInvalid", "for " + event.getArtifact() + ": " + event.getException().getMessage() ); - } - - public void artifactDescriptorMissing( RepositoryEvent event ) - { - println( "artifactDescriptorMissing", "for " + event.getArtifact() ); - } - - public void artifactInstalled( RepositoryEvent event ) - { - println( "artifactInstalled", event.getArtifact() + " to " + event.getFile() ); - } - - public void artifactInstalling( RepositoryEvent event ) - { - println( "artifactInstalling", event.getArtifact() + " to " + event.getFile() ); - } - - public void artifactResolved( RepositoryEvent event ) - { - println( "artifactResolved", event.getArtifact() + " from " + event.getRepository() ); - } - - public void artifactDownloading( RepositoryEvent event ) - { - println( "artifactDownloading", event.getArtifact() + " from " + event.getRepository() ); - } - - public void artifactDownloaded( RepositoryEvent event ) - { - println( "artifactDownloaded", event.getArtifact() + " from " + event.getRepository() ); - } - - public void artifactResolving( RepositoryEvent event ) - { - println( "artifactResolving", event.getArtifact().toString() ); - } - - public void metadataDeployed( RepositoryEvent event ) - { - println( "metadataDeployed", event.getMetadata() + " to " + event.getRepository() ); - } - - public void metadataDeploying( RepositoryEvent event ) - { - println( "metadataDeploying", event.getMetadata() + " to " + event.getRepository() ); - } - - public void metadataInstalled( RepositoryEvent event ) - { - println( "metadataInstalled", event.getMetadata() + " to " + event.getFile() ); - } - - public void metadataInstalling( RepositoryEvent event ) - { - println( "metadataInstalling", event.getMetadata() + " to " + event.getFile() ); - } - - public void metadataInvalid( RepositoryEvent event ) - { - println( "metadataInvalid", event.getMetadata().toString() ); - } - - public void metadataResolved( RepositoryEvent event ) - { - println( "metadataResolved", event.getMetadata() + " from " + event.getRepository() ); - } - - public void metadataResolving( RepositoryEvent event ) - { - println( "metadataResolving", event.getMetadata() + " from " + event.getRepository() ); - } - - private void println( String event, String message ) - { - out.println( "Aether Repository - " + event + ": " + message ); - } -} diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java deleted file mode 100644 index 920298a123..0000000000 --- a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.apache.maven.repository.internal.util; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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 - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.PrintStream; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.sonatype.aether.transfer.AbstractTransferListener; -import org.sonatype.aether.transfer.TransferEvent; -import org.sonatype.aether.transfer.TransferResource; - -public class ConsoleTransferListener - extends AbstractTransferListener -{ - - private PrintStream out; - - private Map downloads = new ConcurrentHashMap(); - - private int lastLength; - - public ConsoleTransferListener() - { - this( null ); - } - - public ConsoleTransferListener( PrintStream out ) - { - this.out = ( out != null ) ? out : System.out; - } - - @Override - public void transferInitiated( TransferEvent event ) - { - String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading"; - - println( "transferInitiated", message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() ); - } - - @Override - public void transferProgressed( TransferEvent event ) - { - TransferResource resource = event.getResource(); - downloads.put( resource, Long.valueOf( event.getTransferredBytes() ) ); - - StringBuilder buffer = new StringBuilder( 64 ); - - for ( Map.Entry entry : downloads.entrySet() ) - { - long total = entry.getKey().getContentLength(); - long complete = entry.getValue().longValue(); - - buffer.append( getStatus( complete, total ) ).append( " " ); - } - - int pad = lastLength - buffer.length(); - lastLength = buffer.length(); - pad( buffer, pad ); - buffer.append( '\r' ); - - print( "transferProgressed", buffer.toString() ); - } - - private String getStatus( long complete, long total ) - { - if ( total >= 1024 ) - { - return toKB( complete ) + "/" + toKB( total ) + " KB "; - } - else if ( total >= 0 ) - { - return complete + "/" + total + " B "; - } - else if ( complete >= 1024 ) - { - return toKB( complete ) + " KB "; - } - else - { - return complete + " B "; - } - } - - private void pad( StringBuilder buffer, int spaces ) - { - String block = " "; - while ( spaces > 0 ) - { - int n = Math.min( spaces, block.length() ); - buffer.append( block, 0, n ); - spaces -= n; - } - } - - @Override - public void transferSucceeded( TransferEvent event ) - { - transferCompleted( event ); - - TransferResource resource = event.getResource(); - long contentLength = event.getTransferredBytes(); - if ( contentLength >= 0 ) - { - String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded" ); - String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B"; - - String throughput = ""; - long duration = System.currentTimeMillis() - resource.getTransferStartTime(); - if ( duration > 0 ) - { - DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) ); - double kbPerSec = ( contentLength / 1024.0 ) / ( duration / 1000.0 ); - throughput = " at " + format.format( kbPerSec ) + " KB/sec"; - } - - println( "transferSucceeded", type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" - + len + throughput + ")" ); - } - } - - @Override - public void transferFailed( TransferEvent event ) - { - transferCompleted( event ); - - println( "transferFailed", event.getException().getClass() + ": " + event.getException().getMessage() ); - } - - private void transferCompleted( TransferEvent event ) - { - downloads.remove( event.getResource() ); - - StringBuilder buffer = new StringBuilder( 64 ); - pad( buffer, lastLength ); - buffer.append( '\r' ); - out.println( buffer ); - } - - @Override - public void transferCorrupted( TransferEvent event ) - { - println( "transferCorrupted", event.getException().getClass() + ": " + event.getException().getMessage() ); - } - - protected long toKB( long bytes ) - { - return ( bytes + 1023 ) / 1024; - } - - private void println( String event, String message ) - { - print( event, message ); - out.println(); - } - - private void print( String event, String message ) - { - out.print( "Aether Transfer - " + event ); - if ( message != null ) - { - out.print( ": " ); - out.print( message ); - } - } -} diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index e098fade53..8f7faa4544 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -72,7 +72,7 @@ test - org.sonatype.aether + org.eclipse.aether aether-connector-wagon test diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java b/maven-compat/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java index cc9e665d9e..abbab821a0 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java @@ -37,15 +37,15 @@ import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.deployment.DeployRequest; -import org.sonatype.aether.deployment.DeployResult; -import org.sonatype.aether.deployment.DeploymentException; -import org.sonatype.aether.metadata.MergeableMetadata; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.artifact.SubArtifact; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.deployment.DeployResult; +import org.eclipse.aether.deployment.DeploymentException; +import org.eclipse.aether.metadata.MergeableMetadata; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.artifact.SubArtifact; @Component( role = ArtifactDeployer.class, instantiationStrategy = "per-lookup" ) public class DefaultArtifactDeployer @@ -84,9 +84,9 @@ public class DefaultArtifactDeployer DeployRequest request = new DeployRequest(); - request.setTrace( DefaultRequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); + request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); - org.sonatype.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); + org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); mainArtifact = mainArtifact.setFile( source ); request.addArtifact( mainArtifact ); @@ -103,7 +103,7 @@ public class DefaultArtifactDeployer { if ( metadata instanceof ProjectArtifactMetadata ) { - org.sonatype.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); + org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); request.addArtifact( pomArtifact ); } @@ -126,8 +126,10 @@ public class DefaultArtifactDeployer if ( deploymentRepository instanceof DefaultArtifactRepository && deploymentRepository.getAuthentication() == null ) { - remoteRepo.setAuthentication( session.getAuthenticationSelector().getAuthentication( remoteRepo ) ); - remoteRepo.setProxy( session.getProxySelector().getProxy( remoteRepo ) ); + RemoteRepository.Builder builder = new RemoteRepository.Builder( remoteRepo ); + builder.setAuthentication( session.getAuthenticationSelector().getAuthentication( remoteRepo ) ); + builder.setProxy( session.getProxySelector().getProxy( remoteRepo ) ); + remoteRepo = builder.build(); } request.setRepository( remoteRepo ); diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java index d68a65c24d..aa924e8b7a 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java @@ -36,12 +36,12 @@ import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.installation.InstallRequest; -import org.sonatype.aether.installation.InstallationException; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.artifact.SubArtifact; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.installation.InstallationException; +import org.eclipse.aether.util.artifact.SubArtifact; /** * @author Jason van Zyl @@ -77,9 +77,9 @@ public class DefaultArtifactInstaller InstallRequest request = new InstallRequest(); - request.setTrace( DefaultRequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); + request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); - org.sonatype.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); + org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); mainArtifact = mainArtifact.setFile( source ); request.addArtifact( mainArtifact ); @@ -87,7 +87,7 @@ public class DefaultArtifactInstaller { if ( metadata instanceof ProjectArtifactMetadata ) { - org.sonatype.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); + org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); request.addArtifact( pomArtifact ); } diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java index d24bf12bbd..658dbdac6e 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java @@ -28,7 +28,7 @@ import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; /** * @author jdcasey diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java index 8024d310b1..4ee80ec2b3 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java @@ -20,13 +20,17 @@ package org.apache.maven.artifact.repository.metadata; */ import java.io.File; +import java.util.Collections; +import java.util.Map; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.codehaus.plexus.util.FileUtils; -import org.sonatype.aether.RepositoryException; -import org.sonatype.aether.metadata.MergeableMetadata; +import org.eclipse.aether.RepositoryException; +import org.eclipse.aether.metadata.AbstractMetadata; +import org.eclipse.aether.metadata.MergeableMetadata; +import org.eclipse.aether.metadata.Metadata; /** * Warning: This is an internal utility class that is only public for technical reasons, it is not part @@ -35,6 +39,7 @@ import org.sonatype.aether.metadata.MergeableMetadata; * @author Benjamin Bentmann */ public final class MetadataBridge + extends AbstractMetadata implements MergeableMetadata { @@ -126,6 +131,17 @@ public final class MetadataBridge } } + public Map getProperties() + { + return Collections.emptyMap(); + } + + @Override + public Metadata setProperties( Map properties ) + { + return this; + } + @SuppressWarnings( "deprecation" ) static class MetadataRepository extends DefaultArtifactRepository diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java index d9ab00fc2d..9a9b31afce 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -60,11 +60,11 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.LocalRepositoryManager; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResult; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.LocalRepositoryManager; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResult; /** * @author Jason van Zyl @@ -220,9 +220,9 @@ public class DefaultArtifactResolver result = repoSystem.resolveArtifact( session, artifactRequest ); } - catch ( org.sonatype.aether.resolution.ArtifactResolutionException e ) + catch ( org.eclipse.aether.resolution.ArtifactResolutionException e ) { - if ( e.getCause() instanceof org.sonatype.aether.transfer.ArtifactNotFoundException ) + if ( e.getCause() instanceof org.eclipse.aether.transfer.ArtifactNotFoundException ) { throw new ArtifactNotFoundException( e.getMessage(), artifact, remoteRepositories, e ); } diff --git a/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java b/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java index 75d1db038f..b70d3cffd5 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java +++ b/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java @@ -32,7 +32,7 @@ import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; // This class needs to stick around because it was exposed the the remote resources plugin started using it instead of // getting the repositories from the project. diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java index 93b16017b4..6dd84dbc27 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java @@ -73,10 +73,11 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.AuthenticationSelector; -import org.sonatype.aether.repository.ProxySelector; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.AuthenticationContext; +import org.eclipse.aether.repository.AuthenticationSelector; +import org.eclipse.aether.repository.ProxySelector; +import org.eclipse.aether.repository.RemoteRepository; /** * @author Jason van Zyl @@ -478,7 +479,7 @@ public class LegacyRepositorySystem { if ( session != null ) { - org.sonatype.aether.repository.MirrorSelector selector = session.getMirrorSelector(); + org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector(); if ( selector != null ) { RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) ); @@ -583,13 +584,18 @@ public class LegacyRepositorySystem AuthenticationSelector selector = session.getAuthenticationSelector(); if ( selector != null ) { - org.sonatype.aether.repository.Authentication auth = - selector.getAuthentication( RepositoryUtils.toRepo( repository ) ); + RemoteRepository repo = RepositoryUtils.toRepo( repository ); + org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo ); if ( auth != null ) { - Authentication result = new Authentication( auth.getUsername(), auth.getPassword() ); - result.setPrivateKey( auth.getPrivateKeyFile() ); - result.setPassphrase( auth.getPassphrase() ); + repo = new RemoteRepository.Builder( repo ).setAuthentication( auth ).build(); + AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo ); + Authentication result = + new Authentication( authCtx.get( AuthenticationContext.USERNAME ), + authCtx.get( AuthenticationContext.PASSWORD ) ); + result.setPrivateKey( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) ); + result.setPassphrase( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) ); + authCtx.close(); return result; } } @@ -688,7 +694,8 @@ public class LegacyRepositorySystem ProxySelector selector = session.getProxySelector(); if ( selector != null ) { - org.sonatype.aether.repository.Proxy proxy = selector.getProxy( RepositoryUtils.toRepo( repository ) ); + RemoteRepository repo = RepositoryUtils.toRepo( repository ); + org.eclipse.aether.repository.Proxy proxy = selector.getProxy( repo ); if ( proxy != null ) { Proxy p = new Proxy(); @@ -697,8 +704,13 @@ public class LegacyRepositorySystem p.setPort( proxy.getPort() ); if ( proxy.getAuthentication() != null ) { - p.setUserName( proxy.getAuthentication().getUsername() ); - p.setPassword( proxy.getAuthentication().getPassword() ); + repo = new RemoteRepository.Builder( repo ).setProxy( proxy ).build(); + AuthenticationContext authCtx = AuthenticationContext.forProxy( session, repo ); + p.setUserName( authCtx.get( AuthenticationContext.USERNAME ) ); + p.setPassword( authCtx.get( AuthenticationContext.PASSWORD ) ); + p.setNtlmDomain( authCtx.get( AuthenticationContext.NTLM_DOMAIN ) ); + p.setNtlmHost( authCtx.get( AuthenticationContext.NTLM_WORKSTATION ) ); + authCtx.close(); } return p; } diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java index 6645257e8d..3f96793a35 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java @@ -36,26 +36,30 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenSession; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.collection.DependencyGraphTransformer; -import org.sonatype.aether.collection.DependencyManager; -import org.sonatype.aether.collection.DependencySelector; -import org.sonatype.aether.collection.DependencyTraverser; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.graph.manager.ClassicDependencyManager; -import org.sonatype.aether.util.graph.selector.AndDependencySelector; -import org.sonatype.aether.util.graph.selector.ExclusionDependencySelector; -import org.sonatype.aether.util.graph.selector.OptionalDependencySelector; -import org.sonatype.aether.util.graph.selector.ScopeDependencySelector; -import org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer; -import org.sonatype.aether.util.graph.transformer.NearestVersionConflictResolver; -import org.sonatype.aether.util.graph.transformer.ConflictMarker; -import org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner; -import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator; -import org.sonatype.aether.util.graph.traverser.FatArtifactTraverser; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.collection.DependencyGraphTransformer; +import org.eclipse.aether.collection.DependencyManager; +import org.eclipse.aether.collection.DependencySelector; +import org.eclipse.aether.collection.DependencyTraverser; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.util.graph.manager.ClassicDependencyManager; +import org.eclipse.aether.util.graph.selector.AndDependencySelector; +import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; +import org.eclipse.aether.util.graph.selector.OptionalDependencySelector; +import org.eclipse.aether.util.graph.selector.ScopeDependencySelector; +import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; +import org.eclipse.aether.util.graph.transformer.ConflictResolver; +import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver; +import org.eclipse.aether.util.graph.transformer.JavaScopeSelector; +import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; +import org.eclipse.aether.util.graph.transformer.NearestVersionSelector; +import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector; +import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; +import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; /** * @author Jason van Zyl @@ -66,7 +70,14 @@ public abstract class AbstractArtifactComponentTestCase protected ArtifactFactory artifactFactory; protected ArtifactRepositoryFactory artifactRepositoryFactory; - + + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + } + @Override protected void setUp() throws Exception @@ -331,8 +342,7 @@ public abstract class AbstractArtifactComponentTestCase throws Exception { DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); - session.setIgnoreMissingArtifactDescriptor( true ); - session.setIgnoreInvalidArtifactDescriptor( true ); + session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); DependencyTraverser depTraverser = new FatArtifactTraverser(); session.setDependencyTraverser( depTraverser ); @@ -345,12 +355,13 @@ public abstract class AbstractArtifactComponentTestCase session.setDependencySelector( depFilter ); DependencyGraphTransformer transformer = - new ChainedDependencyGraphTransformer( new ConflictMarker(), new JavaEffectiveScopeCalculator(), - new NearestVersionConflictResolver(), - new JavaDependencyContextRefiner() ); + new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), + new SimpleOptionalitySelector(), new JavaScopeDeriver() ); + new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() ); session.setDependencyGraphTransformer( transformer ); - session.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepository().getBasedir() ) ); + LocalRepository localRepo = new LocalRepository( localRepository().getBasedir() ); + session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); return session; } diff --git a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java index 18ca204bc1..f897dbf7f9 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java @@ -27,8 +27,10 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; +import org.eclipse.aether.DefaultRepositorySystemSession; /** * @author Jason van Zyl @@ -39,7 +41,14 @@ public abstract class AbstractMavenProjectTestCase protected ProjectBuilder projectBuilder; protected RepositorySystem repositorySystem; - + + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + } + protected void setUp() throws Exception { @@ -166,7 +175,7 @@ public abstract class AbstractMavenProjectTestCase protected void initRepoSession( ProjectBuildingRequest request ) { File localRepo = new File( request.getLocalRepository().getBasedir() ); - MavenRepositorySystemSession session = new MavenRepositorySystemSession( true ); + DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); session.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); request.setRepositorySession( session ); } diff --git a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java index 84d8be274d..36eaee8f25 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java @@ -26,13 +26,13 @@ import java.util.Collections; import java.util.List; import org.codehaus.plexus.component.annotations.Component; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.ArtifactResolver; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResolutionException; -import org.sonatype.aether.resolution.ArtifactResult; -import org.sonatype.aether.transfer.ArtifactNotFoundException; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.impl.ArtifactResolver; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.transfer.ArtifactNotFoundException; /** * @author Benjamin Bentmann diff --git a/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java b/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java index daab6c4f8e..52fdd80478 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java +++ b/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java @@ -21,22 +21,36 @@ package org.apache.maven.project; import java.io.File; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.repository.LocalArtifactRequest; -import org.sonatype.aether.repository.LocalArtifactResult; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.repository.LocalArtifactRegistration; +import org.eclipse.aether.repository.LocalArtifactRequest; +import org.eclipse.aether.repository.LocalArtifactResult; +import org.eclipse.aether.repository.LocalMetadataRegistration; +import org.eclipse.aether.repository.LocalMetadataRequest; +import org.eclipse.aether.repository.LocalMetadataResult; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.LocalRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; /** * @author Benjamin Bentmann */ public class LegacyLocalRepositoryManager - extends SimpleLocalRepositoryManager + implements LocalRepositoryManager { + private final LocalRepository repository; + public LegacyLocalRepositoryManager( File basedir ) { - super( basedir ); + this.repository = new LocalRepository( basedir.getAbsoluteFile(), "legacy" ); + } + + public LocalRepository getRepository() + { + return repository; } public String getPathForLocalArtifact( Artifact artifact ) @@ -59,17 +73,120 @@ public class LegacyLocalRepositoryManager return path.toString(); } + public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) + { + return getPathForLocalArtifact( artifact ); + } + + public String getPathForLocalMetadata( Metadata metadata ) + { + return getPath( metadata, "local" ); + } + + public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) + { + return getPath( metadata, getRepositoryKey( repository, context ) ); + } + + String getRepositoryKey( RemoteRepository repository, String context ) + { + return repository.getId(); + } + + private String getPath( Metadata metadata, String repositoryKey ) + { + StringBuilder path = new StringBuilder( 128 ); + + if ( metadata.getGroupId().length() > 0 ) + { + path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); + + if ( metadata.getArtifactId().length() > 0 ) + { + path.append( metadata.getArtifactId() ).append( '/' ); + + if ( metadata.getVersion().length() > 0 ) + { + path.append( metadata.getVersion() ).append( '/' ); + } + } + } + + path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) ); + + return path.toString(); + } + + private String insertRepositoryKey( String filename, String repositoryKey ) + { + String result; + int idx = filename.indexOf( '.' ); + if ( idx < 0 ) + { + result = filename + '-' + repositoryKey; + } + else + { + result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); + } + return result; + } + public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) { - String path = getPathForLocalArtifact( request.getArtifact() ); - File file = new File( getRepository().getBasedir(), path ); - LocalArtifactResult result = new LocalArtifactResult( request ); - if ( file.isFile() ) - { - result.setFile( file ); - result.setAvailable( true ); - } - return result; - } + String path = getPathForLocalArtifact( request.getArtifact() ); + File file = new File( getRepository().getBasedir(), path ); + LocalArtifactResult result = new LocalArtifactResult( request ); + if ( file.isFile() ) + { + result.setFile( file ); + result.setAvailable( true ); + } + + return result; + } + + public void add( RepositorySystemSession session, LocalArtifactRegistration request ) + { + // noop + } + + public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) + { + LocalMetadataResult result = new LocalMetadataResult( request ); + + String path; + + Metadata metadata = request.getMetadata(); + String context = request.getContext(); + RemoteRepository remote = request.getRepository(); + + if ( remote != null ) + { + path = getPathForRemoteMetadata( metadata, remote, context ); + } + else + { + path = getPathForLocalMetadata( metadata ); + } + + File file = new File( getRepository().getBasedir(), path ); + if ( file.isFile() ) + { + result.setFile( file ); + } + + return result; + } + + public void add( RepositorySystemSession session, LocalMetadataRegistration request ) + { + // noop + } + + public String toString() + { + return String.valueOf( getRepository() ); + } } diff --git a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java index b84733c1d6..01a128b5ae 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java @@ -25,8 +25,8 @@ import java.util.Iterator; import org.apache.maven.artifact.Artifact; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader; -import org.sonatype.aether.impl.ArtifactDescriptorReader; -import org.sonatype.aether.impl.ArtifactResolver; +import org.eclipse.aether.impl.ArtifactDescriptorReader; +import org.eclipse.aether.impl.ArtifactResolver; public class ProjectClasspathTest extends AbstractMavenProjectTestCase diff --git a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java index 64f359cecc..4c73c0f281 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java @@ -32,9 +32,11 @@ import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.util.DefaultRepositorySystemSession; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; /** * Tests {@link LegacyRepositorySystem}. @@ -47,7 +49,14 @@ public class LegacyRepositorySystemTest private RepositorySystem repositorySystem; private ResolutionErrorHandler resolutionErrorHandler; - + + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + } + @Override protected void setUp() throws Exception @@ -114,7 +123,8 @@ public class LegacyRepositorySystemTest .setLocalRepository( getLocalRepository() ); DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); - session.setLocalRepositoryManager( new SimpleLocalRepositoryManager( request.getLocalRepository().getBasedir() ) ); + LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() ); + session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); LegacySupport legacySupport = lookup( LegacySupport.class ); legacySupport.setSession( new MavenSession( getContainer(), session, new DefaultMavenExecutionRequest(), new DefaultMavenExecutionResult() ) ); diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java index a56b5462a6..98340be753 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java @@ -22,6 +22,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Server; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; /** @@ -34,6 +35,13 @@ public class LegacyRepositorySystemTest { private RepositorySystem repositorySystem; + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + } + @Override protected void setUp() throws Exception diff --git a/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xml b/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xml index 2666d8dcca..2b950859de 100644 --- a/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xml +++ b/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xml @@ -61,7 +61,7 @@ under the License. legacySupport - org.sonatype.aether.RepositorySystem + org.eclipse.aether.RepositorySystem default repoSystem diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 7dbde4a8f4..ff5f3e7658 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -59,15 +59,15 @@ maven-aether-provider - org.sonatype.aether + org.eclipse.aether aether-impl - org.sonatype.aether + org.eclipse.aether aether-api - org.sonatype.aether + org.eclipse.aether aether-util diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 98dc5c1805..070b7f71df 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -62,7 +62,6 @@ import org.apache.maven.project.ProjectBuildingResult; import org.apache.maven.project.ProjectSorter; import org.apache.maven.repository.DelegatingLocalArtifactRepository; import org.apache.maven.repository.LocalRepositoryNotAccessibleException; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; @@ -80,20 +79,40 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.dag.CycleDetectedException; import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.sonatype.aether.ConfigurationProperties; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.Authentication; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.NoLocalRepositoryManagerException; -import org.sonatype.aether.repository.RepositoryPolicy; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory; -import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.repository.ChainedWorkspaceReader; -import org.sonatype.aether.util.repository.DefaultAuthenticationSelector; -import org.sonatype.aether.util.repository.DefaultMirrorSelector; -import org.sonatype.aether.util.repository.DefaultProxySelector; +import org.eclipse.aether.ConfigurationProperties; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.collection.DependencyGraphTransformer; +import org.eclipse.aether.collection.DependencyManager; +import org.eclipse.aether.collection.DependencySelector; +import org.eclipse.aether.collection.DependencyTraverser; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.NoLocalRepositoryManagerException; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.resolution.ResolutionErrorPolicy; +import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; +import org.eclipse.aether.util.graph.manager.ClassicDependencyManager; +import org.eclipse.aether.util.graph.selector.AndDependencySelector; +import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; +import org.eclipse.aether.util.graph.selector.OptionalDependencySelector; +import org.eclipse.aether.util.graph.selector.ScopeDependencySelector; +import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; +import org.eclipse.aether.util.graph.transformer.ConflictResolver; +import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver; +import org.eclipse.aether.util.graph.transformer.JavaScopeSelector; +import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; +import org.eclipse.aether.util.graph.transformer.NearestVersionSelector; +import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector; +import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; +import org.eclipse.aether.util.repository.AuthenticationBuilder; +import org.eclipse.aether.util.repository.ChainedWorkspaceReader; +import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; +import org.eclipse.aether.util.repository.DefaultMirrorSelector; +import org.eclipse.aether.util.repository.DefaultProxySelector; +import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; +import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy; /** * @author Jason van Zyl @@ -259,6 +278,8 @@ public class DefaultMaven return processResult( result, e ); } + repoSession.setReadOnly(); + ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { @@ -326,10 +347,12 @@ public class DefaultMaven public RepositorySystemSession newRepositorySession( MavenExecutionRequest request ) { - MavenRepositorySystemSession session = new MavenRepositorySystemSession( false ); + DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); session.setCache( request.getRepositoryCache() ); + session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); + Map configProps = new LinkedHashMap(); configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() ); configProps.put( ConfigurationProperties.INTERACTIVE, Boolean.valueOf( request.isInteractiveMode() ) ); @@ -351,8 +374,11 @@ public class DefaultMaven session.setUpdatePolicy( null ); } - session.setNotFoundCachingEnabled( request.isCacheNotFound() ); - session.setTransferErrorCachingEnabled( request.isCacheTransferError() ); + int errorPolicy = 0; + errorPolicy |= request.isCacheNotFound() ? ResolutionErrorPolicy.CACHE_NOT_FOUND : 0; + errorPolicy |= request.isCacheTransferError() ? ResolutionErrorPolicy.CACHE_TRANSFER_ERROR : 0; + session.setResolutionErrorPolicy( new SimpleResolutionErrorPolicy( errorPolicy, errorPolicy + | ResolutionErrorPolicy.CACHE_NOT_FOUND ) ); session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) ); @@ -363,18 +389,18 @@ public class DefaultMaven logger.warn( "Disabling enhanced local repository: using legacy is stronlgy discouraged to ensure build reproducibility." ); try { - session.setLocalRepositoryManager( simpleLocalRepositoryManagerFactory.newInstance( localRepo ) ); + session.setLocalRepositoryManager( simpleLocalRepositoryManagerFactory.newInstance( session, localRepo ) ); } catch ( NoLocalRepositoryManagerException e ) { logger.warn( "Failed to configure legacy local repository: back to default" ); - session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) ); + session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) ); } } else { - session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) ); + session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) ); } if ( request.getWorkspaceReader() != null ) @@ -410,19 +436,21 @@ public class DefaultMaven DefaultProxySelector proxySelector = new DefaultProxySelector(); for ( Proxy proxy : decrypted.getProxies() ) { - Authentication proxyAuth = new Authentication( proxy.getUsername(), proxy.getPassword() ); - proxySelector.add( new org.sonatype.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), - proxyAuth ), proxy.getNonProxyHosts() ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.addUsername( proxy.getUsername() ).addPassword( proxy.getPassword() ); + proxySelector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), + proxy.getPort(), authBuilder.build() ), + proxy.getNonProxyHosts() ); } session.setProxySelector( proxySelector ); DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector(); for ( Server server : decrypted.getServers() ) { - Authentication auth = - new Authentication( server.getUsername(), server.getPassword(), server.getPrivateKey(), - server.getPassphrase() ); - authSelector.add( server.getId(), auth ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.addUsername( server.getUsername() ).addPassword( server.getPassword() ); + authBuilder.addPrivateKey( server.getPrivateKey(), server.getPassphrase() ); + authSelector.add( server.getId(), authBuilder.build() ); if ( server.getConfiguration() != null ) { @@ -445,13 +473,30 @@ public class DefaultMaven } session.setAuthenticationSelector( authSelector ); + DependencyTraverser depTraverser = new FatArtifactTraverser(); + session.setDependencyTraverser( depTraverser ); + + DependencyManager depManager = new ClassicDependencyManager(); + session.setDependencyManager( depManager ); + + DependencySelector depFilter = + new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), new OptionalDependencySelector(), + new ExclusionDependencySelector() ); + session.setDependencySelector( depFilter ); + + DependencyGraphTransformer transformer = + new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), + new SimpleOptionalitySelector(), new JavaScopeDeriver() ); + transformer = new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() ); + session.setDependencyGraphTransformer( transformer ); + session.setTransferListener( request.getTransferListener() ); session.setRepositoryListener( eventSpyDispatcher.chainListener( new LoggingRepositoryListener( logger ) ) ); - session.setUserProps( request.getUserProperties() ); - session.setSystemProps( request.getSystemProperties() ); - session.setConfigProps( configProps ); + session.setUserProperties( request.getUserProperties() ); + session.setSystemProperties( request.getSystemProperties() ); + session.setConfigProperties( configProps ); return session; } diff --git a/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java b/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java index 8e46525fcb..d176b9d74d 100644 --- a/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java +++ b/maven-core/src/main/java/org/apache/maven/LoggingRepositoryListener.java @@ -22,9 +22,9 @@ package org.apache.maven; import java.io.FileNotFoundException; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.AbstractRepositoryListener; -import org.sonatype.aether.RepositoryEvent; -import org.sonatype.aether.transfer.MetadataNotFoundException; +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.transfer.MetadataNotFoundException; /** * @author Benjamin Bentmann diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java index 4e1a638f47..be1efb3399 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -21,9 +21,9 @@ package org.apache.maven; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.project.MavenProject; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.repository.WorkspaceRepository; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.repository.WorkspaceRepository; import java.io.File; import java.util.ArrayList; @@ -43,9 +43,9 @@ import java.util.Map; class ReactorReader implements WorkspaceReader { - private static final Collection JAR_LIKE_TYPES = Arrays.asList( "jar", "test-jar", "ejb-client" ); + private final static Collection JAR_LIKE_TYPES = Arrays.asList( "jar", "test-jar", "ejb-client" ); - private static final Collection COMPILE_PHASE_TYPES = Arrays.asList( "jar", "ejb-client" ); + private final static Collection COMPILE_PHASE_TYPES = Arrays.asList( "jar", "ejb-client" ); private Map projectsByGAV; @@ -103,7 +103,7 @@ class ReactorReader } else { - String type = artifact.getProperty( "type", "" ); + String type = artifact.getProperty( "type", ""); if ( project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type ) ) { return new File( project.getBuild().getOutputDirectory() ); diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java index f5e36c0f22..9b68a2e62e 100644 --- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java +++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java @@ -30,20 +30,21 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.artifact.ArtifactType; -import org.sonatype.aether.artifact.ArtifactTypeRegistry; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.graph.Exclusion; -import org.sonatype.aether.repository.Authentication; -import org.sonatype.aether.repository.Proxy; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.RepositoryPolicy; -import org.sonatype.aether.util.artifact.ArtifactProperties; -import org.sonatype.aether.util.artifact.DefaultArtifact; -import org.sonatype.aether.util.artifact.DefaultArtifactType; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactProperties; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.artifact.DefaultArtifactType; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.graph.Exclusion; +import org.eclipse.aether.repository.Authentication; +import org.eclipse.aether.repository.Proxy; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.util.repository.AuthenticationBuilder; /** * Warning: This is an internal utility class that is only public for technical reasons, it is not part @@ -197,12 +198,14 @@ public class RepositoryUtils RemoteRepository result = null; if ( repo != null ) { - result = new RemoteRepository( repo.getId(), getLayout( repo ), repo.getUrl() ); - result.setPolicy( true, toPolicy( repo.getSnapshots() ) ); - result.setPolicy( false, toPolicy( repo.getReleases() ) ); - result.setAuthentication( toAuthentication( repo.getAuthentication() ) ); - result.setProxy( toProxy( repo.getProxy() ) ); - result.setMirroredRepositories( toRepos( repo.getMirroredRepositories() ) ); + RemoteRepository.Builder builder = + new RemoteRepository.Builder( repo.getId(), getLayout( repo ), repo.getUrl() ); + builder.setSnapshotPolicy( toPolicy( repo.getSnapshots() ) ); + builder.setReleasePolicy( toPolicy( repo.getReleases() ) ); + builder.setAuthentication( toAuthentication( repo.getAuthentication() ) ); + builder.setProxy( toProxy( repo.getProxy() ) ); + builder.setMirroredRepositories( toRepos( repo.getMirroredRepositories() ) ); + result = builder.build(); } return result; } @@ -247,8 +250,10 @@ public class RepositoryUtils Authentication result = null; if ( auth != null ) { - result = - new Authentication( auth.getUsername(), auth.getPassword(), auth.getPrivateKey(), auth.getPassphrase() ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.addUsername( auth.getUsername() ).addPassword( auth.getPassword() ); + authBuilder.addPrivateKey( auth.getPrivateKey(), auth.getPassphrase() ); + result = authBuilder.build(); } return result; } @@ -258,8 +263,9 @@ public class RepositoryUtils Proxy result = null; if ( proxy != null ) { - Authentication auth = new Authentication( proxy.getUserName(), proxy.getPassword() ); - result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth ); + AuthenticationBuilder authBuilder = new AuthenticationBuilder(); + authBuilder.addUsername( proxy.getUserName() ).addPassword( proxy.getPassword() ); + result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authBuilder.build() ); } return result; } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java index d77f593547..159d3e3f33 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java @@ -29,21 +29,20 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException; import org.apache.maven.repository.Proxy; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.metadata.Metadata; -import org.sonatype.aether.repository.LocalArtifactRegistration; -import org.sonatype.aether.repository.LocalArtifactRequest; -import org.sonatype.aether.repository.LocalArtifactResult; -import org.sonatype.aether.repository.LocalMetadataRegistration; -import org.sonatype.aether.repository.LocalMetadataRequest; -import org.sonatype.aether.repository.LocalMetadataResult; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.LocalRepositoryManager; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.FilterRepositorySystemSession; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.repository.LocalArtifactRegistration; +import org.eclipse.aether.repository.LocalArtifactRequest; +import org.eclipse.aether.repository.LocalArtifactResult; +import org.eclipse.aether.repository.LocalMetadataRegistration; +import org.eclipse.aether.repository.LocalMetadataRequest; +import org.eclipse.aether.repository.LocalMetadataResult; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.LocalRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; /** * Warning: This is an internal utility class that is only public for technical reasons, it is not part @@ -84,14 +83,7 @@ public class LegacyLocalRepositoryManager final LocalRepositoryManager llrm = new LegacyLocalRepositoryManager( repository ); - return new FilterRepositorySystemSession( session ) - { - @Override - public LocalRepositoryManager getLocalRepositoryManager() - { - return llrm; - } - }; + return new DefaultRepositorySystemSession( session ).setLocalRepositoryManager( llrm ); } private LegacyLocalRepositoryManager( ArtifactRepository delegate ) diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/ArtifactClassRealmConstituent.java b/maven-core/src/main/java/org/apache/maven/classrealm/ArtifactClassRealmConstituent.java index e79fa9d20d..562d6f4748 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/ArtifactClassRealmConstituent.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/ArtifactClassRealmConstituent.java @@ -21,7 +21,7 @@ package org.apache.maven.classrealm; import java.io.File; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * @author Benjamin Bentmann diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java index fe43b52ef3..a09f1b092f 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java @@ -25,7 +25,7 @@ import java.util.Map; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * Manages the class realms used by Maven. Warning: This is an internal utility interface that is only diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java index 3cc027e3a3..1798875c00 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java @@ -45,7 +45,7 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * Manages the class realms used by Maven. Warning: This is an internal utility class that is only @@ -163,19 +163,19 @@ public class DefaultClassRealmManager imports.put( "org.apache.maven.wagon.resource", coreRealm ); // aether-api, aether-spi, aether-impl - imports.put( "org.sonatype.aether.*", coreRealm ); - imports.put( "org.sonatype.aether.artifact", coreRealm ); - imports.put( "org.sonatype.aether.collection", coreRealm ); - imports.put( "org.sonatype.aether.deployment", coreRealm ); - imports.put( "org.sonatype.aether.graph", coreRealm ); - imports.put( "org.sonatype.aether.impl", coreRealm ); - imports.put( "org.sonatype.aether.installation", coreRealm ); - imports.put( "org.sonatype.aether.metadata", coreRealm ); - imports.put( "org.sonatype.aether.repository", coreRealm ); - imports.put( "org.sonatype.aether.resolution", coreRealm ); - imports.put( "org.sonatype.aether.spi", coreRealm ); - imports.put( "org.sonatype.aether.transfer", coreRealm ); - imports.put( "org.sonatype.aether.version", coreRealm ); + imports.put( "org.eclipse.aether.*", coreRealm ); + imports.put( "org.eclipse.aether.artifact", coreRealm ); + imports.put( "org.eclipse.aether.collection", coreRealm ); + imports.put( "org.eclipse.aether.deployment", coreRealm ); + imports.put( "org.eclipse.aether.graph", coreRealm ); + imports.put( "org.eclipse.aether.impl", coreRealm ); + imports.put( "org.eclipse.aether.installation", coreRealm ); + imports.put( "org.eclipse.aether.metadata", coreRealm ); + imports.put( "org.eclipse.aether.repository", coreRealm ); + imports.put( "org.eclipse.aether.resolution", coreRealm ); + imports.put( "org.eclipse.aether.spi", coreRealm ); + imports.put( "org.eclipse.aether.transfer", coreRealm ); + imports.put( "org.eclipse.aether.version", coreRealm ); // plexus-classworlds imports.put( "org.codehaus.plexus.classworlds", coreRealm ); diff --git a/maven-core/src/main/java/org/apache/maven/eventspy/EventSpy.java b/maven-core/src/main/java/org/apache/maven/eventspy/EventSpy.java index eea83214d4..5555ee2cb5 100644 --- a/maven-core/src/main/java/org/apache/maven/eventspy/EventSpy.java +++ b/maven-core/src/main/java/org/apache/maven/eventspy/EventSpy.java @@ -62,7 +62,7 @@ public interface EventSpy * @see org.apache.maven.project.DependencyResolutionRequest * @see org.apache.maven.project.DependencyResolutionResultt * @see org.apache.maven.execution.ExecutionEvent - * @see org.sonatype.aether.RepositoryEvent + * @see org.eclipse.aether.RepositoryEvent */ void onEvent( Object event ) throws Exception; diff --git a/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java b/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java index e527336faa..2a16779535 100644 --- a/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java +++ b/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyDispatcher.java @@ -27,7 +27,7 @@ import org.apache.maven.execution.ExecutionListener; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.RepositoryListener; +import org.eclipse.aether.RepositoryListener; /** * Dispatches callbacks to all registered eventspies. diff --git a/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyRepositoryListener.java b/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyRepositoryListener.java index f7df6f80ee..1ebf759cb4 100644 --- a/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyRepositoryListener.java +++ b/maven-core/src/main/java/org/apache/maven/eventspy/internal/EventSpyRepositoryListener.java @@ -19,9 +19,9 @@ package org.apache.maven.eventspy.internal; * under the License. */ -import org.sonatype.aether.AbstractRepositoryListener; -import org.sonatype.aether.RepositoryEvent; -import org.sonatype.aether.RepositoryListener; +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RepositoryListener; /** * Forwards repository events to eventspies. diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java index bea605947e..ef769d9f46 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java @@ -32,10 +32,10 @@ import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; -import org.sonatype.aether.RepositoryCache; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.transfer.TransferListener; -import org.sonatype.aether.util.DefaultRepositoryCache; +import org.eclipse.aether.DefaultRepositoryCache; +import org.eclipse.aether.RepositoryCache; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.transfer.TransferListener; /** * @author Jason van Zyl diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java index 62b6662c3a..3db67953dd 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java @@ -32,9 +32,9 @@ import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.RepositoryCache; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.transfer.TransferListener; +import org.eclipse.aether.RepositoryCache; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.transfer.TransferListener; /** * @author Jason van Zyl diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index 30ff3332d9..214aed8261 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -36,7 +36,7 @@ import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; /** * @author Jason van Zyl diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java index 075283d3dc..a76461d523 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java @@ -44,11 +44,11 @@ import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.util.filter.AndDependencyFilter; -import org.sonatype.aether.util.filter.ScopeDependencyFilter; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.util.filter.AndDependencyFilter; +import org.eclipse.aether.util.filter.ScopeDependencyFilter; /** * Resolves dependencies for the artifacts in context of the lifecycle build @@ -238,7 +238,7 @@ public class LifecycleDependencyResolver for ( Dependency dependency : dependencies ) { - org.sonatype.aether.artifact.Artifact a = dependency.getArtifact(); + org.eclipse.aether.artifact.Artifact a = dependency.getArtifact(); String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() ); if ( !projectKeys.contains( key ) ) { @@ -320,7 +320,7 @@ public class LifecycleDependencyResolver Dependency dependency = node.getDependency(); if ( dependency != null ) { - org.sonatype.aether.artifact.Artifact a = dependency.getArtifact(); + org.eclipse.aether.artifact.Artifact a = dependency.getArtifact(); String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() ); return !keys.contains( key ); } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java index 5e93bcebde..6c1b9cbf4d 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java @@ -26,8 +26,8 @@ import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; /** * @author Jason van Zyl diff --git a/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java b/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java index ec8c4af77d..cbe1cb01d4 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java @@ -25,11 +25,11 @@ import java.util.List; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Plugin; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.RepositoryPolicy; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.repository.WorkspaceRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.repository.WorkspaceRepository; /** * @author Benjamin Bentmann diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java index fee2eb0eac..5caba5a2de 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java @@ -31,8 +31,8 @@ import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; // TODO: the antrun plugin has its own configurator, the only plugin that does. might need to think about how that works // TODO: remove the coreArtifactFilterManager diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java index 6348b738ee..bc10223162 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java @@ -29,7 +29,7 @@ import org.apache.maven.project.ExtensionDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * Default extension realm cache implementation. Assumes cached data does not change. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java index cc2d7bf545..145482d85a 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java @@ -28,12 +28,12 @@ import java.util.Map; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.WorkspaceRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.WorkspaceRepository; /** * @author Igor Fedorenko diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java index 8bb69095e9..4242a32260 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java @@ -30,10 +30,10 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.WorkspaceRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.WorkspaceRepository; /** * Caches raw plugin descriptors. A raw plugin descriptor is a descriptor that has just been extracted from the plugin diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java index c821ae90ad..e459cbcab4 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java @@ -32,11 +32,11 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.WorkspaceRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.WorkspaceRepository; /** * Default PluginCache implementation. Assumes cached data does not change. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java index 6a0da57cf6..cf5db3e4f1 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java @@ -24,7 +24,7 @@ import java.util.List; import org.apache.maven.project.ExtensionDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.sonatype.aether.artifact.Artifact; +import org.eclipse.aether.artifact.Artifact; /** * Caches extension class realms. Warning: This is an internal utility interface that is only public diff --git a/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java b/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java index cdbc83db95..eef9b4f3ea 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java @@ -20,7 +20,7 @@ package org.apache.maven.plugin; */ import org.apache.maven.execution.MavenSession; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; /** * Helps to provide backward-compatibility with plugins that use legacy components. Warning: This is an diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java index 18ca9c9ab0..e62cb9b534 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java @@ -25,9 +25,9 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.repository.RemoteRepository; /** * Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java index 37d9aeee80..df07d4cd93 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java @@ -23,10 +23,10 @@ import java.util.List; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.repository.RemoteRepository; /** * Caches plugin artifacts. Warning: This is an internal utility interface that is only public for diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java index 6b9bf750b3..4b4f368905 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java @@ -23,8 +23,8 @@ import java.util.List; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; /** * Caches raw plugin descriptors. A raw plugin descriptor is a descriptor that has just been extracted from the plugin diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java index 684208186e..7c04ed5bb6 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java @@ -26,9 +26,9 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.repository.RemoteRepository; /** * Caches plugin class realms. Warning: This is an internal utility interface that is only public for diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java index a71a0007a5..59047eb1ee 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java @@ -23,8 +23,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.codehaus.plexus.component.annotations.Component; - -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; /** * Helps to provide backward-compatibility with plugins that use legacy components. Warning: This is an diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 4429f44771..8f22abe20a 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -88,12 +88,12 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.util.filter.AndDependencyFilter; -import org.sonatype.aether.util.graph.PreorderNodeListGenerator; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.filter.AndDependencyFilter; +import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator; /** * Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such @@ -143,7 +143,7 @@ public class DefaultMavenPluginManager if ( pluginDescriptor == null ) { - org.sonatype.aether.artifact.Artifact artifact = + org.eclipse.aether.artifact.Artifact artifact = pluginDependenciesResolver.resolve( plugin, repositories, session ); Artifact pluginArtifact = RepositoryUtils.toArtifact( artifact ); @@ -373,7 +373,7 @@ public class DefaultMavenPluginManager } } - List pluginArtifacts = nlg.getArtifacts( true ); + List pluginArtifacts = nlg.getArtifacts( true ); ClassRealm pluginRealm = classRealmManager.createPluginRealm( plugin, parent, null, foreignImports, pluginArtifacts ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java index bfc6fae060..8153aed8e7 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java @@ -31,35 +31,34 @@ import org.apache.maven.plugin.PluginResolutionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.collection.CollectRequest; -import org.sonatype.aether.collection.DependencyCollectionException; -import org.sonatype.aether.collection.DependencyGraphTransformer; -import org.sonatype.aether.collection.DependencySelector; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.graph.DependencyVisitor; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.resolution.ArtifactDescriptorException; -import org.sonatype.aether.resolution.ArtifactDescriptorRequest; -import org.sonatype.aether.resolution.ArtifactDescriptorResult; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResolutionException; -import org.sonatype.aether.resolution.DependencyRequest; -import org.sonatype.aether.resolution.DependencyResolutionException; -import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.FilterRepositorySystemSession; -import org.sonatype.aether.util.artifact.DefaultArtifact; -import org.sonatype.aether.util.artifact.JavaScopes; -import org.sonatype.aether.util.filter.AndDependencyFilter; -import org.sonatype.aether.util.filter.ExclusionsDependencyFilter; -import org.sonatype.aether.util.filter.ScopeDependencyFilter; -import org.sonatype.aether.util.graph.selector.AndDependencySelector; -import org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.collection.DependencyCollectionException; +import org.eclipse.aether.collection.DependencyGraphTransformer; +import org.eclipse.aether.collection.DependencySelector; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.graph.DependencyVisitor; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.ArtifactDescriptorException; +import org.eclipse.aether.resolution.ArtifactDescriptorRequest; +import org.eclipse.aether.resolution.ArtifactDescriptorResult; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.DependencyRequest; +import org.eclipse.aether.resolution.DependencyResolutionException; +import org.eclipse.aether.util.artifact.JavaScopes; +import org.eclipse.aether.util.filter.AndDependencyFilter; +import org.eclipse.aether.util.filter.ExclusionsDependencyFilter; +import org.eclipse.aether.util.filter.ScopeDependencyFilter; +import org.eclipse.aether.util.graph.selector.AndDependencySelector; +import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; +import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; /** * Assists in resolving the dependencies of a plugin. Warning: This is an internal utility class that @@ -94,20 +93,14 @@ public class DefaultPluginDependenciesResolver public Artifact resolve( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginResolutionException { - RequestTrace trace = DefaultRequestTrace.newChild( null, plugin ); + RequestTrace trace = RequestTrace.newChild( null, plugin ); Artifact pluginArtifact = toArtifact( plugin, session ); try { - RepositorySystemSession pluginSession = new FilterRepositorySystemSession( session ) - { - @Override - public boolean isIgnoreMissingArtifactDescriptor() - { - return false; - } - }; + DefaultRepositorySystemSession pluginSession = new DefaultRepositorySystemSession( session ); + pluginSession.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, false ) ); ArtifactDescriptorRequest request = new ArtifactDescriptorRequest( pluginArtifact, repositories, REPOSITORY_CONTEXT ); @@ -147,7 +140,7 @@ public class DefaultPluginDependenciesResolver List repositories, RepositorySystemSession session ) throws PluginResolutionException { - RequestTrace trace = DefaultRequestTrace.newChild( null, plugin ); + RequestTrace trace = RequestTrace.newChild( null, plugin ); if ( pluginArtifact == null ) { @@ -179,10 +172,10 @@ public class DefaultPluginDependenciesResolver CollectRequest request = new CollectRequest(); request.setRequestContext( REPOSITORY_CONTEXT ); request.setRepositories( repositories ); - request.setRoot( new org.sonatype.aether.graph.Dependency( pluginArtifact, null ) ); + request.setRoot( new org.eclipse.aether.graph.Dependency( pluginArtifact, null ) ); for ( Dependency dependency : plugin.getDependencies() ) { - org.sonatype.aether.graph.Dependency pluginDep = + org.eclipse.aether.graph.Dependency pluginDep = RepositoryUtils.toDependency( dependency, session.getArtifactTypeRegistry() ); if ( !JavaScopes.SYSTEM.equals( pluginDep.getScope() ) ) { @@ -194,7 +187,7 @@ public class DefaultPluginDependenciesResolver DependencyRequest depRequest = new DependencyRequest( request, resolutionFilter ); depRequest.setTrace( trace ); - request.setTrace( DefaultRequestTrace.newChild( trace, depRequest ) ); + request.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( pluginSession, request ).getRoot(); @@ -228,23 +221,13 @@ public class DefaultPluginDependenciesResolver { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( indent ); - org.sonatype.aether.graph.Dependency dep = node.getDependency(); + org.eclipse.aether.graph.Dependency dep = node.getDependency(); if ( dep != null ) { - org.sonatype.aether.artifact.Artifact art = dep.getArtifact(); + org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); buffer.append( art ); buffer.append( ':' ).append( dep.getScope() ); - - if ( node.getPremanagedScope() != null && !node.getPremanagedScope().equals( dep.getScope() ) ) - { - buffer.append( " (scope managed from " ).append( node.getPremanagedScope() ).append( ")" ); - } - - if ( node.getPremanagedVersion() != null && !node.getPremanagedVersion().equals( art.getVersion() ) ) - { - buffer.append( " (version managed from " ).append( node.getPremanagedVersion() ).append( ")" ); - } } logger.debug( buffer.toString() ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/PlexusUtilsInjector.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/PlexusUtilsInjector.java index d191a234ac..2112748027 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/PlexusUtilsInjector.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/PlexusUtilsInjector.java @@ -19,15 +19,15 @@ package org.apache.maven.plugin.internal; * under the License. */ -import org.sonatype.aether.RepositoryException; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.collection.DependencyGraphTransformationContext; -import org.sonatype.aether.collection.DependencyGraphTransformer; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.util.artifact.DefaultArtifact; -import org.sonatype.aether.util.artifact.JavaScopes; -import org.sonatype.aether.util.graph.DefaultDependencyNode; +import org.eclipse.aether.RepositoryException; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.collection.DependencyGraphTransformationContext; +import org.eclipse.aether.collection.DependencyGraphTransformer; +import org.eclipse.aether.graph.DefaultDependencyNode; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.util.artifact.JavaScopes; /** * Injects plexus-utils:1.1 into a plugin's class path if it doesn't already declare a dependency on plexus-utils. This diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java index 60d83141a1..632d1d5918 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java @@ -23,11 +23,11 @@ import java.util.List; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.PluginResolutionException; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.repository.RemoteRepository; /** * Assists in resolving the dependencies of a plugin. Warning: This is an internal utility interface diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/WagonExcluder.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/WagonExcluder.java index 56b1c4f519..f0e2107fab 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/WagonExcluder.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/WagonExcluder.java @@ -19,10 +19,10 @@ package org.apache.maven.plugin.internal; * under the License. */ -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.collection.DependencyCollectionContext; -import org.sonatype.aether.collection.DependencySelector; -import org.sonatype.aether.graph.Dependency; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.collection.DependencyCollectionContext; +import org.eclipse.aether.collection.DependencySelector; +import org.eclipse.aether.graph.Dependency; /** * Assists in detecting wagon providers brought into the plugin class path via legacy Maven core artifacts (e.g. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java index 15a514a0c0..27c5f5b9ed 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java @@ -25,8 +25,8 @@ import java.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve a plugin prefix. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/NoPluginFoundForPrefixException.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/NoPluginFoundForPrefixException.java index 7b868d8c5b..3287021797 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/NoPluginFoundForPrefixException.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/NoPluginFoundForPrefixException.java @@ -21,8 +21,8 @@ package org.apache.maven.plugin.prefix; import java.util.List; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; public class NoPluginFoundForPrefixException extends Exception diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixRequest.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixRequest.java index 14c83cfcdd..c23368ec72 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixRequest.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixRequest.java @@ -22,8 +22,8 @@ package org.apache.maven.plugin.prefix; import java.util.List; import org.apache.maven.model.Model; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve a plugin prefix. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java index 0e67f37bea..6fe1f728b9 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java @@ -19,7 +19,7 @@ package org.apache.maven.plugin.prefix; * under the License. */ -import org.sonatype.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin prefix resolution request. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResolver.java index a9761aacd1..76814fd79c 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResolver.java @@ -38,20 +38,19 @@ import org.apache.maven.plugin.prefix.PluginPrefixResult; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.RepositoryEvent.EventType; -import org.sonatype.aether.RepositoryListener; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.repository.ArtifactRepository; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.RepositoryPolicy; -import org.sonatype.aether.resolution.MetadataRequest; -import org.sonatype.aether.resolution.MetadataResult; -import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.listener.DefaultRepositoryEvent; -import org.sonatype.aether.util.metadata.DefaultMetadata; +import org.eclipse.aether.RepositoryEvent.EventType; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RepositoryListener; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.metadata.DefaultMetadata; +import org.eclipse.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.resolution.MetadataRequest; +import org.eclipse.aether.resolution.MetadataResult; /** * Resolves a plugin prefix. @@ -163,13 +162,13 @@ public class DefaultPluginPrefixResolver private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request ) { - RequestTrace trace = DefaultRequestTrace.newChild( null, request ); + RequestTrace trace = RequestTrace.newChild( null, request ); List requests = new ArrayList(); for ( String pluginGroup : request.getPluginGroups() ) { - org.sonatype.aether.metadata.Metadata metadata = + org.eclipse.aether.metadata.Metadata metadata = new DefaultMetadata( pluginGroup, "maven-metadata.xml", DefaultMetadata.Nature.RELEASE_OR_SNAPSHOT ); requests.add( new MetadataRequest( metadata, null, REPOSITORY_CONTEXT ).setTrace( trace ) ); @@ -213,7 +212,7 @@ public class DefaultPluginPrefixResolver { for ( MetadataResult res : results ) { - org.sonatype.aether.metadata.Metadata metadata = res.getMetadata(); + org.eclipse.aether.metadata.Metadata metadata = res.getMetadata(); if ( metadata != null ) { @@ -243,7 +242,7 @@ public class DefaultPluginPrefixResolver private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request, RequestTrace trace, String pluginGroup, - org.sonatype.aether.metadata.Metadata metadata, + org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository ) { if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() ) @@ -277,17 +276,18 @@ public class DefaultPluginPrefixResolver } private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, - org.sonatype.aether.metadata.Metadata metadata, ArtifactRepository repository, + org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository, Exception exception ) { RepositoryListener listener = session.getRepositoryListener(); if ( listener != null ) { - DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace ); + RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID ); + event.setTrace( trace ); event.setMetadata( metadata ); event.setException( exception ); event.setRepository( repository ); - listener.metadataInvalid( event ); + listener.metadataInvalid( event.build() ); } } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResult.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResult.java index 65aea883b4..9917387ed5 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResult.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/DefaultPluginPrefixResult.java @@ -21,7 +21,7 @@ package org.apache.maven.plugin.prefix.internal; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.prefix.PluginPrefixResult; -import org.sonatype.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin prefix resolution request. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java index 1e671b3bd8..a1f116bb6a 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java @@ -26,8 +26,8 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve the version for a plugin. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java index a6b9e5bce7..5d2b63d21d 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java @@ -22,8 +22,8 @@ package org.apache.maven.plugin.version; import java.util.List; import org.apache.maven.model.Model; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve the version for a plugin. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java index af85f1f7ac..84ec0967af 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java @@ -21,8 +21,8 @@ package org.apache.maven.plugin.version; import java.util.List; -import org.sonatype.aether.repository.LocalRepository; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; public class PluginVersionResolutionException extends Exception diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java index 4169d3076d..bc3a2d28d2 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java @@ -19,7 +19,7 @@ package org.apache.maven.plugin.version; * under the License. */ -import org.sonatype.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin version resolution request. diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java index a215d2855f..95e0ba8eaa 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java @@ -43,22 +43,21 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.aether.RepositoryEvent.EventType; -import org.sonatype.aether.RepositoryListener; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.repository.ArtifactRepository; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.resolution.MetadataRequest; -import org.sonatype.aether.resolution.MetadataResult; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.listener.DefaultRepositoryEvent; -import org.sonatype.aether.util.metadata.DefaultMetadata; -import org.sonatype.aether.util.version.GenericVersionScheme; -import org.sonatype.aether.version.InvalidVersionSpecificationException; -import org.sonatype.aether.version.Version; -import org.sonatype.aether.version.VersionScheme; +import org.eclipse.aether.RepositoryEvent.EventType; +import org.eclipse.aether.RepositoryEvent; +import org.eclipse.aether.RepositoryListener; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.metadata.DefaultMetadata; +import org.eclipse.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.MetadataRequest; +import org.eclipse.aether.resolution.MetadataResult; +import org.eclipse.aether.util.version.GenericVersionScheme; +import org.eclipse.aether.version.InvalidVersionSpecificationException; +import org.eclipse.aether.version.Version; +import org.eclipse.aether.version.VersionScheme; /** * Resolves a version for a plugin. @@ -114,11 +113,11 @@ public class DefaultPluginVersionResolver private PluginVersionResult resolveFromRepository( PluginVersionRequest request ) throws PluginVersionResolutionException { - RequestTrace trace = DefaultRequestTrace.newChild( null, request ); + RequestTrace trace = RequestTrace.newChild( null, request ); DefaultPluginVersionResult result = new DefaultPluginVersionResult(); - org.sonatype.aether.metadata.Metadata metadata = + org.eclipse.aether.metadata.Metadata metadata = new DefaultMetadata( request.getGroupId(), request.getArtifactId(), "maven-metadata.xml", DefaultMetadata.Nature.RELEASE_OR_SNAPSHOT ); @@ -280,7 +279,7 @@ public class DefaultPluginVersionResolver } private void mergeMetadata( RepositorySystemSession session, RequestTrace trace, Versions versions, - org.sonatype.aether.metadata.Metadata metadata, ArtifactRepository repository ) + org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository ) { if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() ) { @@ -300,17 +299,18 @@ public class DefaultPluginVersionResolver } private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, - org.sonatype.aether.metadata.Metadata metadata, ArtifactRepository repository, + org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository, Exception exception ) { RepositoryListener listener = session.getRepositoryListener(); if ( listener != null ) { - DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace ); + RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID ); + event.setTrace( trace ); event.setMetadata( metadata ); event.setException( exception ); event.setRepository( repository ); - listener.metadataInvalid( event ); + listener.metadataInvalid( event.build() ); } } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java index 234d0b7ecc..c67516c0ce 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java @@ -20,7 +20,7 @@ package org.apache.maven.plugin.version.internal; */ import org.apache.maven.plugin.version.PluginVersionResult; -import org.sonatype.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin version resolution request. diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionRequest.java index a7f3a93812..cf5b0d70df 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionRequest.java @@ -19,8 +19,8 @@ package org.apache.maven.project; * under the License. */ -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.graph.DependencyFilter; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.graph.DependencyFilter; /** * @author Benjamin Bentmann diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java b/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java index 49727f3afe..b69b69ed02 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java @@ -25,8 +25,8 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.DependencyNode; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; /** * @author Benjamin Bentmann diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index a242ee579c..744d231d06 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -55,15 +55,14 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.impl.RemoteRepositoryManager; -import org.sonatype.aether.repository.LocalRepositoryManager; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.repository.WorkspaceRepository; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResult; -import org.sonatype.aether.util.DefaultRequestTrace; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.impl.RemoteRepositoryManager; +import org.eclipse.aether.repository.LocalRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.WorkspaceRepository; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResult; /** */ @@ -88,7 +87,7 @@ public class DefaultProjectBuilder private RepositorySystem repositorySystem; @Requirement - private org.sonatype.aether.RepositorySystem repoSystem; + private org.eclipse.aether.RepositorySystem repoSystem; @Requirement private RemoteRepositoryManager repositoryManager; @@ -245,7 +244,7 @@ public class DefaultProjectBuilder ModelBuildingRequest request = new DefaultModelBuildingRequest(); - RequestTrace trace = DefaultRequestTrace.newChild( null, configuration ).newChild( request ); + RequestTrace trace = RequestTrace.newChild( null, configuration ).newChild( request ); ModelResolver resolver = new ProjectModelResolver( config.session, trace, repoSystem, repositoryManager, config.repositories, @@ -274,7 +273,7 @@ public class DefaultProjectBuilder public ProjectBuildingResult build( Artifact artifact, boolean allowStubModel, ProjectBuildingRequest request ) throws ProjectBuildingException { - org.sonatype.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact ); + org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact ); pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact ); InternalConfig config = new InternalConfig( request, null ); @@ -291,7 +290,7 @@ public class DefaultProjectBuilder pomArtifact = pomResult.getArtifact(); localProject = pomResult.getRepository() instanceof WorkspaceRepository; } - catch ( org.sonatype.aether.resolution.ArtifactResolutionException e ) + catch ( org.eclipse.aether.resolution.ArtifactResolutionException e ) { if ( e.getResults().get( 0 ).isMissing() && allowStubModel ) { diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java index e9b08929c8..1d99343f64 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java @@ -52,12 +52,12 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.util.filter.ExclusionsDependencyFilter; -import org.sonatype.aether.util.graph.PreorderNodeListGenerator; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.filter.ExclusionsDependencyFilter; +import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator; /** * Assists the project builder. Warning: This is an internal utility class that is only public for diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java index f32426d0e3..87b4b8c92b 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java @@ -27,7 +27,7 @@ import java.util.Properties; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Profile; import org.apache.maven.model.building.ModelBuildingRequest; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; public class DefaultProjectBuildingRequest implements ProjectBuildingRequest diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java index 2d9b15944e..2a6be6d23b 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java @@ -34,22 +34,23 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.artifact.ArtifactType; -import org.sonatype.aether.artifact.ArtifactTypeRegistry; -import org.sonatype.aether.collection.CollectRequest; -import org.sonatype.aether.collection.DependencyCollectionException; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.graph.DependencyVisitor; -import org.sonatype.aether.resolution.ArtifactResult; -import org.sonatype.aether.resolution.DependencyRequest; -import org.sonatype.aether.util.DefaultRequestTrace; -import org.sonatype.aether.util.artifact.ArtifacIdUtils; -import org.sonatype.aether.util.artifact.ArtifactProperties; -import org.sonatype.aether.util.artifact.JavaScopes; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.ArtifactProperties; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.collection.DependencyCollectionException; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.graph.DependencyVisitor; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.resolution.DependencyRequest; +import org.eclipse.aether.util.artifact.ArtifactIdUtils; +import org.eclipse.aether.util.artifact.JavaScopes; +import org.eclipse.aether.util.graph.manager.DependencyManagerUtils; /** * @author Benjamin Bentmann @@ -68,17 +69,25 @@ public class DefaultProjectDependenciesResolver public DependencyResolutionResult resolve( DependencyResolutionRequest request ) throws DependencyResolutionException { - RequestTrace trace = DefaultRequestTrace.newChild( null, request ); + RequestTrace trace = RequestTrace.newChild( null, request ); DefaultDependencyResolutionResult result = new DefaultDependencyResolutionResult(); MavenProject project = request.getMavenProject(); RepositorySystemSession session = request.getRepositorySession(); + if ( logger.isDebugEnabled() + && session.getConfigProperties().get( DependencyManagerUtils.CONFIG_PROP_VERBOSE ) == null ) + { + DefaultRepositorySystemSession verbose = new DefaultRepositorySystemSession( session ); + verbose.setConfigProperty( DependencyManagerUtils.CONFIG_PROP_VERBOSE, Boolean.TRUE ); + session = verbose; + } DependencyFilter filter = request.getResolutionFilter(); ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry(); CollectRequest collect = new CollectRequest(); + collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) ); collect.setRequestContext( "project" ); collect.setRepositories( project.getRemoteProjectRepositories() ); @@ -110,7 +119,7 @@ public class DefaultProjectDependenciesResolver } } String key = - ArtifacIdUtils.toVersionlessId( dependency.getGroupId(), dependency.getArtifactId(), + ArtifactIdUtils.toVersionlessId( dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), classifier ); dependencies.put( key, dependency ); } @@ -119,11 +128,11 @@ public class DefaultProjectDependenciesResolver String key = artifact.getDependencyConflictId(); Dependency dependency = dependencies.get( key ); Collection exclusions = dependency != null ? dependency.getExclusions() : null; - org.sonatype.aether.graph.Dependency dep = RepositoryUtils.toDependency( artifact, exclusions ); + org.eclipse.aether.graph.Dependency dep = RepositoryUtils.toDependency( artifact, exclusions ); if ( !JavaScopes.SYSTEM.equals( dep.getScope() ) && dep.getArtifact().getFile() != null ) { // enable re-resolution - org.sonatype.aether.artifact.Artifact art = dep.getArtifact(); + org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); art = art.setFile( null ).setVersion( art.getBaseVersion() ); dep = dep.setArtifact( art ); } @@ -146,7 +155,7 @@ public class DefaultProjectDependenciesResolver DependencyNode node; try { - collect.setTrace( DefaultRequestTrace.newChild( trace, depRequest ) ); + collect.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( session, collect ).getRoot(); result.setDependencyGraph( node ); } @@ -182,7 +191,7 @@ public class DefaultProjectDependenciesResolver { process( result, repoSystem.resolveDependencies( session, depRequest ).getArtifactResults() ); } - catch ( org.sonatype.aether.resolution.DependencyResolutionException e ) + catch ( org.eclipse.aether.resolution.DependencyResolutionException e ) { process( result, e.getResult().getArtifactResults() ); @@ -228,24 +237,26 @@ public class DefaultProjectDependenciesResolver { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( indent ); - org.sonatype.aether.graph.Dependency dep = node.getDependency(); + org.eclipse.aether.graph.Dependency dep = node.getDependency(); if ( dep != null ) { - org.sonatype.aether.artifact.Artifact art = dep.getArtifact(); + org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); buffer.append( art ); buffer.append( ':' ).append( dep.getScope() ); - if ( node.getPremanagedScope() != null && !node.getPremanagedScope().equals( dep.getScope() ) ) + String premanagedScope = DependencyManagerUtils.getPremanagedScope( node ); + if ( premanagedScope != null && !premanagedScope.equals( dep.getScope() ) ) { - buffer.append( " (scope managed from " ).append( node.getPremanagedScope() ); + buffer.append( " (scope managed from " ).append( premanagedScope ); appendManagementSource( buffer, art, "scope" ); buffer.append( ")" ); } - if ( node.getPremanagedVersion() != null && !node.getPremanagedVersion().equals( art.getVersion() ) ) + String premanagedVersion = DependencyManagerUtils.getPremanagedVersion( node ); + if ( premanagedVersion != null && !premanagedVersion.equals( art.getVersion() ) ) { - buffer.append( " (version managed from " ).append( node.getPremanagedVersion() ); + buffer.append( " (version managed from " ).append( premanagedVersion ); appendManagementSource( buffer, art, "version" ); buffer.append( ")" ); } @@ -269,7 +280,7 @@ public class DefaultProjectDependenciesResolver return true; } - private void appendManagementSource( StringBuilder buffer, org.sonatype.aether.artifact.Artifact artifact, + private void appendManagementSource( StringBuilder buffer, org.eclipse.aether.artifact.Artifact artifact, String field ) { if ( managed == null ) @@ -285,7 +296,7 @@ public class DefaultProjectDependenciesResolver } String key = - ArtifacIdUtils.toVersionlessId( artifact.getGroupId(), artifact.getArtifactId(), + ArtifactIdUtils.toVersionlessId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getProperty( ArtifactProperties.TYPE, "jar" ), artifact.getClassifier() ); diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java index d895fdf0a7..1c5dfa3517 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java @@ -26,7 +26,7 @@ import java.util.Map; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; -import org.sonatype.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyFilter; /** * Default project realm cache implementation. Assumes cached data does not change. diff --git a/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionRequest.java b/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionRequest.java index a41778dd69..758c49170e 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionRequest.java @@ -19,8 +19,8 @@ package org.apache.maven.project; * under the License. */ -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.graph.DependencyFilter; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.graph.DependencyFilter; /** * A request to resolve the dependencies of a project. diff --git a/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionResult.java b/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionResult.java index d951c05b1d..2f62d80da2 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionResult.java @@ -21,8 +21,8 @@ package org.apache.maven.project; import java.util.List; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.DependencyNode; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; /** * The result of a project dependency resolution. 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 0349e8aa86..c3f214f4c3 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 @@ -60,8 +60,8 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.sonatype.aether.graph.DependencyFilter; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.repository.RemoteRepository; import java.io.File; import java.io.IOException; diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java index db8fe902fa..9ed113dad4 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java @@ -26,7 +26,7 @@ import java.util.Properties; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Profile; import org.apache.maven.model.building.ModelBuildingRequest; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; public interface ProjectBuildingRequest { diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java index e6cc41112a..522c79c9a8 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java @@ -33,15 +33,15 @@ import org.apache.maven.model.resolution.InvalidRepositoryException; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.model.resolution.UnresolvableModelException; import org.apache.maven.repository.internal.ArtifactDescriptorUtils; -import org.sonatype.aether.RepositorySystem; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.RequestTrace; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.RemoteRepositoryManager; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.resolution.ArtifactRequest; -import org.sonatype.aether.resolution.ArtifactResolutionException; -import org.sonatype.aether.util.artifact.DefaultArtifact; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.impl.RemoteRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; /** * A model resolver to assist building of projects. This resolver gives priority to those repositories that have been diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectRealmCache.java b/maven-core/src/main/java/org/apache/maven/project/ProjectRealmCache.java index e36d1d255a..456cfa90e7 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectRealmCache.java @@ -22,7 +22,7 @@ package org.apache.maven.project; import java.util.List; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.sonatype.aether.graph.DependencyFilter; +import org.eclipse.aether.graph.DependencyFilter; /** * Caches project class realms. Warning: This is an internal utility interface that is only public for 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 76c95a6b89..d56fdc62a6 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 @@ -75,9 +75,9 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RepositoryPolicy; -import org.sonatype.aether.transfer.ArtifactNotFoundException; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.transfer.ArtifactNotFoundException; /** * @author Jason van Zyl @@ -734,7 +734,7 @@ public class MavenMetadataSource { return true; } - if ( e.getCause() instanceof org.sonatype.aether.resolution.ArtifactResolutionException + if ( e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException && e.getCause().getCause() instanceof ArtifactNotFoundException ) { return true; @@ -748,7 +748,7 @@ public class MavenMetadataSource { return true; } - if ( e.getCause() instanceof org.sonatype.aether.resolution.ArtifactResolutionException + if ( e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException && !( e.getCause().getCause() instanceof ArtifactNotFoundException ) ) { return true; diff --git a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java index 7bcd442539..0f3cd56be1 100644 --- a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java +++ b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java @@ -34,7 +34,7 @@ import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Server; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; /** * @author Jason van Zyl diff --git a/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java b/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java index 04ec4fe3ca..2bb801d8bd 100644 --- a/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java +++ b/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java @@ -29,11 +29,11 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.aether.util.version.GenericVersionScheme; -import org.sonatype.aether.version.InvalidVersionSpecificationException; -import org.sonatype.aether.version.Version; -import org.sonatype.aether.version.VersionConstraint; -import org.sonatype.aether.version.VersionScheme; +import org.eclipse.aether.util.version.GenericVersionScheme; +import org.eclipse.aether.version.InvalidVersionSpecificationException; +import org.eclipse.aether.version.Version; +import org.eclipse.aether.version.VersionConstraint; +import org.eclipse.aether.version.VersionScheme; /** * Provides information about the current Maven runtime. @@ -139,7 +139,7 @@ public class DefaultRuntimeInformation throw new IllegalStateException( "Could not parse current Maven version: " + e.getMessage(), e ); } - if ( constraint.getRanges().isEmpty() ) + if ( constraint.getRange() == null ) { return constraint.getVersion().compareTo( current ) <= 0; } diff --git a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java index c547bfbaad..813a128ba7 100644 --- a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java +++ b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java @@ -42,12 +42,14 @@ import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; public abstract class AbstractCoreMavenComponentTestCase extends PlexusTestCase @@ -96,8 +98,7 @@ public abstract class AbstractCoreMavenComponentTestCase */ protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { -// containerConfiguration.addComponentDiscoverer( PluginManager.class ); -// containerConfiguration.addComponentDiscoveryListener( PluginManager.class ); + containerConfiguration.setAutoWiring( true ); } protected MavenExecutionRequest createMavenExecutionRequest( File pom ) @@ -160,10 +161,12 @@ public abstract class AbstractCoreMavenComponentTestCase } protected void initRepoSession( ProjectBuildingRequest request ) + throws Exception { - File localRepo = new File( request.getLocalRepository().getBasedir() ); - MavenRepositorySystemSession session = new MavenRepositorySystemSession( true ); - session.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) ); + File localRepoDir = new File( request.getLocalRepository().getBasedir() ); + LocalRepository localRepo = new LocalRepository( localRepoDir ); + DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); + session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); request.setRepositorySession( session ); } diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java index be148bd53e..133bcb3a21 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java @@ -24,8 +24,8 @@ import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; /** * @author Kristian Rosenvold diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginPrefixResolverStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginPrefixResolverStub.java index e5dc526c8d..a4b54e9814 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginPrefixResolverStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginPrefixResolverStub.java @@ -19,7 +19,7 @@ import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.prefix.PluginPrefixRequest; import org.apache.maven.plugin.prefix.PluginPrefixResolver; import org.apache.maven.plugin.prefix.PluginPrefixResult; -import org.sonatype.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.ArtifactRepository; /** * @author Kristian Rosenvold diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginVersionResolverStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginVersionResolverStub.java index b2daee2069..c79658e8d7 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginVersionResolverStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/PluginVersionResolverStub.java @@ -19,7 +19,7 @@ import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.plugin.version.PluginVersionResult; -import org.sonatype.aether.repository.ArtifactRepository; +import org.eclipse.aether.repository.ArtifactRepository; /** * @author Kristian Rosenvold diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java index 673e5387d3..4147b36cde 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependenciesResolverStub.java @@ -24,9 +24,9 @@ import org.apache.maven.project.DependencyResolutionException; import org.apache.maven.project.DependencyResolutionRequest; import org.apache.maven.project.DependencyResolutionResult; import org.apache.maven.project.MavenProject; -import org.sonatype.aether.graph.Dependency; -import org.sonatype.aether.graph.DependencyNode; -import org.sonatype.aether.util.graph.DefaultDependencyNode; +import org.eclipse.aether.graph.DefaultDependencyNode; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyNode; import java.util.Collection; import java.util.Collections; diff --git a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java index d6592ccc2a..a8b48290e0 100644 --- a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java @@ -27,8 +27,10 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; +import org.eclipse.aether.DefaultRepositorySystemSession; /** * @author Jason van Zyl @@ -39,7 +41,14 @@ public abstract class AbstractMavenProjectTestCase protected ProjectBuilder projectBuilder; protected RepositorySystem repositorySystem; - + + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + } + protected void setUp() throws Exception { @@ -170,7 +179,7 @@ public abstract class AbstractMavenProjectTestCase protected void initRepoSession( ProjectBuildingRequest request ) { File localRepo = new File( request.getLocalRepository().getBasedir() ); - MavenRepositorySystemSession repoSession = new MavenRepositorySystemSession( true ); + DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); repoSession.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); request.setRepositorySession( repoSession ); } diff --git a/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java b/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java index daab6c4f8e..52fdd80478 100644 --- a/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java +++ b/maven-core/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java @@ -21,22 +21,36 @@ package org.apache.maven.project; import java.io.File; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.repository.LocalArtifactRequest; -import org.sonatype.aether.repository.LocalArtifactResult; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.repository.LocalArtifactRegistration; +import org.eclipse.aether.repository.LocalArtifactRequest; +import org.eclipse.aether.repository.LocalArtifactResult; +import org.eclipse.aether.repository.LocalMetadataRegistration; +import org.eclipse.aether.repository.LocalMetadataRequest; +import org.eclipse.aether.repository.LocalMetadataResult; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.LocalRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; /** * @author Benjamin Bentmann */ public class LegacyLocalRepositoryManager - extends SimpleLocalRepositoryManager + implements LocalRepositoryManager { + private final LocalRepository repository; + public LegacyLocalRepositoryManager( File basedir ) { - super( basedir ); + this.repository = new LocalRepository( basedir.getAbsoluteFile(), "legacy" ); + } + + public LocalRepository getRepository() + { + return repository; } public String getPathForLocalArtifact( Artifact artifact ) @@ -59,17 +73,120 @@ public class LegacyLocalRepositoryManager return path.toString(); } + public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) + { + return getPathForLocalArtifact( artifact ); + } + + public String getPathForLocalMetadata( Metadata metadata ) + { + return getPath( metadata, "local" ); + } + + public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) + { + return getPath( metadata, getRepositoryKey( repository, context ) ); + } + + String getRepositoryKey( RemoteRepository repository, String context ) + { + return repository.getId(); + } + + private String getPath( Metadata metadata, String repositoryKey ) + { + StringBuilder path = new StringBuilder( 128 ); + + if ( metadata.getGroupId().length() > 0 ) + { + path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); + + if ( metadata.getArtifactId().length() > 0 ) + { + path.append( metadata.getArtifactId() ).append( '/' ); + + if ( metadata.getVersion().length() > 0 ) + { + path.append( metadata.getVersion() ).append( '/' ); + } + } + } + + path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) ); + + return path.toString(); + } + + private String insertRepositoryKey( String filename, String repositoryKey ) + { + String result; + int idx = filename.indexOf( '.' ); + if ( idx < 0 ) + { + result = filename + '-' + repositoryKey; + } + else + { + result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); + } + return result; + } + public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) { - String path = getPathForLocalArtifact( request.getArtifact() ); - File file = new File( getRepository().getBasedir(), path ); - LocalArtifactResult result = new LocalArtifactResult( request ); - if ( file.isFile() ) - { - result.setFile( file ); - result.setAvailable( true ); - } - return result; - } + String path = getPathForLocalArtifact( request.getArtifact() ); + File file = new File( getRepository().getBasedir(), path ); + LocalArtifactResult result = new LocalArtifactResult( request ); + if ( file.isFile() ) + { + result.setFile( file ); + result.setAvailable( true ); + } + + return result; + } + + public void add( RepositorySystemSession session, LocalArtifactRegistration request ) + { + // noop + } + + public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) + { + LocalMetadataResult result = new LocalMetadataResult( request ); + + String path; + + Metadata metadata = request.getMetadata(); + String context = request.getContext(); + RemoteRepository remote = request.getRepository(); + + if ( remote != null ) + { + path = getPathForRemoteMetadata( metadata, remote, context ); + } + else + { + path = getPathForLocalMetadata( metadata ); + } + + File file = new File( getRepository().getBasedir(), path ); + if ( file.isFile() ) + { + result.setFile( file ); + } + + return result; + } + + public void add( RepositorySystemSession session, LocalMetadataRegistration request ) + { + // noop + } + + public String toString() + { + return String.valueOf( getRepository() ); + } } diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index 8012124fe0..06ee6c9cde 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -32,9 +32,12 @@ import org.apache.maven.model.PluginExecution; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.project.harness.PomTestWrapper; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; public class PomConstructionTest extends PlexusTestCase @@ -51,6 +54,13 @@ public class PomConstructionTest private File testDirectory; + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + } + protected void setUp() throws Exception { @@ -1808,20 +1818,20 @@ public class PomConstructionTest } private PomTestWrapper buildPom( String pomPath, String... profileIds ) - throws ProjectBuildingException + throws Exception { return buildPom( pomPath, null, profileIds ); } private PomTestWrapper buildPom( String pomPath, Properties executionProperties, String... profileIds ) - throws ProjectBuildingException + throws Exception { return buildPom( pomPath, false, executionProperties, profileIds ); } private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties executionProperties, String... profileIds ) - throws ProjectBuildingException + throws Exception { File pomFile = new File( testDirectory, pomPath ); if ( pomFile.isDirectory() ) @@ -1840,10 +1850,10 @@ public class PomConstructionTest config.setUserProperties( executionProperties ); config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 : ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); - MavenRepositorySystemSession repoSession = new MavenRepositorySystemSession( true ); - repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( - new File( - config.getLocalRepository().getBasedir() ) ) ); + + DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); + LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() ); + repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) ); config.setRepositorySession( repoSession ); return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() ); diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java index d2a25b1f13..91ace4f1e8 100644 --- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java +++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java @@ -26,15 +26,15 @@ import java.net.URL; import java.util.Collection; import org.codehaus.plexus.util.FileUtils; -import org.sonatype.aether.artifact.Artifact; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.spi.connector.ArtifactDownload; -import org.sonatype.aether.spi.connector.ArtifactUpload; -import org.sonatype.aether.spi.connector.MetadataDownload; -import org.sonatype.aether.spi.connector.MetadataUpload; -import org.sonatype.aether.spi.connector.RepositoryConnector; -import org.sonatype.aether.transfer.ArtifactNotFoundException; -import org.sonatype.aether.transfer.ArtifactTransferException; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.spi.connector.ArtifactDownload; +import org.eclipse.aether.spi.connector.ArtifactUpload; +import org.eclipse.aether.spi.connector.MetadataDownload; +import org.eclipse.aether.spi.connector.MetadataUpload; +import org.eclipse.aether.spi.connector.RepositoryConnector; +import org.eclipse.aether.transfer.ArtifactNotFoundException; +import org.eclipse.aether.transfer.ArtifactTransferException; /** * @author Benjamin Bentmann diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnectorFactory.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnectorFactory.java index 008a83cbe9..17fd43f925 100644 --- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnectorFactory.java +++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnectorFactory.java @@ -20,11 +20,11 @@ package org.apache.maven.repository; */ import org.codehaus.plexus.component.annotations.Component; -import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.repository.RemoteRepository; -import org.sonatype.aether.spi.connector.RepositoryConnector; -import org.sonatype.aether.spi.connector.RepositoryConnectorFactory; -import org.sonatype.aether.transfer.NoRepositoryConnectorException; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.spi.connector.RepositoryConnector; +import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; +import org.eclipse.aether.transfer.NoRepositoryConnectorException; /** * @author Benjamin Bentmann @@ -40,7 +40,7 @@ public class TestRepositoryConnectorFactory return new TestRepositoryConnector( repository ); } - public int getPriority() + public float getPriority() { return 0; } diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java index c90f08aff8..2a9b17652a 100644 --- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java +++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java @@ -48,7 +48,7 @@ import org.apache.maven.settings.Server; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; -import org.sonatype.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; /** * @author Benjamin Bentmann diff --git a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java index ec0ef67b94..41b21ce7a2 100644 --- a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java +++ b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java @@ -31,13 +31,16 @@ import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.project.harness.PomTestWrapper; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; +import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; public class PomConstructionWithSettingsTest extends PlexusTestCase @@ -52,6 +55,13 @@ public class PomConstructionWithSettingsTest private File testDirectory; + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + } + protected void setUp() throws Exception { @@ -113,10 +123,10 @@ public class PomConstructionWithSettingsTest config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) ); config.setActiveProfileIds( settings.getActiveProfiles() ); - MavenRepositorySystemSession repoSession = new MavenRepositorySystemSession( true ); - repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( - new File( - config.getLocalRepository().getBasedir() ) ) ); + + DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); + LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() ); + repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) ); config.setRepositorySession( repoSession ); return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() ); diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index 0e71c8b718..62999f5a23 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -76,10 +76,10 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.util.StringUtils; +import org.eclipse.aether.transfer.TransferListener; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonatype.aether.transfer.TransferListener; import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java index d63cdfc070..58b1a5dcba 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java @@ -24,10 +24,10 @@ import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; -import org.sonatype.aether.transfer.AbstractTransferListener; -import org.sonatype.aether.transfer.TransferCancelledException; -import org.sonatype.aether.transfer.TransferEvent; -import org.sonatype.aether.transfer.TransferResource; +import org.eclipse.aether.transfer.AbstractTransferListener; +import org.eclipse.aether.transfer.TransferCancelledException; +import org.eclipse.aether.transfer.TransferEvent; +import org.eclipse.aether.transfer.TransferResource; public abstract class AbstractMavenTransferListener extends AbstractTransferListener diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java index 2263c937a6..f5f4abc8fd 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java @@ -23,9 +23,9 @@ import java.io.PrintStream; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.sonatype.aether.transfer.TransferCancelledException; -import org.sonatype.aether.transfer.TransferEvent; -import org.sonatype.aether.transfer.TransferResource; +import org.eclipse.aether.transfer.TransferCancelledException; +import org.eclipse.aether.transfer.TransferEvent; +import org.eclipse.aether.transfer.TransferResource; /** * Console download progress meter. diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java index 319519cc43..fd9f52cf51 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java @@ -19,7 +19,7 @@ package org.apache.maven.cli.transfer; * under the License. */ -import org.sonatype.aether.transfer.AbstractTransferListener; +import org.eclipse.aether.transfer.AbstractTransferListener; /** * @author Benjamin Bentmann diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java index f09c768959..6560fe5231 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java @@ -23,12 +23,12 @@ import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; +import org.eclipse.aether.transfer.AbstractTransferListener; +import org.eclipse.aether.transfer.TransferCancelledException; +import org.eclipse.aether.transfer.TransferEvent; +import org.eclipse.aether.transfer.TransferResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonatype.aether.transfer.AbstractTransferListener; -import org.sonatype.aether.transfer.TransferCancelledException; -import org.sonatype.aether.transfer.TransferEvent; -import org.sonatype.aether.transfer.TransferResource; public class Slf4jMavenTransferListener extends AbstractTransferListener diff --git a/maven-embedder/src/site/apt/logging.apt b/maven-embedder/src/site/apt/logging.apt index fc3834efc4..bdab9b2d57 100644 --- a/maven-embedder/src/site/apt/logging.apt +++ b/maven-embedder/src/site/apt/logging.apt @@ -24,7 +24,11 @@ Maven Logging Plexus Logger and LoggerManager can be injected in Plexus component using Plexus annotations +<<<<<<< HEAD ++------ +======= +------+ +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -39,11 +43,26 @@ public class DefaultMyComponent @Requirement private LoggerManager loggerManager; } +<<<<<<< HEAD ++------ +======= +------+ +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 Starting with Maven 3.1.0, SLF4J Logger can be used directly too, without Plexus. Of course, this will only work when run under Maven 3.1.0, then this technique can be used safely only in Maven core components. +<<<<<<< HEAD ++----- +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Wombat +{ + final Logger logger = LoggerFactory.getLogger(Wombat.class); +} ++----- +======= +-----+ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,6 +72,7 @@ public class MyClass final Logger logger = LoggerFactory.getLogger( MyClass.class ); } +-----+ +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 * Logger Name diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 5b33f7767d..821aca41bc 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -62,6 +62,7 @@ under the License. src/main/mdo/lifecycle.mdo + src/main/mdo/plugin.mdo 1.0.0 @@ -76,6 +77,15 @@ under the License. + + maven-jar-plugin + + + org/apache/maven/plugin/descriptor/model + org/apache/maven/plugin/descriptor/model/**/* + + +
diff --git a/maven-plugin-api/src/site/apt/index.apt b/maven-plugin-api/src/site/apt/index.apt index 4d2497b2a6..3def6bca6a 100644 --- a/maven-plugin-api/src/site/apt/index.apt +++ b/maven-plugin-api/src/site/apt/index.apt @@ -3,20 +3,35 @@ ----- Hervé Boutemy ----- +<<<<<<< HEAD 2012-06-02 +======= + 2011-10-16 +>>>>>>> 4fdcdbd26244ff81e242054fd38cf415d92499be ----- Maven Plugin API +<<<<<<< HEAD The API for plugins - composed of goals implemented by Mojos - development. A plugin is described in a {{{./plugin.html}<<>> plugin descriptor}}, generally generated from plugin sources using {{{/plugin-tools/maven-plugin-plugin/}maven-plugin-plugin}}. +======= + The API for plugins - Mojos - development. + + A plugin is described in a {{{./plugin.html}<<>> plugin descriptor}}, + generally generated from plugin sources using {{{/plugins/maven-plugin-plugin/}maven-plugin-plugin}}. +>>>>>>> 4fdcdbd26244ff81e242054fd38cf415d92499be * See Also * {{{/developers/mojo-api-specification.html}Mojo API Specification}} +<<<<<<< HEAD * {{{/plugin-tools/}plugin-tools}} * {{{/plugin-testing/}plugin-testing}} +======= + * {{{/plugin-tools/}plugin-tools}}, containing {{{/plugins/maven-plugin-plugin/}maven-plugin-plugin}} +>>>>>>> 4fdcdbd26244ff81e242054fd38cf415d92499be diff --git a/pom.xml b/pom.xml index 2049e9f351..ed5ea974b9 100644 --- a/pom.xml +++ b/pom.xml @@ -58,13 +58,15 @@ 1.7 1.7 1.3 - 1.13.1 1.7.2 + 0.9.0.M2 true apache-maven Maven Apache Maven + scp://people.apache.org/www/maven.apache.org/ref/${project.version}/ + http://maven.apache.org/ref/${project.version}/ ref/3-LATEST @@ -262,39 +264,29 @@ - org.sonatype.aether + org.eclipse.aether aether-api ${aetherVersion} - org.sonatype.aether + org.eclipse.aether aether-spi ${aetherVersion} - org.sonatype.aether + org.eclipse.aether aether-impl ${aetherVersion} - org.sonatype.aether + org.eclipse.aether aether-util ${aetherVersion} - org.sonatype.aether + org.eclipse.aether aether-connector-wagon ${aetherVersion} - - - org.codehaus.plexus - plexus-container-default - - - org.sonatype.sisu - sisu-inject-plexus - - @@ -572,4 +564,5 @@ + diff --git a/src/site/site.xml b/src/site/site.xml index 6954e93cde..291d8ced9f 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.skins maven-fluido-skin - 1.2.1 + 1.3.0