aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2018-10-28 13:04:30 +0100
committerMartin Stockhammer <martin_s@apache.org>2018-10-28 13:04:30 +0100
commitd39977c41348cde01f3f54bd22c06ae696aab7b9 (patch)
tree08d116f43fa6b9e1c13d364d61277a40d3c54151 /archiva-modules/plugins
parent24ee701d1daee202e799b5ca17f9dff19d398c6e (diff)
downloadarchiva-d39977c41348cde01f3f54bd22c06ae696aab7b9.tar.gz
archiva-d39977c41348cde01f3f54bd22c06ae696aab7b9.zip
Fixing dependencies and adapting to new lib versions
Diffstat (limited to 'archiva-modules/plugins')
-rw-r--r--archiva-modules/plugins/maven2-repository/pom.xml11
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java1
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java3
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java119
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/pom.xml9
-rw-r--r--archiva-modules/plugins/stage-repository-merge/pom.xml7
6 files changed, 132 insertions, 18 deletions
diff --git a/archiva-modules/plugins/maven2-repository/pom.xml b/archiva-modules/plugins/maven2-repository/pom.xml
index a1fc76686..07cfd1821 100644
--- a/archiva-modules/plugins/maven2-repository/pom.xml
+++ b/archiva-modules/plugins/maven2-repository/pom.xml
@@ -99,8 +99,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
- <version>3.3.9</version>
+ <artifactId>maven-resolver-provider</artifactId>
</dependency>
<!--
@@ -124,13 +123,11 @@
<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>
@@ -225,6 +222,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<plugins>
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
index f9e441454..0b8f38dce 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
@@ -256,6 +256,7 @@ public class Maven3DependencyTreeBuilder
}
+
}
private RepositorySystem newRepositorySystem()
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
index e8ff5e8f6..b3b420f29 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
@@ -75,6 +75,7 @@ import org.apache.maven.model.building.ModelBuildingRequest;
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;
@@ -291,7 +292,7 @@ public class Maven2RepositoryStorage
// MRM-1411
req.setModelResolver(
new RepositoryModelResolver( managedRepository, pathTranslator, wagonFactory, remoteRepositories,
- networkProxies, managedRepository ) );
+ networkProxies, managedRepository ));
Model model;
try
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java
index b2fd1220f..e5aea4ce3 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java
@@ -21,6 +21,8 @@ package org.apache.archiva.metadata.repository.storage.maven2;
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;
@@ -34,6 +36,7 @@ import org.apache.archiva.repository.RepositoryCredentials;
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;
@@ -42,6 +45,10 @@ 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.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;
@@ -50,6 +57,26 @@ import org.apache.maven.wagon.authentication.AuthenticationException;
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;
@@ -63,6 +90,10 @@ import java.util.Map;
public class RepositoryModelResolver
implements ModelResolver
{
+
+ private RepositorySystemSession session;
+ private VersionRangeResolver versionRangeResolver;
+
private Path basedir;
private RepositoryPathTranslator pathTranslator;
@@ -77,6 +108,8 @@ public class RepositoryModelResolver
private static final String METADATA_FILENAME = "maven-metadata.xml";
+ private DefaultServiceLocator locator;
+
// key/value: remote repo ID/network proxy
Map<String, NetworkProxy> networkProxyMap;
@@ -91,7 +124,7 @@ public class RepositoryModelResolver
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 );
@@ -104,6 +137,45 @@ public class RepositoryModelResolver
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
@@ -163,18 +235,41 @@ public class RepositoryModelResolver
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,
@@ -237,7 +332,7 @@ public class RepositoryModelResolver
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
diff --git a/archiva-modules/plugins/metadata-store-jcr/pom.xml b/archiva-modules/plugins/metadata-store-jcr/pom.xml
index 299a29ac8..c53149a93 100644
--- a/archiva-modules/plugins/metadata-store-jcr/pom.xml
+++ b/archiva-modules/plugins/metadata-store-jcr/pom.xml
@@ -179,7 +179,14 @@
<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>
diff --git a/archiva-modules/plugins/stage-repository-merge/pom.xml b/archiva-modules/plugins/stage-repository-merge/pom.xml
index 4023b24a1..d8719f8e6 100644
--- a/archiva-modules/plugins/stage-repository-merge/pom.xml
+++ b/archiva-modules/plugins/stage-repository-merge/pom.xml
@@ -118,6 +118,13 @@
<artifactId>xercesImpl</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<plugins>