mirror of https://github.com/apache/maven.git
Remove deprecated usage of ServiceLocator/Service
This commit is contained in:
parent
e30c1bf9fc
commit
1ab49b349f
|
@ -33,7 +33,6 @@ import org.apache.maven.model.DistributionManagement;
|
|||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Relocation;
|
||||
import org.apache.maven.model.building.ArtifactModelSource;
|
||||
import org.apache.maven.model.building.DefaultModelBuilderFactory;
|
||||
import org.apache.maven.model.building.DefaultModelBuildingRequest;
|
||||
import org.apache.maven.model.building.ModelBuilder;
|
||||
import org.apache.maven.model.building.ModelBuildingException;
|
||||
|
@ -65,8 +64,6 @@ 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.transfer.ArtifactNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -77,7 +74,7 @@ import org.slf4j.LoggerFactory;
|
|||
@Named
|
||||
@Singleton
|
||||
public class DefaultArtifactDescriptorReader
|
||||
implements ArtifactDescriptorReader, Service
|
||||
implements ArtifactDescriptorReader
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger( DefaultArtifactDescriptorReader.class );
|
||||
|
||||
|
@ -111,20 +108,6 @@ public class DefaultArtifactDescriptorReader
|
|||
setRepositoryEventDispatcher( repositoryEventDispatcher );
|
||||
}
|
||||
|
||||
public void initService( ServiceLocator locator )
|
||||
{
|
||||
setRemoteRepositoryManager( locator.getService( RemoteRepositoryManager.class ) );
|
||||
setVersionResolver( locator.getService( VersionResolver.class ) );
|
||||
setVersionRangeResolver( locator.getService( VersionRangeResolver.class ) );
|
||||
setArtifactResolver( locator.getService( ArtifactResolver.class ) );
|
||||
modelBuilder = locator.getService( ModelBuilder.class );
|
||||
if ( modelBuilder == null )
|
||||
{
|
||||
setModelBuilder( new DefaultModelBuilderFactory().newInstance() );
|
||||
}
|
||||
setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
|
||||
}
|
||||
|
||||
public DefaultArtifactDescriptorReader setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager )
|
||||
{
|
||||
this.remoteRepositoryManager = Objects.requireNonNull( remoteRepositoryManager,
|
||||
|
|
|
@ -39,8 +39,6 @@ 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.synccontext.SyncContextFactory;
|
||||
import org.eclipse.aether.util.version.GenericVersionScheme;
|
||||
import org.eclipse.aether.version.InvalidVersionSpecificationException;
|
||||
|
@ -67,7 +65,7 @@ import java.util.Objects;
|
|||
@Named
|
||||
@Singleton
|
||||
public class DefaultVersionRangeResolver
|
||||
implements VersionRangeResolver, Service
|
||||
implements VersionRangeResolver
|
||||
{
|
||||
|
||||
private static final String MAVEN_METADATA_XML = "maven-metadata.xml";
|
||||
|
@ -92,13 +90,6 @@ public class DefaultVersionRangeResolver
|
|||
setRepositoryEventDispatcher( repositoryEventDispatcher );
|
||||
}
|
||||
|
||||
public void initService( ServiceLocator locator )
|
||||
{
|
||||
setMetadataResolver( locator.getService( MetadataResolver.class ) );
|
||||
setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
|
||||
setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
|
||||
}
|
||||
|
||||
public DefaultVersionRangeResolver setMetadataResolver( MetadataResolver metadataResolver )
|
||||
{
|
||||
this.metadataResolver = Objects.requireNonNull( metadataResolver, "metadataResolver cannot be null" );
|
||||
|
|
|
@ -46,8 +46,6 @@ 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.synccontext.SyncContextFactory;
|
||||
import org.eclipse.aether.util.ConfigUtils;
|
||||
|
||||
|
@ -72,7 +70,7 @@ import java.util.Objects;
|
|||
@Named
|
||||
@Singleton
|
||||
public class DefaultVersionResolver
|
||||
implements VersionResolver, Service
|
||||
implements VersionResolver
|
||||
{
|
||||
|
||||
private static final String MAVEN_METADATA_XML = "maven-metadata.xml";
|
||||
|
@ -103,13 +101,6 @@ public class DefaultVersionResolver
|
|||
setRepositoryEventDispatcher( repositoryEventDispatcher );
|
||||
}
|
||||
|
||||
public void initService( ServiceLocator locator )
|
||||
{
|
||||
setMetadataResolver( locator.getService( MetadataResolver.class ) );
|
||||
setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
|
||||
setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
|
||||
}
|
||||
|
||||
public DefaultVersionResolver setMetadataResolver( MetadataResolver metadataResolver )
|
||||
{
|
||||
this.metadataResolver = Objects.requireNonNull( metadataResolver, "metadataResolver cannot be null" );
|
||||
|
|
|
@ -27,11 +27,6 @@ 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;
|
||||
|
@ -63,25 +58,6 @@ public final class 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}.
|
||||
* @deprecated This method is deprecated along with {@link DefaultServiceLocator} (since Maven Resolver 1.7.0).
|
||||
*/
|
||||
@Deprecated
|
||||
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
|
||||
|
|
|
@ -19,13 +19,9 @@ package org.apache.maven.repository.internal;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.RepositorySystemSession;
|
||||
import org.eclipse.aether.impl.MetadataGeneratorFactory;
|
||||
import org.eclipse.aether.spi.locator.ServiceLocator;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class MavenRepositorySystemUtilsTest
|
||||
|
@ -38,19 +34,4 @@ public class MavenRepositorySystemUtilsTest
|
|||
assertNotNull( session );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRepositorySystem()
|
||||
{
|
||||
ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
||||
RepositorySystem repoSys = locator.getService( RepositorySystem.class );
|
||||
assertNotNull( repoSys );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMetadataGeneratorFactories()
|
||||
{
|
||||
ServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
||||
assertEquals( 2, locator.getServices( MetadataGeneratorFactory.class ).size() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue