summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2014-01-10 03:54:32 +0000
committerOlivier Lamy <olamy@apache.org>2014-01-10 03:54:32 +0000
commit7b2440ca48cd275002f43e1663aa75faf0ca57df (patch)
treecfde3ae71aabde3bcab5a0d07a4e8ac31d3f8e6b
parentaf42752e144d051c5bcfa2a6353c960c45dfef2a (diff)
downloadarchiva-7b2440ca48cd275002f43e1663aa75faf0ca57df.tar.gz
archiva-7b2440ca48cd275002f43e1663aa75faf0ca57df.zip
cleanup
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1557022 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java48
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java2
-rw-r--r--archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java2
3 files changed, 38 insertions, 14 deletions
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 197fc9712..3f050e3ab 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
@@ -146,13 +146,14 @@ public class Maven3DependencyTreeBuilder
return;
}
+ List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
+ Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>();
+
try
{
// MRM-1411
// TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
// handled there. It doesn't cache anything locally!
- List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
- Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>();
Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
@@ -179,7 +180,15 @@ public class Maven3DependencyTreeBuilder
}
// FIXME take care of relative path
- resolve( repository.getLocation(), groupId, artifactId, version, dependencyVisitor );
+ ResolveRequest resolveRequest = new ResolveRequest();
+ resolveRequest.dependencyVisitor = dependencyVisitor;
+ resolveRequest.localRepoDir = repository.getLocation();
+ resolveRequest.groupId = groupId;
+ resolveRequest.artifactId = artifactId;
+ resolveRequest.version = version;
+ resolveRequest.remoteRepositories = remoteRepositories;
+ resolveRequest.networkProxies = networkProxies;
+ resolve( resolveRequest );
}
@@ -197,24 +206,39 @@ public class Maven3DependencyTreeBuilder
return treeEntries;
}
+ private static class ResolveRequest
+ {
+ String localRepoDir, groupId, artifactId, version;
+
+ DependencyVisitor dependencyVisitor;
- private void resolve( String localRepoDir, String groupId, String artifactId, String version,
- DependencyVisitor dependencyVisitor )
+ List<RemoteRepository> remoteRepositories;
+
+ Map<String, NetworkProxy> networkProxies;
+
+ }
+
+
+ private void resolve( ResolveRequest resolveRequest )
{
RepositorySystem system = newRepositorySystem();
- RepositorySystemSession session = newRepositorySystemSession( system, localRepoDir );
+ RepositorySystemSession session = newRepositorySystemSession( system, resolveRequest.localRepoDir );
- org.sonatype.aether.artifact.Artifact artifact =
- new DefaultArtifact( groupId + ":" + artifactId + ":" + version );
+ org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(
+ resolveRequest.groupId + ":" + resolveRequest.artifactId + ":" + resolveRequest.version );
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot( new Dependency( artifact, "" ) );
- // add remote repositories ?
- collectRequest.addRepository( new org.sonatype.aether.repository.RemoteRepository( "fake", "default", "http://maven.apache.org" ) );
-
+ // add remote repositories
+ for ( RemoteRepository remoteRepository : resolveRequest.remoteRepositories )
+ {
+ collectRequest.addRepository(
+ new org.sonatype.aether.repository.RemoteRepository( remoteRepository.getId(), "default",
+ remoteRepository.getUrl() ) );
+ }
collectRequest.setRequestContext( "project" );
//collectRequest.addRepository( repo );
@@ -222,7 +246,7 @@ public class Maven3DependencyTreeBuilder
try
{
CollectResult collectResult = system.collectDependencies( session, collectRequest );
- collectResult.getRoot().accept( dependencyVisitor );
+ collectResult.getRoot().accept( resolveRequest.dependencyVisitor );
log.debug( "test" );
}
catch ( DependencyCollectionException e )
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 46602ac97..e9ed73077 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
@@ -223,7 +223,7 @@ public class Maven2RepositoryStorage
String id = readMetadataRequest.getProjectId() + "-" + artifactVersion + ".pom";
File file =
pathTranslator.toFile( basedir, readMetadataRequest.getNamespace(), readMetadataRequest.getProjectId(),
- artifactVersion, id );
+ readMetadataRequest.getProjectVersion(), id );
if ( !file.exists() )
{
diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
index 9a1f58a58..a46cbefd0 100644
--- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
+++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
@@ -342,7 +342,7 @@ public class Maven2RepositoryMetadataResolverTest
{
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(
new ReadMetadataRequest( TEST_REPO_ID, "org.apache", "apache", "5-SNAPSHOT" ) );
- MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
+ MavenProjectFacet facet = MavenProjectFacet.class.cast( metadata.getFacet( MavenProjectFacet.FACET_ID ) );
assertEquals( "pom", facet.getPackaging() );
assertEquals( "http://www.apache.org/", metadata.getUrl() );
assertNull( facet.getParent() );