MRM-224 Converting Maven 1.x plugins. We're simply making sure they are copied over with the right extension so that folks using an m2 repository for both m1 and m2 clients have something that works.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@475767 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2006-11-16 15:28:07 +00:00
parent fc775b6179
commit 4a2ab461c5
3 changed files with 44 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package org.apache.maven.archiva.converter;
import org.apache.maven.archiva.converter.transaction.FileTransaction;
import org.apache.maven.archiva.reporting.ReportingDatabase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
@ -90,6 +91,11 @@ public class DefaultRepositoryConverter
*/
private ModelConverter translator;
/**
* @plexus.requirement
*/
private ArtifactHandlerManager artifactHandlerManager;
/**
* @plexus.configuration default-value="false"
*/
@ -666,6 +672,11 @@ public class DefaultRepositoryConverter
{
File sourceFile = artifact.getFile();
if ( sourceFile.getAbsolutePath().indexOf( "/plugins/" ) > -1 )
{
artifact.setArtifactHandler( artifactHandlerManager.getArtifactHandler( "maven-plugin" ) );
}
File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
boolean result = true;

View File

@ -0,0 +1,7 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-foo-plugin</artifactId>
<version>1.0.0</version>
<packaging>maven-plugin</version>
</project>

View File

@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
/**
@ -404,6 +405,31 @@ public class RepositoryConverterTest
assertTrue( true );
}
public void testMavenOnePluginConversion()
throws Exception
{
Artifact artifact = createArtifact( "org.apache.maven.plugins", "maven-foo-plugin", "1.0", "1.0", "maven-plugin" );
artifact.setFile( new File( getBasedir(), "src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar" ) );
repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
// There is a warning but I can't figure out how to look at it. Eyeballing the results it appears
// the plugin is being coverted correctly.
//checkSuccess();
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
assertTrue( "Check artifact created", artifactFile.exists() );
assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) );
/*
The POM isn't needed for Maven 1.x plugins but the raw conversion for
artifact = createPomArtifact( artifact );
File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
File expectedPomFile = getTestFile( "src/test/expected-files/maven-foo-plugin-1.0.pom" );
assertTrue( "Check POM created", pomFile.exists() );
compareFiles( expectedPomFile, pomFile );
*/
}
public void testV3TimestampedSnapshotPomConvert()
throws IOException, RepositoryConversionException
{