mirror of https://github.com/apache/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
This commit is contained in:
parent
2e0b0bd17a
commit
26c39b527a
|
@ -10,6 +10,19 @@
|
|||
<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>
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
5
pom.xml
5
pom.xml
|
@ -223,6 +223,11 @@
|
|||
<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>
|
||||
|
|
Loading…
Reference in New Issue