<requiredProperty key="httpcoreVersion">
<defaultValue>${httpclient.core.version}</defaultValue>
</requiredProperty>
+ <requiredProperty key="asmVersion">
+ <defaultValue>${asm.version}</defaultValue>
+ </requiredProperty>
</requiredProperties>
</archetype-descriptor>
<mockito.version>${mockitoVersion}</mockito.version>
<httpclient.version>${httpclientVersion}</httpclient.version>
<httpclient.core.version>${httpcoreVersion}</httpclient.core.version>
+ <asm.version>${asmVersion}</asm.version>
</properties>
<dependencies>
<dependency>
<version>${springockito.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<!-- match up with those used by Archiva -->
<artifactId>httpcore</artifactId>
<version>${httpclient.core.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>${asm.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
springockitoVersion=${springockito.version}
mockitoVersion=${mockito.version}
httpclientVersion=${httpclient.version}
-httpcoreVersion=${httpclient.core.version}
\ No newline at end of file
+httpcoreVersion=${httpclient.core.version}
+asmVersion=${asm.version}
\ No newline at end of file
<artifactId>jaxb-api</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<pluginManagement>
<artifactId>archiva-maven2-indexer</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-model-converter</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-guice</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.aether</groupId>
+ <artifactId>aether-util</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-checksum</artifactId>
<scope>test</scope>
</dependency>
- <!-- Needed for JDK >= 9 -->
+ <!-- START Needed for JDK >= 9 -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<artifactId>jaxb-api</artifactId>
<scope>test</scope>
</dependency>
+ <!-- STOP Needed for JDK >= 9 -->
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.codehaus.plexus.component.annotations.Component;
/**
* @author jdcasey
*/
+@Component( role = ArtifactRepositoryLayout.class, hint = "legacy")
public class LegacyRepositoryLayout
implements ArtifactRepositoryLayout
{
import org.apache.archiva.repository.scanner.RepositoryScannerException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.springframework.stereotype.Service;
/**
*
*/
- private ArtifactRepositoryFactory artifactRepositoryFactory;
+ // private ArtifactRepositoryFactory artifactRepositoryFactory;
/**
*
public DefaultLegacyRepositoryConverter( PlexusSisuBridge plexusSisuBridge )
throws PlexusSisuBridgeException
{
- artifactRepositoryFactory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
+ // artifactRepositoryFactory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
defaultLayout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
}
legacyRepository.setLayout( "legacy" );
ArtifactRepository repository =
- artifactRepositoryFactory.createArtifactRepository( "default", defaultRepositoryUrl, defaultLayout,
- null, null );
+ new MavenArtifactRepository("default", defaultRepositoryUrl, defaultLayout, null, null);
+
legacyConverterConsumer.setExcludes( fileExclusionPatterns );
legacyConverterConsumer.setDestinationRepository( repository );
import junit.framework.TestCase;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.converter.artifact.LegacyRepositoryLayout;
import org.apache.archiva.converter.legacy.LegacyRepositoryConverter;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.junit.Before;
import org.junit.Test;
{
super.setUp();
- ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
+ // ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
//(ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
- ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "legacy" );
+ ArtifactRepositoryLayout layout = new LegacyRepositoryLayout();
//(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
Path sourceBase = Paths.get( "src/test/source-repository" );
- sourceRepository = factory.createArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null,
+ sourceRepository = new MavenArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null,
null );
layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
{
super.setUp();
- ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
+ // ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
- ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "legacy" );
+ ArtifactRepositoryLayout layout = new LegacyRepositoryLayout();
Path sourceBase = getTestFile( "src/test/source-repository" );
sourceRepository =
- factory.createArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
+ new MavenArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
copyDirectoryStructure( getTestFile( "src/test/target-repository" ), targetBase );
targetRepository =
- factory.createArtifactRepository( "target", targetBase.toUri().toURL().toString(), layout, null, null );
+ new MavenArtifactRepository( "target", targetBase.toUri().toURL().toString(), layout, null, null );
artifactConverter =
applicationContext.getBean( "artifactConverter#legacy-to-default", ArtifactConverter.class );
{
// test that it fails if the same
- ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
sourceRepository =
- factory.createArtifactRepository( "source", targetRepository.getUrl(), targetRepository.getLayout(), null,
+ new MavenArtifactRepository( "source", targetRepository.getUrl(), targetRepository.getLayout(), null,
null );
Artifact artifact = createArtifact( "test", "repository-artifact", "1.0" );
private void createModernSourceRepository()
throws Exception
{
- ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
-
ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
Path sourceBase = getTestFile( "src/test/source-modern-repository" );
sourceRepository =
- factory.createArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
+ new MavenArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
}
}
<artifactId>log4j-jcl</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<artifactId>indexer-core</artifactId>
<classifier>shaded-lucene</classifier>
</dependency>
+
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ </dependency>
<!--
<dependency>
<groupId>org.codehaus.plexus</groupId>
* under the License.
*/
+import com.google.inject.AbstractModule;
+import org.apache.maven.bridge.MavenRepositorySystem;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.eclipse.sisu.inject.TypeArguments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
+import javax.inject.Inject;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
public class PlexusSisuBridge
{
+ private MavenRepositorySystem mavenRepositorySystem = new MavenRepositorySystem();
+
private Logger log = LoggerFactory.getLogger( getClass() );
private boolean containerAutoWiring = true;
private DefaultPlexusContainer plexusContainer;
+ class InternalBinder extends AbstractModule {
+
+ @Override
+ protected void configure( )
+ {
+ bind( MavenRepositorySystem.class ).toInstance( mavenRepositorySystem );
+ // bind(TypeArguments.implicitKey( MavenRepositorySystem.class )).to(MavenRepositorySystem.class);
+ }
+ }
+
@PostConstruct
public void initialize()
throws PlexusSisuBridgeException
for ( URL url : urls )
{
containerRealm.addURL( url );
+ log.debug("Added url {}", url);
}
}
try
{
Thread.currentThread().setContextClassLoader( containerRealm );
- plexusContainer = new DefaultPlexusContainer( conf );
+ InternalBinder binder = new InternalBinder( );
+ plexusContainer = new DefaultPlexusContainer( conf, binder );
+
}
catch ( PlexusContainerException e )
{
throw new PlexusSisuBridgeException( e.getMessage(), e );
+ } catch (Throwable ex) {
+ log.error("PlexusSisuBridge initialization failed {}", ex.getMessage(), ex);
+ throw new PlexusSisuBridgeException( ex.getMessage(), ex );
}
finally
{
default-lazy-init="true">
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.common.plexusbridge
- org.apache.maven.index"/>
+ <context:component-scan base-package="org.apache.archiva.common.plexusbridge, org.apache.maven.*"/>
+
<!--
- <bean id="indexer" class="org.apache.maven.index.DefaultIndexer"/>
+ <bean id="indexer" class="org.apache.maven.bridge.MavenRepositorySystem.apache.maven.index.DefaultIndexer"/>
<bean id="scanner" class="org.apache.maven.index.DefaultScanner"/>
<bean id="indexerEngine" class="org.apache.maven.index.DefaultIndexerEngine"/>
<bean id="searchEngine" class="org.apache.maven.index.DefaultSearchEngine"/>
<artifactId>archiva-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
<scope>test</scope>
</dependency>
- <!-- Needed for JDK >= 9 -->
+ <!-- START Needed for JDK >= 9 -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<artifactId>jaxb-api</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- END Needed for JDK >= 9 -->
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<artifactId>xercesImpl</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
<artifactId>archiva-maven2-indexer</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
<artifactId>jaxb-runtime</artifactId>
<scope>test</scope>
</dependency>
+
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<properties>
<webappDirectory>${project.build.directory}/container/webapps/archiva</webappDirectory>
- <container.propertiesPortFilePath>${project.build.directory}/container-port.properties</container.propertiesPortFilePath>
+ <container.propertiesPortFilePath>${project.build.directory}/container-port.properties
+ </container.propertiesPortFilePath>
<maxWaitTimeInMs>10000</maxWaitTimeInMs>
<selenium-server.version>3.4.0</selenium-server.version>
<fluentlenium.version>3.2.0</fluentlenium.version>
<artifactId>archiva-webapp</artifactId>
<type>war</type>
</dependency>
-<!-- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-slf4j-logging</artifactId>
- <exclusions>
- <exclusion>
- <artifactId>plexus-component-api</artifactId>
+ <!-- <dependency>
<groupId>org.codehaus.plexus</groupId>
- </exclusion>
- </exclusions>
- </dependency>-->
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-slf4j-logging</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>plexus-component-api</artifactId>
+ <groupId>org.codehaus.plexus</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>-->
<!--
jcr-oak currently needs guava 15.0 and selenium webdriver needs 22.0
</dependency>
-
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
</dependency>
-
-
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-slf4j-logging</artifactId>
+ <version>1.1</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
<configuration>
<failOnError>false</failOnError>
<target>
- <delete file="${user.home}/.m2/archiva.xml" />
+ <delete file="${user.home}/.m2/archiva.xml"/>
</target>
</configuration>
</execution>
<version>${spring.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-slf4j-logging</artifactId>
+ <version>1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
<build>
<scope>test</scope>
</dependency>
- <!-- Needed for JDK >= 9 -->
+ <!-- START Needed for JDK >= 9 -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<artifactId>jaxb-api</artifactId>
<scope>test</scope>
</dependency>
+ <!-- END Needed for JDK >= 9 -->
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
- <version>3.3.9</version>
+ <artifactId>maven-resolver-provider</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
- <version>0.9.0.M2</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-file</artifactId>
- <version>0.9.0.M2</version>
</dependency>
<dependency>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<plugins>
}
+
}
private RepositorySystem newRepositorySystem()
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.eclipse.aether.impl.VersionRangeResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
// MRM-1411
req.setModelResolver(
new RepositoryModelResolver( managedRepository, pathTranslator, wagonFactory, remoteRepositories,
- networkProxies, managedRepository ) );
+ networkProxies, managedRepository ));
Model model;
try
import org.apache.archiva.admin.model.beans.NetworkProxy;
import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.dependency.tree.maven2.ArchivaRepositoryConnectorFactory;
+import org.apache.archiva.indexer.UnsupportedBaseContextException;
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.xml.XMLException;
import org.apache.commons.lang.StringUtils;
import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.maven.index.context.IndexingContext;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Repository;
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.DefaultArtifactDescriptorReader;
+import org.apache.maven.repository.internal.DefaultVersionRangeResolver;
+import org.apache.maven.repository.internal.DefaultVersionResolver;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.proxy.ProxyInfo;
+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.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.DefaultServiceLocator;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RepositoryModelResolver
implements ModelResolver
{
+
+ private RepositorySystemSession session;
+ private VersionRangeResolver versionRangeResolver;
+
private Path basedir;
private RepositoryPathTranslator pathTranslator;
private static final String METADATA_FILENAME = "maven-metadata.xml";
+ private DefaultServiceLocator locator;
+
// key/value: remote repo ID/network proxy
Map<String, NetworkProxy> networkProxyMap;
public RepositoryModelResolver( ManagedRepository managedRepository, RepositoryPathTranslator pathTranslator,
WagonFactory wagonFactory, List<RemoteRepository> remoteRepositories,
- Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository )
+ Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository)
{
this( Paths.get( managedRepository.getLocation() ), pathTranslator );
this.networkProxyMap = networkProxiesMap;
this.targetRepository = targetRepository;
+
+ this.locator = MavenRepositorySystemUtils.newServiceLocator( );
+
+ locator.addService( RepositoryConnectorFactory.class,
+ ArchivaRepositoryConnectorFactory.class );// FileRepositoryConnectorFactory.class );
+ locator.addService( VersionResolver.class, DefaultVersionResolver.class );
+ locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class );
+ locator.addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class );
+
+ this.session = newRepositorySystemSession( newRepositorySystem(), managedRepository.getLocalPath().toString() );
+
+ this.versionRangeResolver = locator.getService(VersionRangeResolver.class);
+ }
+
+ private RepositorySystem newRepositorySystem()
+ {
+ return locator.getService( RepositorySystem.class );
+ }
+
+ private RepositorySystemSession newRepositorySystemSession( RepositorySystem system, String localRepoDir )
+ {
+ DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession( );
+
+ LocalRepository repo = new LocalRepository( localRepoDir );
+
+ DependencySelector depFilter = new AndDependencySelector( new ExclusionDependencySelector() );
+ session.setDependencySelector( depFilter );
+ SimpleLocalRepositoryManagerFactory repFactory = new SimpleLocalRepositoryManagerFactory( );
+ try
+ {
+ LocalRepositoryManager manager = repFactory.newInstance( session, repo );
+ session.setLocalRepositoryManager(manager);
+ }
+ catch ( NoLocalRepositoryManagerException e )
+ {
+ e.printStackTrace( );
+ }
+
+ return session;
}
@Override
return new FileModelSource( model.toFile() );
}
- // TODO: v3.0.0 Implement this method
- @Override
- public ModelSource resolveModel( Parent parent ) throws UnresolvableModelException
- {
- return null;
+ public ModelSource resolveModel(Parent parent) throws UnresolvableModelException {
+ try {
+ Artifact artifact = new DefaultArtifact(parent.getGroupId(), parent.getArtifactId(), "", "pom", parent.getVersion());
+ VersionRangeRequest versionRangeRequest;
+ versionRangeRequest = new VersionRangeRequest(artifact, null, null);
+ VersionRangeResult versionRangeResult = this.versionRangeResolver.resolveVersionRange(this.session, versionRangeRequest);
+ if (versionRangeResult.getHighestVersion() == null) {
+ throw new UnresolvableModelException(String.format("No versions matched the requested parent version range '%s'", parent.getVersion()), parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+ } else if (versionRangeResult.getVersionConstraint() != null && versionRangeResult.getVersionConstraint().getRange() != null && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null) {
+ throw new UnresolvableModelException(String.format("The requested parent version range '%s' does not specify an upper bound", parent.getVersion()), parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+ } else {
+ parent.setVersion(versionRangeResult.getHighestVersion().toString());
+ return this.resolveModel(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+ }
+ } catch ( VersionRangeResolutionException var5) {
+ throw new UnresolvableModelException(var5.getMessage(), parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), var5);
+ }
}
- // TODO: v3.0.0 Implement this method
- @Override
- public ModelSource resolveModel( Dependency dependency ) throws UnresolvableModelException
- {
- return null;
+ public ModelSource resolveModel(Dependency dependency) throws UnresolvableModelException {
+ try {
+ Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), "", "pom", dependency.getVersion());
+ VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifact, null, null);
+ VersionRangeResult versionRangeResult = this.versionRangeResolver.resolveVersionRange(this.session, versionRangeRequest);
+ if (versionRangeResult.getHighestVersion() == null) {
+ throw new UnresolvableModelException(String.format("No versions matched the requested dependency version range '%s'", dependency.getVersion()), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
+ } else if (versionRangeResult.getVersionConstraint() != null && versionRangeResult.getVersionConstraint().getRange() != null && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null) {
+ throw new UnresolvableModelException(String.format("The requested dependency version range '%s' does not specify an upper bound", dependency.getVersion()), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
+ } else {
+ dependency.setVersion(versionRangeResult.getHighestVersion().toString());
+ return this.resolveModel(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
+ }
+ } catch (VersionRangeResolutionException var5) {
+ throw new UnresolvableModelException(var5.getMessage(), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), var5);
+ }
}
protected Path findTimeStampedSnapshotPom( String groupId, String artifactId, String version,
public ModelResolver newCopy()
{
return new RepositoryModelResolver( managedRepository, pathTranslator, wagonFactory, remoteRepositories,
- networkProxyMap, targetRepository );
+ networkProxyMap, targetRepository);
}
// FIXME: we need to do some refactoring, we cannot re-use the proxy components of archiva-proxy in maven2-repository
<artifactId>metrics-core</artifactId>
<version>3.1.0</version>
</dependency>
- </dependencies>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+</dependencies>
<build>
<testResources>
<testResource>
<artifactId>xercesImpl</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<plugins>
<commons-lang.version>2.6</commons-lang.version>
<maven3x.version>3.5.4</maven3x.version>
- <maven.version>2.0.8</maven.version>
- <aether.version>1.13.1</aether.version>
+ <maven.artifact-manager.version>2.2.1</maven.artifact-manager.version>
+ <sonatype.aether.version>1.13.1</sonatype.aether.version>
+ <eclipse.aether.version>0.9.0.M2</eclipse.aether.version>
<maven-model-converter.version>2.1</maven-model-converter.version>
<maven.indexer.version>6.0.0</maven.indexer.version>
<guava.version>15.0</guava.version>
<openjpaVersion>2.4.1</openjpaVersion>
+ <asm.version>5.0.4</asm.version>
+
<!-- restore when we will be able to use a derby in memory database -->
<redbackTestJdbcUrl>jdbc:derby:memory:users-test;create=true</redbackTestJdbcUrl>
<redbackTestJdbcDriver>org.apache.derby.jdbc.EmbeddedDriver</redbackTestJdbcDriver>
+
<sisu-inject-plexus.version>0.3.3</sisu-inject-plexus.version>
<plexus-digest.version>1.1</plexus-digest.version>
<plexus-expression-evaluator.version>2.1</plexus-expression-evaluator.version>
<artifactId>mail</artifactId>
<version>${javaxMailVersion}</version>
</dependency>
+
+
+ <!-- Maven related dependencies -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
- <version>${maven.version}</version>
+ <version>${maven3x.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
- <version>${maven.version}</version>
+ <version>${maven.artifact-manager.version}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-repository-metadata</artifactId>
+ <version>${maven3x.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-resolver-provider</artifactId>
+ <version>${maven3x.version}</version>
+ </dependency>
+
+ <!-- Eclipse aether -->
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ <version>${eclipse.aether.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-connector-file</artifactId>
+ <version>${eclipse.aether.version}</version>
+ </dependency>
+
+ <!-- Sonatype aether -->
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-api</artifactId>
- <version>${aether.version}</version>
+ <version>${sonatype.aether.version}</version>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-impl</artifactId>
- <version>${aether.version}</version>
+ <version>${sonatype.aether.version}</version>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-util</artifactId>
- <version>${aether.version}</version>
+ <version>${sonatype.aether.version}</version>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-connector-file</artifactId>
- <version>${aether.version}</version>
+ <version>${sonatype.aether.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-repository-metadata</artifactId>
- <version>${maven3x.version}</version>
- </dependency>
<!--
<dependency>
<groupId>org.codehaus.plexus</groupId>
<version>2.3.0</version>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>${asm.version}</version>
+ </dependency>
+
+
+
+
</dependencies>
</dependencyManagement>