}
else
{
- get( path, target, repository, managedRepository, wagonProxy, force );
+ target = get( path, target, repository, managedRepository, wagonProxy, force );
}
}
return target;
}
- private void get( String path, File target, ProxiedArtifactRepository repository,
+ /**
+ * @return the target File may not be same as the target argument, if a
+ * maven1 to maven2 path convertion occured.
+ */
+ private File get( String path, File target, ProxiedArtifactRepository repository,
ArtifactRepository managedRepository, ProxyInfo wagonProxy, boolean force )
throws ProxyException
{
if ( artifact != null )
{
+ target = new File( managedRepository.getBasedir(), managedRepository.pathOf( artifact ) );
+
ArtifactRepository artifactRepository = repository.getRepository();
// we use the release policy for tracking failures, but only check for updates on snapshots
// in case it previously failed and we've since found it
repository.clearFailure( path );
}
+ return target;
}
private void mergeMetadataFiles( File target, File metadataFile )
ArtifactRepositoryLayout legacyLayout =
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
- legacyManagedRepository = createRepository( "managed-repository", repoLocation );
+ legacyManagedRepository = createRepository( "managed-repository", repoLocation, legacyLayout );
File location = getTestFile( "src/test/repositories/proxied1" );
proxiedRepository1 = createRepository( "proxied1", location );
file.lastModified() );
}
+ public void testLegacyRequestConvertedToDefaultPathInManagedRepo()
+ throws Exception
+ {
+ // Check that a Maven1 legacy request is translated to a maven2 path in
+ // the managed repository.
+
+ String legacyPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
+ String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+ File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+ assertTrue( expectedFile.exists() );
+
+ File file = requestHandler.get( legacyPath, legacyProxiedRepositories, defaultManagedRepository );
+
+ assertEquals( "Check file matches", expectedFile, file );
+ }
+
+ public void testDefaultRequestConvertedToLegacyPathInManagedRepo()
+ throws Exception
+ {
+ // Check that a Maven2 default request is translated to a legacy path in
+ // the managed repository.
+
+ String legacyPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
+ String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+ File expectedFile = new File( legacyManagedRepository.getBasedir(), legacyPath );
+ assertTrue( expectedFile.exists() );
+
+ File file = requestHandler.get( path, proxiedRepositories, legacyManagedRepository );
+
+ assertEquals( "Check file matches", expectedFile, file );
+ }
+
private static Versioning getVersioning( List versions )
{
Versioning versioning = new Versioning();