]> source.dussan.org Git - archiva.git/commitdiff
o simple start to the repo app
authorJason van Zyl <jvanzyl@apache.org>
Thu, 15 Jun 2006 06:16:10 +0000 (06:16 +0000)
committerJason van Zyl <jvanzyl@apache.org>
Thu, 15 Jun 2006 06:16:10 +0000 (06:16 +0000)
  - 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

maven-repository-core/pom.xml
maven-repository-core/src/main/java/org/apache/maven/repository/DefaultRepositoryManager.java [new file with mode: 0644]
maven-repository-core/src/main/java/org/apache/maven/repository/RepositoryManager.java [new file with mode: 0644]
maven-repository-core/src/test/java/org/apache/maven/repository/RepositoryManagerTest.java [new file with mode: 0644]
pom.xml

index feb702fe306bc76782b31732da5603f5695112a8..be593d8ccc1ac4f09a756c7a90aacd54dd8a4894 100644 (file)
   <artifactId>maven-repository-core</artifactId>
   <name>Maven Repository Manager Core</name>
   <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.repository</groupId>
+      <artifactId>maven-repository-converter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.repository</groupId>
+      <artifactId>maven-repository-discovery</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.repository</groupId>
+      <artifactId>maven-repository-reports-standard</artifactId>
+    </dependency>    
+    <!-- Testing -->
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
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 (file)
index 0000000..d0940f0
--- /dev/null
@@ -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 (file)
index 0000000..e3baccb
--- /dev/null
@@ -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 (file)
index 0000000..d56740d
--- /dev/null
@@ -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 2d25fda0c50fd910320bd80ce75730a2b0d75c66..e9e7b18e30bec2881cacfc51313dde9d17bb8385 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <artifactId>maven-repository-configuration</artifactId>
         <version>${pom.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.maven.repository</groupId>
+        <artifactId>maven-repository-converter</artifactId>
+        <version>${pom.version}</version>
+      </dependency>      
     </dependencies>
   </dependencyManagement>
   <reporting>