From: Jason van Zyl Date: Thu, 15 Jun 2006 06:16:10 +0000 (+0000) Subject: o simple start to the repo app X-Git-Tag: archiva-0.9-alpha-1~811 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=26c39b527a0041dc6041e16e525c7ff77daec09c;p=archiva.git o simple start to the repo app - will integrate configuration next and a plexus app server front-end git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@414486 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/maven-repository-core/pom.xml b/maven-repository-core/pom.xml index feb702fe3..be593d8cc 100644 --- a/maven-repository-core/pom.xml +++ b/maven-repository-core/pom.xml @@ -10,6 +10,19 @@ maven-repository-core Maven Repository Manager Core + + org.apache.maven.repository + maven-repository-converter + + + org.apache.maven.repository + maven-repository-discovery + + + org.apache.maven.repository + maven-repository-reports-standard + + junit junit diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java b/maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java new file mode 100644 index 000000000..d0940f0b6 --- /dev/null +++ b/maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java @@ -0,0 +1,80 @@ +package org.apache.maven.repository; + +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.repository.converter.RepositoryConversionException; +import org.apache.maven.repository.converter.RepositoryConverter; +import org.apache.maven.repository.discovery.ArtifactDiscoverer; +import org.apache.maven.repository.reporting.ArtifactReporter; + +import java.io.File; +import java.util.List; +import java.net.MalformedURLException; + +/** + * @author Jason van Zyl + * @plexus.component + */ +public class DefaultRepositoryManager + implements RepositoryManager +{ + /** + * @plexus.requirement role="org.apache.maven.artifact.repository.discovery.ArtifactDiscoverer" role-hint="legacy" + */ + private ArtifactDiscoverer artifactDiscoverer; + + /** + * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" role-hint="legacy" + */ + private ArtifactRepositoryLayout legacyLayout; + + /** + * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" role-hint="default" + */ + private ArtifactRepositoryLayout defaultLayout; + + /** + * @plexus.requirement role="org.apache.maven.artifact.repository.ArtifactRepositoryFactory" + */ + private ArtifactRepositoryFactory artifactRepositoryFactory; + + /** + * @plexus.requirement role="org.apache.maven.repository.converter.ArtifactRepositoryFactory" + */ + private RepositoryConverter repositoryConverter; + + /** + * @plexus.requirement role="org.apache.maven.artifact.repository.reporter.ArtifactReporter" role-hint="default" + */ + private ArtifactReporter reporter; + + public void convertLegacyRepository( File legacyRepositoryDirectory, + File repositoryDirectory, + boolean includeSnapshots ) + throws RepositoryConversionException + { + ArtifactRepository legacyRepository; + + ArtifactRepository repository; + + try + { + legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy", + legacyRepositoryDirectory.toURL().toString(), + legacyLayout, null, null ); + + repository = artifactRepositoryFactory.createArtifactRepository( "default", + legacyRepositoryDirectory.toURL().toString(), + defaultLayout, null, null ); + } + catch ( MalformedURLException e ) + { + throw new RepositoryConversionException( "Error convering legacy repository.", e ); + } + + List legacyArtifacts = artifactDiscoverer.discoverArtifacts( legacyRepository, null, includeSnapshots ); + + repositoryConverter.convert( legacyArtifacts, repository, reporter ); + } +} diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/RepositoryManager.java b/maven-repository-core/src/main/java/org/apache/maven/repository/RepositoryManager.java new file mode 100644 index 000000000..e3baccb12 --- /dev/null +++ b/maven-repository-core/src/main/java/org/apache/maven/repository/RepositoryManager.java @@ -0,0 +1,29 @@ +package org.apache.maven.repository; + +import org.apache.maven.repository.converter.RepositoryConversionException; + +import java.io.File; + +/** + * @author Jason van Zyl + */ +public interface RepositoryManager +{ + /** + * Role of the Repository Manager + */ + String ROLE = RepositoryManager.class.getName(); + + /** + * Convert a legacy repository to a modern repository. This means a Maven 1.x repository + * using v3 POMs to a Maven 2.x repository using v4.0.0 POMs. + * + * @param legacyRepositoryDirectory + * @param repositoryDirectory + * @throws RepositoryConversionException + */ + void convertLegacyRepository( File legacyRepositoryDirectory, + File repositoryDirectory, + boolean includeSnapshots ) + throws RepositoryConversionException; +} diff --git a/maven-repository-core/src/test/java/org/apache/maven/repository/RepositoryManagerTest.java b/maven-repository-core/src/test/java/org/apache/maven/repository/RepositoryManagerTest.java new file mode 100644 index 000000000..d56740db4 --- /dev/null +++ b/maven-repository-core/src/test/java/org/apache/maven/repository/RepositoryManagerTest.java @@ -0,0 +1,16 @@ +package org.apache.maven.repository; + +import org.codehaus.plexus.PlexusTestCase; + +/** + * @author Jason van Zyl + */ +public class RepositoryManagerTest + extends PlexusTestCase +{ + public void testLegacyRepositoryConversion() + throws Exception + { + RepositoryManager rm = (RepositoryManager) lookup( RepositoryManager.ROLE ); + } +} diff --git a/pom.xml b/pom.xml index 2d25fda0c..e9e7b18e3 100644 --- a/pom.xml +++ b/pom.xml @@ -223,6 +223,11 @@ maven-repository-configuration ${pom.version} + + org.apache.maven.repository + maven-repository-converter + ${pom.version} +