aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins/maven2-repository/src
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2014-01-10 03:54:15 +0000
committerOlivier Lamy <olamy@apache.org>2014-01-10 03:54:15 +0000
commitaf42752e144d051c5bcfa2a6353c960c45dfef2a (patch)
tree2fbe716f21a0b6e808f531e255de48ca262643c7 /archiva-modules/plugins/maven2-repository/src
parent3a59b856d838f7c9c3eed20d65d3753c36ab57e5 (diff)
downloadarchiva-af42752e144d051c5bcfa2a6353c960c45dfef2a.tar.gz
archiva-af42752e144d051c5bcfa2a6353c960c45dfef2a.zip
when browsing we must be more relax to resolve dependencies especially with snapshot having released as parent pom
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1557021 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/maven2-repository/src')
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java2
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java53
2 files changed, 33 insertions, 22 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 30dcd3dff..197fc9712 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
@@ -213,7 +213,7 @@ public class Maven3DependencyTreeBuilder
collectRequest.setRoot( new Dependency( artifact, "" ) );
// add remote repositories ?
- //collectRequest.addRepository( )
+ collectRequest.addRepository( new org.sonatype.aether.repository.RemoteRepository( "fake", "default", "http://maven.apache.org" ) );
collectRequest.setRequestContext( "project" );
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 8dab2bfef..46602ac97 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
@@ -169,31 +169,35 @@ public class Maven2RepositoryStorage
{
ManagedRepository managedRepository =
managedRepositoryAdmin.getManagedRepository( readMetadataRequest.getRepositoryId() );
-
String artifactVersion = readMetadataRequest.getProjectVersion();
- if ( VersionUtil.isSnapshot(
- readMetadataRequest.getProjectVersion() ) ) // skygo trying to improve speed by honoring managed configuration MRM-1658
+ // olamy: in case of browsing via the ui we can mix repos (parent of a SNAPSHOT can come from release repo)
+ if ( !readMetadataRequest.isBrowsingRequest() )
{
- if ( managedRepository.isReleases() && !managedRepository.isSnapshots() )
+
+ if ( VersionUtil.isSnapshot(
+ artifactVersion ) ) // skygo trying to improve speed by honoring managed configuration MRM-1658
{
- throw new RepositoryStorageRuntimeException( "lookforsnaponreleaseonly",
- "managed repo is configured for release only" );
+ if ( managedRepository.isReleases() && !managedRepository.isSnapshots() )
+ {
+ throw new RepositoryStorageRuntimeException( "lookforsnaponreleaseonly",
+ "managed repo is configured for release only" );
+ }
}
- }
- else
- {
- if ( !managedRepository.isReleases() && managedRepository.isSnapshots() )
+ else
{
- throw new RepositoryStorageRuntimeException( "lookforsreleaseonsneponly",
- "managed repo is configured for snapshot only" );
+ if ( !managedRepository.isReleases() && managedRepository.isSnapshots() )
+ {
+ throw new RepositoryStorageRuntimeException( "lookforsreleaseonsneponly",
+ "managed repo is configured for snapshot only" );
+ }
}
}
File basedir = new File( managedRepository.getLocation() );
- if ( VersionUtil.isSnapshot( readMetadataRequest.getProjectVersion() ) )
+ if ( VersionUtil.isSnapshot( artifactVersion ) )
{
File metadataFile = pathTranslator.toFile( basedir, readMetadataRequest.getNamespace(),
- readMetadataRequest.getProjectId(),
- readMetadataRequest.getProjectVersion(), METADATA_FILENAME );
+ readMetadataRequest.getProjectId(), artifactVersion,
+ METADATA_FILENAME );
try
{
ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
@@ -219,7 +223,7 @@ public class Maven2RepositoryStorage
String id = readMetadataRequest.getProjectId() + "-" + artifactVersion + ".pom";
File file =
pathTranslator.toFile( basedir, readMetadataRequest.getNamespace(), readMetadataRequest.getProjectId(),
- readMetadataRequest.getProjectVersion(), id );
+ artifactVersion, id );
if ( !file.exists() )
{
@@ -258,6 +262,13 @@ public class Maven2RepositoryStorage
}
}
+ // That's a browsing request so we can a mix of SNAPSHOT and release artifacts (especially with snapshots which
+ // can have released parent pom
+ if ( readMetadataRequest.isBrowsingRequest() )
+ {
+ remoteRepositories.addAll( remoteRepositoryAdmin.getRemoteRepositories() );
+ }
+
ModelBuildingRequest req =
new DefaultModelBuildingRequest().setProcessPlugins( false ).setPomFile( file ).setTwoPhaseBuilding(
false ).setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
@@ -809,12 +820,12 @@ public class Maven2RepositoryStorage
filePath =
StringUtils.replace( filePath, artifactReference.getArtifactId() + "-" + artifactReference.getVersion(),
artifactReference.getArtifactId() + "-" + StringUtils.remove(
- artifactReference.getVersion(), "-" + VersionUtil.SNAPSHOT ) + "-" + timestamp + "-"
- + buildNumber );
+ artifactReference.getVersion(), "-" + VersionUtil.SNAPSHOT ) + "-" + timestamp
+ + "-" + buildNumber );
- throw new RelocationException(
- "/repository/" + managedRepositoryContent.getRepository().getId() +
- ( StringUtils.startsWith( filePath, "/" ) ? "" : "/" ) + filePath, RelocationException.RelocationType.TEMPORARY );
+ throw new RelocationException( "/repository/" + managedRepositoryContent.getRepository().getId() +
+ ( StringUtils.startsWith( filePath, "/" ) ? "" : "/" ) + filePath,
+ RelocationException.RelocationType.TEMPORARY );
}