diff options
author | Olivier Lamy <olamy@apache.org> | 2012-03-11 23:58:01 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-03-11 23:58:01 +0000 |
commit | cf74f31f832b0a175b5063299f9abd19349967a3 (patch) | |
tree | 6c451dc52ac8fc3b014e2f33928aee61629f035a /archiva-modules/plugins/maven2-repository/src/main | |
parent | f2557bd4765f0e6e63c5acc3c97923ae026ba489 (diff) | |
download | archiva-cf74f31f832b0a175b5063299f9abd19349967a3.tar.gz archiva-cf74f31f832b0a175b5063299f9abd19349967a3.zip |
[MRM-1567] Artifact data incomplete.
move MavenMetadataReader to a new module to avoid cyclic dependency.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299489 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/maven2-repository/src/main')
3 files changed, 48 insertions, 11 deletions
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java index 1ba491b4e..417788f59 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java @@ -186,8 +186,6 @@ public class DefaultDependencyTreeBuilder return; } - File basedir = new File( repository.getLocation() ); - try { // MRM-1411 @@ -216,7 +214,7 @@ public class DefaultDependencyTreeBuilder } Model model = buildProject( - new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories, networkProxies, + new RepositoryModelResolver( repository, pathTranslator, wagonFactory, remoteRepositories, networkProxies, repository ), groupId, artifactId, version ); Map managedVersions = createManagedVersionMap( model ); 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 4e70d48f5..5d9a21016 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 @@ -148,11 +148,11 @@ public class Maven2RepositoryStorage { try { - ManagedRepository repositoryConfiguration = managedRepositoryAdmin.getManagedRepository( repoId ); + ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repoId ); String artifactVersion = projectVersion; - File basedir = new File( repositoryConfiguration.getLocation() ); + File basedir = new File( managedRepository.getLocation() ); if ( VersionUtil.isSnapshot( projectVersion ) ) { File metadataFile = @@ -234,8 +234,8 @@ public class Maven2RepositoryStorage // MRM-1411 req.setModelResolver( - new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories, networkProxies, - repositoryConfiguration ) ); + new RepositoryModelResolver( managedRepository, pathTranslator, wagonFactory, remoteRepositories, 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 2bbde57c1..d62512f86 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 @@ -23,8 +23,10 @@ import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.common.utils.VersionUtil; -import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +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.model.SnapshotVersion; import org.apache.archiva.proxy.common.WagonFactory; import org.apache.archiva.proxy.common.WagonFactoryException; import org.apache.archiva.xml.XMLException; @@ -72,6 +74,8 @@ public class RepositoryModelResolver // key/value: remote repo ID/network proxy Map<String, NetworkProxy> networkProxyMap; + private ManagedRepository managedRepository; + public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator ) { this.basedir = basedir; @@ -79,11 +83,11 @@ public class RepositoryModelResolver this.pathTranslator = pathTranslator; } - public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator, WagonFactory wagonFactory, - List<RemoteRepository> remoteRepositories, + public RepositoryModelResolver( ManagedRepository managedRepository, RepositoryPathTranslator pathTranslator, + WagonFactory wagonFactory, List<RemoteRepository> remoteRepositories, Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository ) { - this( basedir, pathTranslator ); + this( new File( managedRepository.getLocation() ), pathTranslator ); this.wagonFactory = wagonFactory; @@ -104,6 +108,41 @@ public class RepositoryModelResolver if ( !model.exists() ) { + + // is a SNAPSHOT ? + if ( StringUtils.contains( version, "SNAPSHOT" ) ) + { + // reading metadata if there + File mavenMetadata = new File( model.getParent(), METADATA_FILENAME ); + if ( mavenMetadata.exists() ) + { + try + { + ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( mavenMetadata ); + SnapshotVersion snapshotVersion = archivaRepositoryMetadata.getSnapshotVersion(); + if ( snapshotVersion != null ) + { + String lastVersion = snapshotVersion.getTimestamp(); + int buildNumber = snapshotVersion.getBuildNumber(); + String snapshotPath = + StringUtils.replaceChars( groupId, '.', '/' ) + '/' + artifactId + '/' + version + '/' + + artifactId + '-' + StringUtils.remove( version, "-SNAPSHOT" ) + '-' + lastVersion + + '-' + buildNumber + ".pom"; + model = new File( basedir, snapshotPath ); + //model = pathTranslator.toFile( basedir, groupId, artifactId, lastVersion, filename ); + if ( model.exists() ) + { + return new FileModelSource( model ); + } + } + } + catch ( XMLException e ) + { + log.warn( "fail to read {}, {}", mavenMetadata.getAbsolutePath(), e.getCause() ); + } + } + } + for ( RemoteRepository remoteRepository : remoteRepositories ) { try |