You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/02/24 01:02:45 UTC
svn commit: r747226 [1/2] - in /maven/mercury/trunk: ./
mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/
mercury-ant-tasks/src/main/resources/org/apache/maven/mercury/ant/tasks/
mercury-ant-tasks/src/site/apt/ mercury-it/src/test/jav...
Author: ogusakov
Date: Tue Feb 24 00:02:44 2009
New Revision: 747226
URL: http://svn.apache.org/viewvc?rev=747226&view=rev
Log:
[MERCURY-93] - removed mandatory repository ID, cleaning up ant tasks, PlexusMercury
Added:
maven/mercury/trunk/mercury-repo/mercury-repo-api/src/test/java/org/apache/maven/mercury/repository/api/AbstractRepositoryTest.java (with props)
maven/mercury/trunk/mercury-transport/mercury-transport-api/src/main/java/org/apache/maven/mercury/transport/api/Messages.properties (with props)
Removed:
maven/mercury/trunk/mercury-plexus/src/test/java/
Modified:
maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Auth.java
maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Repo.java
maven/mercury/trunk/mercury-ant-tasks/src/main/resources/org/apache/maven/mercury/ant/tasks/Messages.properties
maven/mercury/trunk/mercury-ant-tasks/src/site/apt/howto.apt
maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java
maven/mercury/trunk/mercury-it/src/test/resources/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.xml
maven/mercury/trunk/mercury-plexus/pom.xml
maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/PlexusMercury.java
maven/mercury/trunk/mercury-plexus/src/main/resources/org/apache/maven/mercury/plexus/Messages.properties
maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java
maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/flat/LocalRepositoryFlat.java
maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryM2.java
maven/mercury/trunk/mercury-repo/mercury-repo-local-map/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryMap.java
maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/Messages.properties
maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryM2.java
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/test/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReaderTest.java
maven/mercury/trunk/mercury-transport/mercury-transport-api/src/main/java/org/apache/maven/mercury/transport/api/Server.java
maven/mercury/trunk/pom.xml
Modified: maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Auth.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Auth.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Auth.java (original)
+++ maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Auth.java Tue Feb 24 00:02:44 2009
@@ -58,6 +58,11 @@
public Auth( String auth )
{
+ setSource( auth );
+ }
+
+ public void setSource( String auth )
+ {
if( auth == null )
throw new IllegalArgumentException( LANG.getMessage( "auth.null.auth" ) );
@@ -74,7 +79,17 @@
else
paramStr = auth.substring( colon+1 );
- StringTokenizer st = new StringTokenizer( paramStr, "," );
+ if( METHOD_BASIC.regionMatches( 0, _method, 0, METHOD_BASIC.length() ) )
+ {
+ StringTokenizer st = new StringTokenizer( paramStr, "/" );
+
+ if( st.countTokens() != 2 )
+ throw new IllegalArgumentException( LANG.getMessage( "auth.bad.basic.params" ) );
+
+ _name = st.nextToken();
+
+ _pass = st.nextToken();
+ }
}
public void setName( String name )
Modified: maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Repo.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Repo.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Repo.java (original)
+++ maven/mercury/trunk/mercury-ant-tasks/src/main/java/org/apache/maven/mercury/ant/tasks/Repo.java Tue Feb 24 00:02:44 2009
@@ -181,9 +181,15 @@
}
}
- public void setAuthentication()
+ public void setAuthentication( String auth )
{
+ Auth a = new Auth( auth );
+ String authId = "auth."+System.currentTimeMillis()+"." + (int)(Math.random()*10000);
+
+ getProject().addReference( authId, a );
+
+ setAuthid( authId );
}
public void setAuthid( String authid )
Modified: maven/mercury/trunk/mercury-ant-tasks/src/main/resources/org/apache/maven/mercury/ant/tasks/Messages.properties
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-ant-tasks/src/main/resources/org/apache/maven/mercury/ant/tasks/Messages.properties?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-ant-tasks/src/main/resources/org/apache/maven/mercury/ant/tasks/Messages.properties (original)
+++ maven/mercury/trunk/mercury-ant-tasks/src/main/resources/org/apache/maven/mercury/ant/tasks/Messages.properties Tue Feb 24 00:02:44 2009
@@ -53,3 +53,4 @@
auth.null.auth=null auth supplied. Cannot process it.
auth.no.method=auth '{0}' does not provide a method, general format 'method:method_specific_args'
+auth.bad.basic.params=basic authentication has format: name/password - cannot parse the supplied data.
\ No newline at end of file
Modified: maven/mercury/trunk/mercury-ant-tasks/src/site/apt/howto.apt
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-ant-tasks/src/site/apt/howto.apt?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-ant-tasks/src/site/apt/howto.apt (original)
+++ maven/mercury/trunk/mercury-ant-tasks/src/site/apt/howto.apt Tue Feb 24 00:02:44 2009
@@ -55,7 +55,7 @@
>
<classpath>
<deps>
- <dependency name="asm:asm:3.0"/>
+ <dependency id="asm:asm:3.0"/>
</deps>
</classpath>
</javac>
@@ -71,7 +71,7 @@
>
<classpath>
<deps>
- <dependency name="t:t:1.0::pom" pom="${basedir}/t-1.0.pom"/>
+ <dependency source="${basedir}/t-1.0.pom"/>
</deps>
</classpath>
</javac>
Modified: maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java (original)
+++ maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java Tue Feb 24 00:02:44 2009
@@ -51,331 +51,346 @@
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
/**
- *
- *
* @author Oleg Gusakov
* @version $Id: DefaultPlexusMercuryTest.java 723125 2008-12-03 23:19:50Z ogusakov $
*/
public class DefaultPlexusMercuryTest
-extends PlexusTestCase
+ extends PlexusTestCase
{
- PlexusMercury pm;
+ PlexusMercury pm;
- RemoteRepositoryM2 remoteRepo;
- LocalRepositoryM2 localRepo;
-
- List<Repository> repos;
-
- Artifact a;
-
- protected static final String keyId = "0EDB5D91141BC4F2";
-
- protected static final String secretKeyFile = "/pgp/secring.gpg";
- protected static final String publicKeyFile = "/pgp/pubring.gpg";
- protected static final String secretKeyPass = "testKey82";
-
- String artifactCoord = "org.apache.maven.mercury:mercury-repo-virtual:1.0.0-alpha-2-SNAPSHOT";
-
- private File localRepoDir;
-
- public static final String SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_USER = "plexus.mercury.test.user";
- static String remoteServerUser = System.getProperty( SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_USER, "admin" );
-
- public static final String SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_PASS = "plexus.mercury.test.pass";
- static String remoteServerPass = System.getProperty( SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_PASS, "admin123" );
-
- PgpStreamVerifierFactory pgpRF;
- PgpStreamVerifierFactory pgpWF;
-
- SHA1VerifierFactory sha1F;
- HashSet<StreamVerifierFactory> vFacSha1;
-
- VirtualRepositoryReader vrr;
-
- PlexusContainer plexus;
-
- HttpTestServer _jetty;
- String _port;
- File _remoteRepoBase = new File("./target/test-classes/remoteRepo");
-
- //-------------------------------------------------------------------------------------
-// @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- // prep. Artifact
- File artifactBinary = File.createTempFile( "test-repo-writer", "bin" );
- FileUtil.writeRawData( getClass().getResourceAsStream( "/maven-core-2.0.9.jar" ), artifactBinary );
-
- a = new DefaultArtifact( new ArtifactBasicMetadata("org.apache.maven.mercury:mercury-core:2.0.9") );
-
- a.setPomBlob( FileUtil.readRawData( getClass().getResourceAsStream( "/maven-core-2.0.9.pom" ) ) );
- a.setFile( artifactBinary );
-
- // prep Repository
- pm = getContainer().lookup( PlexusMercury.class );
-
- pgpRF = pm.createPgpReaderFactory( true, true, getClass().getResourceAsStream( publicKeyFile ) );
- pgpWF = pm.createPgpWriterFactory( true, true, getClass().getResourceAsStream( secretKeyFile ), keyId, secretKeyPass );
-
- sha1F = new SHA1VerifierFactory( true, false );
-
- _jetty = new HttpTestServer( _remoteRepoBase, "/repo" );
- _jetty.start();
- _port = String.valueOf( _jetty.getPort() );
-
- String remoteServerUrl = "http://localhost:"+_port+"/repo";
- remoteRepo = pm.constructRemoteRepositoryM2( "testRepo"
- , new URL(remoteServerUrl), remoteServerUser, remoteServerPass
- , null, null, null
- , null, FileUtil.vSet( pgpRF, sha1F )
- , null, FileUtil.vSet( pgpWF, sha1F )
- );
-
-// localRepoDir = File.createTempFile( "local-", "-repo" );
- localRepoDir = new File( "./target/local" );
- FileUtil.delete( localRepoDir );
- localRepoDir.mkdirs();
-//
-// localRepo = new LocalRepositoryM2( "testLocalRepo", localRepoDir, pm.findDependencyProcessor() );
-
- localRepo = pm.constructLocalRepositoryM2( "testLocal", localRepoDir, null, null, null, null );
-
- repos = new ArrayList<Repository>();
- repos.add( localRepo );
- repos.add( remoteRepo );
-
- vrr = new VirtualRepositoryReader(repos);
-
- }
- //-------------------------------------------------------------------------------------
- @Override
- protected void tearDown()
- throws Exception
- {
- super.tearDown();
-
- if( _jetty != null )
+ RemoteRepositoryM2 remoteRepo;
+
+ LocalRepositoryM2 localRepo;
+
+ List<Repository> repos;
+
+ Artifact a;
+
+ protected static final String keyId = "0EDB5D91141BC4F2";
+
+ protected static final String secretKeyFile = "/pgp/secring.gpg";
+
+ protected static final String publicKeyFile = "/pgp/pubring.gpg";
+
+ protected static final String secretKeyPass = "testKey82";
+
+ String artifactCoord = "org.apache.maven.mercury:mercury-repo-virtual:1.0.0-alpha-2-SNAPSHOT";
+
+ private File localRepoDir;
+
+ public static final String SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_USER = "plexus.mercury.test.user";
+
+ static String remoteServerUser = System.getProperty( SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_USER, "admin" );
+
+ public static final String SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_PASS = "plexus.mercury.test.pass";
+
+ static String remoteServerPass = System.getProperty( SYSTEM_PARAMETER_PLEXUS_MERCURY_TEST_PASS, "admin123" );
+
+ PgpStreamVerifierFactory pgpRF;
+
+ PgpStreamVerifierFactory pgpWF;
+
+ SHA1VerifierFactory sha1F;
+
+ HashSet<StreamVerifierFactory> vFacSha1;
+
+ VirtualRepositoryReader vrr;
+
+ PlexusContainer plexus;
+
+ HttpTestServer _jetty;
+
+ String _port;
+
+ File _remoteRepoBase = new File( "./target/test-classes/remoteRepo" );
+
+ // -------------------------------------------------------------------------------------
+ // @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ // prep. Artifact
+ File artifactBinary = File.createTempFile( "test-repo-writer", "bin" );
+ FileUtil.writeRawData( getClass().getResourceAsStream( "/maven-core-2.0.9.jar" ), artifactBinary );
+
+ a = new DefaultArtifact( new ArtifactBasicMetadata( "org.apache.maven.mercury:mercury-core:2.0.9" ) );
+
+ a.setPomBlob( FileUtil.readRawData( getClass().getResourceAsStream( "/maven-core-2.0.9.pom" ) ) );
+ a.setFile( artifactBinary );
+
+ // prep Repository
+ pm = getContainer().lookup( PlexusMercury.class );
+
+ pgpRF = pm.createPgpReaderFactory( true, true, getClass().getResourceAsStream( publicKeyFile ) );
+ pgpWF =
+ pm.createPgpWriterFactory( true, true, getClass().getResourceAsStream( secretKeyFile ), keyId,
+ secretKeyPass );
+
+ sha1F = new SHA1VerifierFactory( true, false );
+
+ _jetty = new HttpTestServer( _remoteRepoBase, "/repo" );
+ _jetty.start();
+ _port = String.valueOf( _jetty.getPort() );
+
+ String remoteServerUrl = "http://localhost:" + _port + "/repo";
+ remoteRepo =
+ pm.constructRemoteRepositoryM2( "testRepo", new URL( remoteServerUrl ), remoteServerUser, remoteServerPass,
+ null, null, null, null, FileUtil.vSet( pgpRF, sha1F ), null,
+ FileUtil.vSet( pgpWF, sha1F ) );
+
+ // localRepoDir = File.createTempFile( "local-", "-repo" );
+ localRepoDir = new File( "./target/local" );
+ FileUtil.delete( localRepoDir );
+ localRepoDir.mkdirs();
+ //
+ // localRepo = new LocalRepositoryM2( "testLocalRepo", localRepoDir, pm.findDependencyProcessor() );
+
+ localRepo = pm.constructLocalRepositoryM2( "testLocal", localRepoDir, null, null, null, null );
+
+ repos = new ArrayList<Repository>();
+ repos.add( localRepo );
+ repos.add( remoteRepo );
+
+ vrr = new VirtualRepositoryReader( repos );
+
+ }
+
+ // -------------------------------------------------------------------------------------
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+
+ if ( _jetty != null )
+ try
+ {
+ _jetty.stop();
+ _jetty.destroy();
+ }
+ finally
+ {
+ _jetty = null;
+ }
+ }
+
+ // ----------------------------------------------------------------------------------------------
+ private static boolean assertHasArtifact( List<ArtifactMetadata> res, String gav )
+ {
+ ArtifactMetadata gavMd = new ArtifactMetadata( gav );
+
+ for ( ArtifactBasicMetadata md : res )
+ if ( md.sameGAV( gavMd ) )
+ return true;
+
+ return false;
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testFindDepProcessorWithHint()
+ throws RepositoryException, ComponentLookupException
+ {
+ DependencyProcessor dp = null;
+
+ dp = pm.findDependencyProcessor( "default" );
+
+ assertNotNull( dp );
+
+ assertTrue( MavenDependencyProcessor.class.isAssignableFrom( dp.getClass() ) );
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testFindDepProcessor()
+ // should run after the previous one
+ throws RepositoryException, ComponentLookupException
+ {
+ DependencyProcessor dp = null;
+
+ dp = pm.findDependencyProcessor();
+
+ assertNotNull( dp );
+
+ assertTrue( MavenDependencyProcessor.class.isAssignableFrom( dp.getClass() ) );
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testWrite()
+ throws RepositoryException
+ {
+ pm.write( localRepo, a );
+
+ File af = new File( localRepoDir, "org/apache/maven/mercury/mercury-core/2.0.9/mercury-core-2.0.9.jar" );
+
+ assertTrue( af.exists() );
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testReadVersions()
+ throws RepositoryException
+ {
+ ArtifactMetadata bmd = new ArtifactMetadata( artifactCoord );
+
+ List<ArtifactBasicMetadata> res = pm.readVersions( repos, bmd );
+
+ assertNotNull( res );
+
+ assertFalse( res.isEmpty() );
+
+ ArtifactBasicMetadata a = res.get( 0 );
+
+ assertEquals( "1.0.0-alpha-2-20081104.001322-2", a.getVersion() );
+
+ List<Artifact> al = pm.read( repos, a );
+
+ assertNotNull( al );
+
+ assertFalse( al.isEmpty() );
+
+ assertEquals( 1, al.size() );
+
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testRead()
+ throws RepositoryException
+ {
+ ArtifactMetadata bmd = new ArtifactMetadata( artifactCoord );
+
+ Collection<Artifact> res = pm.read( repos, bmd );
+
+ assertNotNull( res );
+
+ assertFalse( res.isEmpty() );
+
+ Artifact a = res.toArray( new Artifact[1] )[0];
+
+ assertNotNull( a );
+
+ File fBin = a.getFile();
+
+ assertNotNull( fBin );
+
+ assertTrue( fBin.exists() );
+
+ byte[] pomBytes = a.getPomBlob();
+
+ assertNotNull( pomBytes );
+
+ assertTrue( pomBytes.length > 10 );
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testReadNonExistent()
+ {
+ ArtifactMetadata bmd = new ArtifactMetadata( "does.not:exist:1.0" );
+
+ Collection<Artifact> res = null;
+ try
+ {
+ res = pm.read( repos, bmd );
+ }
+ catch ( RepositoryException e )
+ {
+ fail( "reading non-existent artifact should not raise an exception, got " + e.getMessage() );
+ }
+
+ assertNull( res );
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testResolveNonExistent()
+ {
+ ArtifactMetadata bmd = new ArtifactMetadata( "does.not:exist:1.0" );
+
+ Collection<ArtifactMetadata> res = null;
try
{
- _jetty.stop();
- _jetty.destroy();
+ res = pm.resolve( repos, ArtifactScopeEnum.compile, bmd );
}
- finally
+ catch ( RepositoryException e )
{
- _jetty = null;
+ fail( "reading non-existent artifact should not raise an exception, got " + e.getMessage() );
}
- }
- //----------------------------------------------------------------------------------------------
- private static boolean assertHasArtifact( List<ArtifactMetadata> res, String gav )
- {
- ArtifactMetadata gavMd = new ArtifactMetadata(gav);
-
- for( ArtifactBasicMetadata md : res )
- if( md.sameGAV( gavMd ) )
- return true;
-
- return false;
- }
- //-------------------------------------------------------------------------------------
- public void testFindDepProcessorWithHint()
- throws RepositoryException, ComponentLookupException
- {
- DependencyProcessor dp = null;
-
- dp = pm.findDependencyProcessor("default");
-
- assertNotNull( dp );
-
- assertTrue( MavenDependencyProcessor.class.isAssignableFrom( dp.getClass() ) );
- }
- //-------------------------------------------------------------------------------------
- public void testFindDepProcessor() // should run after the previous one
- throws RepositoryException, ComponentLookupException
- {
- DependencyProcessor dp = null;
-
- dp = pm.findDependencyProcessor();
-
- assertNotNull( dp );
-
- assertTrue( MavenDependencyProcessor.class.isAssignableFrom( dp.getClass() ) );
- }
- //-------------------------------------------------------------------------------------
- public void testWrite()
- throws RepositoryException
- {
- pm.write( localRepo, a );
-
- File af = new File( localRepoDir, "org/apache/maven/mercury/mercury-core/2.0.9/mercury-core-2.0.9.jar" );
-
- assertTrue( af.exists() );
- }
- //-------------------------------------------------------------------------------------
- public void testReadVersions()
- throws RepositoryException
- {
- ArtifactMetadata bmd = new ArtifactMetadata(artifactCoord);
-
- List<ArtifactBasicMetadata> res = pm.readVersions( repos, bmd );
-
- assertNotNull( res );
-
- assertFalse( res.isEmpty() );
-
- ArtifactBasicMetadata a = res.get( 0 );
-
- assertEquals( "1.0.0-alpha-2-20081104.001322-2", a.getVersion() );
-
- List<Artifact> al = pm.read( repos, a );
-
- assertNotNull( al );
-
- assertFalse( al.isEmpty() );
-
- assertEquals( 1, al.size() );
-
- }
- //-------------------------------------------------------------------------------------
- public void testRead()
- throws RepositoryException
- {
- ArtifactMetadata bmd = new ArtifactMetadata(artifactCoord);
-
- Collection<Artifact> res = pm.read( repos, bmd );
-
- assertNotNull( res );
-
- assertFalse( res.isEmpty() );
-
- Artifact a = res.toArray( new Artifact[1] )[0];
-
- assertNotNull( a );
-
- File fBin = a.getFile();
-
- assertNotNull( fBin );
-
- assertTrue( fBin.exists() );
-
- byte [] pomBytes = a.getPomBlob();
-
- assertNotNull( pomBytes );
-
- assertTrue( pomBytes.length > 10 );
- }
- //-------------------------------------------------------------------------------------
- public void testReadNonExistent()
- {
- ArtifactMetadata bmd = new ArtifactMetadata( "does.not:exist:1.0" );
-
- Collection<Artifact> res = null;
- try
- {
- res = pm.read( repos, bmd );
- }
- catch ( RepositoryException e )
- {
- fail( "reading non-existent artifact should not raise an exception, got "+e.getMessage() );
- }
-
- assertNull( res );
- }
- //-------------------------------------------------------------------------------------
- public void testResolveNonExistent()
- {
- ArtifactMetadata bmd = new ArtifactMetadata( "does.not:exist:1.0" );
-
- Collection<ArtifactMetadata> res = null;
- try
- {
- res = pm.resolve( repos, ArtifactScopeEnum.compile, bmd );
- }
- catch ( RepositoryException e )
- {
- fail( "reading non-existent artifact should not raise an exception, got "+e.getMessage() );
- }
- }
- //-------------------------------------------------------------------------------------
- public void testResolve()
- throws Exception
- {
- Server central = new Server( "central", new URL("http://repo1.maven.org/maven2") );
-// Server central = new Server( "central", new URL("http://repository.sonatype.org/content/groups/public") );
-
- repos.add( new RemoteRepositoryM2(central, pm.findDependencyProcessor()) );
-
- String artifactId = "asm:asm-xml:3.0";
-
- List<ArtifactMetadata> res = pm.resolve( repos, ArtifactScopeEnum.compile, new ArtifactQueryList(artifactId), null, null );
-
- System.out.println("Resolved as "+res);
-
- assertEquals( 4, res.size() );
-
- assertTrue( assertHasArtifact( res, "asm:asm-xml:3.0" ) );
- assertTrue( assertHasArtifact( res, "asm:asm-util:3.0" ) );
- assertTrue( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
- assertTrue( assertHasArtifact( res, "asm:asm:3.0" ) );
- }
- //-------------------------------------------------------------------------------------
- @SuppressWarnings("unchecked")
- public void testResolveWithExclusion()
- throws Exception
- {
-// Server central = new Server( "central", new URL("http://repo1.maven.org/maven2") );
-// Server central = new Server( "central", new URL("http://repository.sonatype.org/content/groups/public") );
-
-// repos.add( new RemoteRepositoryM2(central, pm.findDependencyProcessor()) );
-
- String artifactId = "asm:asm-xml:3.0";
-
- List<ArtifactMetadata> res = pm.resolve( repos
- , ArtifactScopeEnum.compile
- , new ArtifactQueryList(artifactId)
- , null
- , new ArtifactExclusionList("asm:asm:3.0")
- );
-
- System.out.println("Resolved as "+res);
-
- assertEquals( 3, res.size() );
-
- assertTrue( assertHasArtifact( res, "asm:asm-xml:3.0" ) );
- assertTrue( assertHasArtifact( res, "asm:asm-util:3.0" ) );
- assertTrue( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
- assertFalse( assertHasArtifact( res, "asm:asm:3.0" ) );
- }
- //-------------------------------------------------------------------------------------
- @SuppressWarnings("unchecked")
- public void testResolveWithInclusion()
- throws Exception
- {
-// Server central = new Server( "central", new URL("http://repo1.maven.org/maven2") );
-// Server central = new Server( "central", new URL("http://repository.sonatype.org/content/groups/public") );
-
-// repos.add( new RemoteRepositoryM2(central, pm.findDependencyProcessor()) );
-
- String artifactId = "asm:asm-xml:3.0";
-
- List<ArtifactMetadata> res = pm.resolve( repos
- , ArtifactScopeEnum.compile
- , new ArtifactQueryList(artifactId)
- , new ArtifactInclusionList("asm:asm-xml:3.0","asm:asm-util:3.0")
- , null
- );
-
- System.out.println("Resolved as "+res);
-
- assertEquals( 2, res.size() );
-
- assertTrue( assertHasArtifact( res, "asm:asm-xml:3.0" ) );
- assertTrue( assertHasArtifact( res, "asm:asm-util:3.0" ) );
- assertFalse( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
- assertFalse( assertHasArtifact( res, "asm:asm:3.0" ) );
- }
- //-------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------
+ }
+
+ // -------------------------------------------------------------------------------------
+ public void testResolve()
+ throws Exception
+ {
+ Server central = new Server( "central", new URL( "http://repo1.maven.org/maven2" ) );
+ // Server central = new Server( "central", new URL("http://repository.sonatype.org/content/groups/public") );
+
+ repos.add( new RemoteRepositoryM2( central, pm.findDependencyProcessor() ) );
+
+ String artifactId = "asm:asm-xml:3.0";
+
+ List<ArtifactMetadata> res =
+ pm.resolve( repos, ArtifactScopeEnum.compile, new ArtifactQueryList( artifactId ), null, null );
+
+ System.out.println( "Resolved as " + res );
+
+ assertEquals( 4, res.size() );
+
+ assertTrue( assertHasArtifact( res, "asm:asm-xml:3.0" ) );
+ assertTrue( assertHasArtifact( res, "asm:asm-util:3.0" ) );
+ assertTrue( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
+ assertTrue( assertHasArtifact( res, "asm:asm:3.0" ) );
+ }
+
+ // -------------------------------------------------------------------------------------
+ @SuppressWarnings( "unchecked" )
+ public void testResolveWithExclusion()
+ throws Exception
+ {
+ // Server central = new Server( "central", new URL("http://repo1.maven.org/maven2") );
+ // Server central = new Server( "central", new URL("http://repository.sonatype.org/content/groups/public") );
+
+ // repos.add( new RemoteRepositoryM2(central, pm.findDependencyProcessor()) );
+
+ String artifactId = "asm:asm-xml:3.0";
+
+ List<ArtifactMetadata> res =
+ pm.resolve( repos, ArtifactScopeEnum.compile, new ArtifactQueryList( artifactId ), null,
+ new ArtifactExclusionList( "asm:asm:3.0" ) );
+
+ System.out.println( "Resolved as " + res );
+
+ assertEquals( 3, res.size() );
+
+ assertTrue( assertHasArtifact( res, "asm:asm-xml:3.0" ) );
+ assertTrue( assertHasArtifact( res, "asm:asm-util:3.0" ) );
+ assertTrue( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
+ assertFalse( assertHasArtifact( res, "asm:asm:3.0" ) );
+ }
+
+ // -------------------------------------------------------------------------------------
+ @SuppressWarnings( "unchecked" )
+ public void testResolveWithInclusion()
+ throws Exception
+ {
+ // Server central = new Server( "central", new URL("http://repo1.maven.org/maven2") );
+ // Server central = new Server( "central", new URL("http://repository.sonatype.org/content/groups/public") );
+
+ // repos.add( new RemoteRepositoryM2(central, pm.findDependencyProcessor()) );
+
+ String artifactId = "asm:asm-xml:3.0";
+
+ List<ArtifactMetadata> res =
+ pm.resolve( repos, ArtifactScopeEnum.compile, new ArtifactQueryList( artifactId ),
+ new ArtifactInclusionList( "asm:asm-xml:3.0", "asm:asm-util:3.0" ), null );
+
+ System.out.println( "Resolved as " + res );
+
+ assertEquals( 2, res.size() );
+
+ assertTrue( assertHasArtifact( res, "asm:asm-xml:3.0" ) );
+ assertTrue( assertHasArtifact( res, "asm:asm-util:3.0" ) );
+ assertFalse( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
+ assertFalse( assertHasArtifact( res, "asm:asm:3.0" ) );
+ }
+ // -------------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------------
}
Modified: maven/mercury/trunk/mercury-it/src/test/resources/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.xml
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-it/src/test/resources/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.xml?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-it/src/test/resources/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.xml (original)
+++ maven/mercury/trunk/mercury-it/src/test/resources/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.xml Tue Feb 24 00:02:44 2009
@@ -9,6 +9,20 @@
</component>
<component>
+ <role>org.apache.maven.mercury.builder.api.DependencyProcessor</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.mercury.MavenDependencyProcessor</implementation>
+ <isolated-realm>false</isolated-realm>
+ </component>
+
+ <component>
+ <role>org.apache.maven.mercury.builder.api.DependencyProcessor</role>
+ <role-hint>default</role-hint>
+ <implementation>org.apache.maven.mercury.MavenDependencyProcessor</implementation>
+ <isolated-realm>false</isolated-realm>
+ </component>
+
+ <component>
<role>org.apache.maven.mercury.plexus.PlexusMercury</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.mercury.plexus.DefaultPlexusMercury</implementation>
@@ -16,16 +30,10 @@
<requirements>
<requirement>
<role>org.apache.maven.mercury.builder.api.DependencyProcessor</role>
- <role-hint>maven</role-hint>
- <field-name>dependencyProcessor</field-name>
- </requirement>
- <requirement>
- <role>org.codehaus.plexus.PlexusContainer</role>
- <role-hint>default</role-hint>
- <field-name>plexus</field-name>
+ <field-name>_dependencyProcessors</field-name>
</requirement>
</requirements>
</component>
-
+
</components>
</plexus>
Modified: maven/mercury/trunk/mercury-plexus/pom.xml
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/pom.xml?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/pom.xml (original)
+++ maven/mercury/trunk/mercury-plexus/pom.xml Tue Feb 24 00:02:44 2009
@@ -64,6 +64,12 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ </dependency>
+
</dependencies>
<build>
Modified: maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java (original)
+++ maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java Tue Feb 24 00:02:44 2009
@@ -58,10 +58,9 @@
import org.apache.maven.mercury.transport.api.Credentials;
import org.apache.maven.mercury.transport.api.Server;
import org.apache.maven.mercury.util.Util;
-import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Configuration;
import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.lang.DefaultLanguage;
import org.codehaus.plexus.lang.Language;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -72,268 +71,288 @@
* @author Oleg Gusakov
*/
-@Component( role=PlexusMercury.class )
+@Component( role = PlexusMercury.class )
public class DefaultPlexusMercury
-extends AbstractLogEnabled
-implements PlexusMercury
+ extends AbstractLogEnabled
+ implements PlexusMercury
{
- private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( DefaultPlexusMercury.class );
- private static final Language LANG = new DefaultLanguage( DefaultPlexusMercury.class );
-
- @Requirement( hint="maven" )
- DependencyProcessor dependencyProcessor;
-
- @Requirement
- PlexusContainer plexus;
-
- //---------------------------------------------------------------
- public DependencyProcessor findDependencyProcessor( String hint )
- throws RepositoryException
- {
- if( dependencyProcessor != null )
- return dependencyProcessor;
-
- if( plexus == null )
- throw new RepositoryException( LANG.getMessage( "no.plexus.injected" ) );
+ private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( DefaultPlexusMercury.class );
+
+ private static final Language LANG = new DefaultLanguage( DefaultPlexusMercury.class );
- DependencyProcessor dp = null;
+ private List<Repository> _repos;
- try
+ @Configuration(name="defaultDependencyProcessorHint",value="maven")
+ String _defaultDpHint = "maven";
+
+ @Requirement(role=DependencyProcessor.class)
+ private Map< String, DependencyProcessor > _dependencyProcessors;
+
+ // ---------------------------------------------------------------
+ public DependencyProcessor findDependencyProcessor( String hint )
+ throws RepositoryException
{
- dp = plexus.lookup( DependencyProcessor.class, hint );
-
- return dp;
- }
- catch( ComponentLookupException e )
- {
- throw new RepositoryException( LANG.getMessage( "no.dep.processor.injected", hint, e.getMessage() ) );
- }
- }
- //---------------------------------------------------------------
- public DependencyProcessor findDependencyProcessor()
- throws RepositoryException
- {
- return findDependencyProcessor( "default" );
- }
- //---------------------------------------------------------------
- public RemoteRepositoryM2 constructRemoteRepositoryM2(
- String id
- , URL serverUrl, String serverUser, String serverPass
- , URL proxyUrl, String proxyUser, String proxyPass
- , Set<StreamObserverFactory> readerStreamObservers
- , Set<StreamVerifierFactory> readerStreamVerifiers
- , Set<StreamObserverFactory> writerStreamObservers
- , Set<StreamVerifierFactory> writerStreamVerifiers
- )
- throws RepositoryException
- {
- Server server = new Server( id, serverUrl );
-
- server.setReaderStreamObserverFactories( readerStreamObservers );
- server.setReaderStreamVerifierFactories( readerStreamVerifiers );
- server.setWriterStreamObserverFactories( writerStreamObservers );
- server.setWriterStreamVerifierFactories( writerStreamVerifiers );
-
- if( serverUser != null )
+ DependencyProcessor dp = null;
+
+ if ( _dependencyProcessors != null )
+ dp = _dependencyProcessors.get( hint );
+
+ if( dp == null)
+ throw new RepositoryException( LANG.getMessage( "no.dep.processor.injected", hint ) );
+
+ return dp;
+ }
+
+ // ---------------------------------------------------------------
+ public DependencyProcessor findDependencyProcessor()
+ throws RepositoryException
{
- Credentials cred = new Credentials( serverUser, serverPass );
- server.setServerCredentials( cred );
+ return findDependencyProcessor( _defaultDpHint );
}
-
- if( proxyUrl != null )
+
+ // ---------------------------------------------------------------
+ public RemoteRepositoryM2 constructRemoteRepositoryM2( String id, URL serverUrl, String serverUser,
+ String serverPass, URL proxyUrl, String proxyUser,
+ String proxyPass,
+ Set<StreamObserverFactory> readerStreamObservers,
+ Set<StreamVerifierFactory> readerStreamVerifiers,
+ Set<StreamObserverFactory> writerStreamObservers,
+ Set<StreamVerifierFactory> writerStreamVerifiers )
+ throws RepositoryException
{
- server.setProxy( proxyUrl );
-
- if( proxyUser != null )
- {
- Credentials cred = new Credentials( proxyUser, proxyPass );
- server.setProxyCredentials( cred );
- }
+ Server server = new Server( id, serverUrl );
+
+ server.setReaderStreamObserverFactories( readerStreamObservers );
+ server.setReaderStreamVerifierFactories( readerStreamVerifiers );
+ server.setWriterStreamObserverFactories( writerStreamObservers );
+ server.setWriterStreamVerifierFactories( writerStreamVerifiers );
+
+ if ( serverUser != null )
+ {
+ Credentials cred = new Credentials( serverUser, serverPass );
+ server.setServerCredentials( cred );
+ }
+
+ if ( proxyUrl != null )
+ {
+ server.setProxy( proxyUrl );
+
+ if ( proxyUser != null )
+ {
+ Credentials cred = new Credentials( proxyUser, proxyPass );
+ server.setProxyCredentials( cred );
+ }
+ }
+
+ RemoteRepositoryM2 repo = new RemoteRepositoryM2( id, server, findDependencyProcessor() );
+
+ return repo;
}
-
- RemoteRepositoryM2 repo = new RemoteRepositoryM2( id, server, findDependencyProcessor() );
- return repo;
- }
- //---------------------------------------------------------------
- public LocalRepositoryM2 constructLocalRepositoryM2(
- String id,
- File rootDir,
- Set<StreamObserverFactory> readerStreamObservers,
- Set<StreamVerifierFactory> readerStreamVerifiers,
- Set<StreamObserverFactory> writerStreamObservers,
- Set<StreamVerifierFactory> writerStreamVerifiers
- )
- throws RepositoryException
- {
- Server server;
- try
+ // ---------------------------------------------------------------
+ public LocalRepositoryM2 constructLocalRepositoryM2( String id, File rootDir,
+ Set<StreamObserverFactory> readerStreamObservers,
+ Set<StreamVerifierFactory> readerStreamVerifiers,
+ Set<StreamObserverFactory> writerStreamObservers,
+ Set<StreamVerifierFactory> writerStreamVerifiers )
+ throws RepositoryException
{
- server = new Server( id, rootDir.toURL() );
+ Server server;
+ try
+ {
+ server = new Server( id, rootDir.toURL() );
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new RepositoryException( e );
+ }
+
+ server.setReaderStreamObserverFactories( readerStreamObservers );
+ server.setReaderStreamVerifierFactories( readerStreamVerifiers );
+ server.setWriterStreamObserverFactories( writerStreamObservers );
+ server.setWriterStreamVerifierFactories( writerStreamVerifiers );
+
+ LocalRepositoryM2 repo = new LocalRepositoryM2( server, findDependencyProcessor() );
+
+ return repo;
}
- catch( MalformedURLException e )
+
+ // ---------------------------------------------------------------
+ public void write( Repository repo, Artifact... artifacts )
+ throws RepositoryException
{
- throw new RepositoryException(e);
+ write( repo, Arrays.asList( artifacts ) );
}
-
- server.setReaderStreamObserverFactories( readerStreamObservers );
- server.setReaderStreamVerifierFactories( readerStreamVerifiers );
- server.setWriterStreamObserverFactories( writerStreamObservers );
- server.setWriterStreamVerifierFactories( writerStreamVerifiers );
-
- LocalRepositoryM2 repo = new LocalRepositoryM2( server, findDependencyProcessor() );
-
- return repo;
- }
-
- //---------------------------------------------------------------
- public void write( Repository repo, Artifact... artifacts )
- throws RepositoryException
- {
- write( repo, Arrays.asList( artifacts ) );
- }
-
- public void write(
- Repository repo,
- Collection<Artifact> artifacts )
- throws RepositoryException
- {
- if( repo == null )
- throw new RepositoryException( LANG.getMessage( "null.repo" ) );
-
- RepositoryWriter wr = repo.getWriter();
-
- wr.writeArtifacts( artifacts );
-
- }
- //---------------------------------------------------------------
- public List<Artifact> read( List<Repository> repos, ArtifactBasicMetadata... artifacts )
- throws RepositoryException
- {
- return read( repos, Arrays.asList( artifacts ) );
- }
- //---------------------------------------------------------------
- public List<Artifact> read( List<Repository> repos, List<? extends ArtifactBasicMetadata> artifacts )
- throws RepositoryException
- {
- if( Util.isEmpty( repos ) )
- throw new RepositoryException( LANG.getMessage( "null.repo" ) );
-
- VirtualRepositoryReader vr = new VirtualRepositoryReader( repos );
-
- ArtifactResults ar = vr.readArtifacts( artifacts );
-
- if( ar == null || !ar.hasResults() )
- return null;
- if( ar.hasExceptions() && LOG.isWarnEnabled() )
- LOG.info( ar.getExceptions().toString() );
-
- if( !ar.hasResults() )
- return null;
+ public void write( Repository repo, Collection<Artifact> artifacts )
+ throws RepositoryException
+ {
+ if ( repo == null )
+ throw new RepositoryException( LANG.getMessage( "null.repo" ) );
- Map<ArtifactBasicMetadata, List<Artifact>> am = ar.getResults();
-
- List<Artifact> al = new ArrayList<Artifact>();
- for( Map.Entry<ArtifactBasicMetadata, List<Artifact>> e : am.entrySet() )
- al.addAll( e.getValue() );
+ RepositoryWriter wr = repo.getWriter();
- return al;
-
- }
+ wr.writeArtifacts( artifacts );
- public List<Artifact> read( List<Repository> repo, ArtifactMetadata... artifacts )
- throws RepositoryException
- {
- return read( repo, Arrays.asList( artifacts ) );
- }
- //---------------------------------------------------------------
- public PgpStreamVerifierFactory createPgpReaderFactory(
- boolean lenient,
- boolean sufficient,
- InputStream pubRing )
- throws StreamVerifierException
- {
- return new PgpStreamVerifierFactory(
- new StreamVerifierAttributes(PgpStreamVerifierFactory.DEFAULT_EXTENSION,lenient,sufficient )
- , pubRing
- );
- }
-
- //---------------------------------------------------------------
- public PgpStreamVerifierFactory createPgpWriterFactory(
- boolean lenient,
- boolean sufficient,
- InputStream secRing,
- String keyId,
- String keyPass )
- throws StreamVerifierException
- {
- return new PgpStreamVerifierFactory(
- new StreamVerifierAttributes(PgpStreamVerifierFactory.DEFAULT_EXTENSION,lenient,sufficient )
- , secRing , keyId, keyPass
- );
- }
-
- public List<ArtifactMetadata> resolve( List<Repository> repos, ArtifactScopeEnum scope, ArtifactMetadata metadata )
- throws RepositoryException
- {
- return resolve( repos, scope, new ArtifactQueryList( metadata ), null, null );
- }
-
- //---------------------------------------------------------------
- public List<ArtifactMetadata> resolve( List<Repository> repos
- , ArtifactScopeEnum scope
- , ArtifactQueryList artifacts
- , ArtifactInclusionList inclusions
- , ArtifactExclusionList exclusions
- )
- throws RepositoryException
- {
- if( Util.isEmpty( artifacts ) || artifacts.isEmpty() )
- throw new IllegalArgumentException( LANG.getMessage( "no.artifacts" ) );
-
- try
+ }
+
+ // ---------------------------------------------------------------
+ public List<Artifact> read( List<Repository> repos, ArtifactBasicMetadata... artifacts )
+ throws RepositoryException
{
- DependencyBuilder depBuilder = DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL, repos );
+ return read( repos, Arrays.asList( artifacts ) );
+ }
- List<ArtifactMetadata> res = depBuilder.resolveConflicts( scope, artifacts, inclusions, exclusions );
-
- return res;
+ // ---------------------------------------------------------------
+ public List<Artifact> read( List<Repository> repos, List<? extends ArtifactBasicMetadata> artifacts )
+ throws RepositoryException
+ {
+ if ( Util.isEmpty( repos ) )
+ throw new RepositoryException( LANG.getMessage( "null.repo" ) );
+
+ VirtualRepositoryReader vr = new VirtualRepositoryReader( repos );
+
+ ArtifactResults ar = vr.readArtifacts( artifacts );
+
+ if ( ar == null || !ar.hasResults() )
+ return null;
+
+ if ( ar.hasExceptions() && LOG.isWarnEnabled() )
+ LOG.info( ar.getExceptions().toString() );
+
+ if ( !ar.hasResults() )
+ return null;
+
+ Map<ArtifactBasicMetadata, List<Artifact>> am = ar.getResults();
+
+ List<Artifact> al = new ArrayList<Artifact>();
+ for ( Map.Entry<ArtifactBasicMetadata, List<Artifact>> e : am.entrySet() )
+ al.addAll( e.getValue() );
+
+ return al;
+
+ }
+
+ public List<Artifact> read( List<Repository> repo, ArtifactMetadata... artifacts )
+ throws RepositoryException
+ {
+ return read( repo, Arrays.asList( artifacts ) );
+ }
+
+ // ---------------------------------------------------------------
+ public PgpStreamVerifierFactory createPgpReaderFactory( boolean lenient, boolean sufficient, InputStream pubRing )
+ throws StreamVerifierException
+ {
+ return new PgpStreamVerifierFactory( new StreamVerifierAttributes( PgpStreamVerifierFactory.DEFAULT_EXTENSION,
+ lenient, sufficient ), pubRing );
+ }
+
+ // ---------------------------------------------------------------
+ public PgpStreamVerifierFactory createPgpWriterFactory( boolean lenient, boolean sufficient, InputStream secRing,
+ String keyId, String keyPass )
+ throws StreamVerifierException
+ {
+ return new PgpStreamVerifierFactory( new StreamVerifierAttributes( PgpStreamVerifierFactory.DEFAULT_EXTENSION,
+ lenient, sufficient ), secRing, keyId,
+ keyPass );
+ }
+
+ public List<ArtifactMetadata> resolve( List<Repository> repos, ArtifactScopeEnum scope, ArtifactMetadata metadata )
+ throws RepositoryException
+ {
+ return resolve( repos, scope, new ArtifactQueryList( metadata ), null, null );
+ }
+
+ // ---------------------------------------------------------------
+ public List<ArtifactMetadata> resolve( List<Repository> repos, ArtifactScopeEnum scope,
+ ArtifactQueryList artifacts, ArtifactInclusionList inclusions,
+ ArtifactExclusionList exclusions )
+ throws RepositoryException
+ {
+ if ( Util.isEmpty( artifacts ) || artifacts.isEmpty() )
+ throw new IllegalArgumentException( LANG.getMessage( "no.artifacts" ) );
+
+ try
+ {
+ DependencyBuilder depBuilder =
+ DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL, repos );
+
+ List<ArtifactMetadata> res = depBuilder.resolveConflicts( scope, artifacts, inclusions, exclusions );
+
+ return res;
+ }
+ catch ( MetadataTreeException e )
+ {
+ throw new RepositoryException( e );
+ }
+ }
+
+ // ---------------------------------------------------------------
+ /**
+ * get all available versions of for the artifact query.
+ *
+ * @param repo repository instance to search
+ * @param query metadata query to search by
+ * @return list of found version metadatas
+ * @throws PlexusMercuryException
+ */
+ public List<ArtifactBasicMetadata> readVersions( List<Repository> repos, ArtifactBasicMetadata query )
+ throws RepositoryException
+ {
+ VirtualRepositoryReader vr = new VirtualRepositoryReader( repos );
+ List<ArtifactBasicMetadata> q = new ArrayList<ArtifactBasicMetadata>( 1 );
+ q.add( query );
+
+ ArtifactBasicResults res = vr.readVersions( q );
+
+ if ( res == null )
+ return null;
+
+ if ( res.hasExceptions() && LOG.isWarnEnabled() )
+ LOG.warn( res.getExceptions().toString() );
+
+ return res.getResult( query );
+ }
+ // ---------------------------------------------------------------
+ public List<Repository> constructRepositories( String localDir, String... urls )
+ throws RepositoryException
+ {
+ try
+ {
+ int nRemote = urls == null ? 0 : urls.length;
+
+ List<Repository> repos = new ArrayList<Repository>( 1 + nRemote );
+
+ DependencyProcessor dp = findDependencyProcessor();
+
+ LocalRepositoryM2 lr = new LocalRepositoryM2( new File(localDir), dp );
+
+ repos.add( lr );
+
+ if( nRemote > 0 )
+ for( String url : urls )
+ {
+ RemoteRepositoryM2 rr = new RemoteRepositoryM2( url, dp );
+
+ repos.add( rr );
+ }
+
+ return repos;
+
+ }
+ catch( Exception e )
+ {
+ throw new RepositoryException( e );
+ }
}
- catch( MetadataTreeException e )
+ // ---------------------------------------------------------------
+ public PlexusMercury setRepositories( String localDir, String... urls )
+ throws RepositoryException
{
- throw new RepositoryException( e );
+ _repos = constructRepositories( localDir, urls );
+
+ return this;
}
- }
- //---------------------------------------------------------------
- /**
- * get all available versions of for the artifact query.
- *
- * @param repo repository instance to search
- * @param query metadata query to search by
- * @return list of found version metadatas
- * @throws PlexusMercuryException
- */
- public List<ArtifactBasicMetadata> readVersions( List<Repository> repos
- , ArtifactBasicMetadata query
- )
- throws RepositoryException
- {
- VirtualRepositoryReader vr = new VirtualRepositoryReader( repos );
- List<ArtifactBasicMetadata> q = new ArrayList<ArtifactBasicMetadata>(1);
- q.add( query );
-
- ArtifactBasicResults res = vr.readVersions( q );
-
- if( res == null )
- return null;
-
- if( res.hasExceptions() && LOG.isWarnEnabled() )
- LOG.warn( res.getExceptions().toString() );
-
- return res.getResult( query );
- }
- //---------------------------------------------------------------
- //---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
}
Modified: maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/PlexusMercury.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/PlexusMercury.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/PlexusMercury.java (original)
+++ maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/PlexusMercury.java Tue Feb 24 00:02:44 2009
@@ -49,8 +49,6 @@
*/
public interface PlexusMercury
{
- public static String ROLE = PlexusMercury.class.getName();
-
/**
* lookup dependency processor in plexus and return the "default" implementation
*
@@ -154,6 +152,28 @@
, Set<StreamVerifierFactory> writerStreamVerifiers
)
throws RepositoryException;
+
+ /**
+ * construct a list of repositories from strings. First string is local dir, all others - remote URLs
+ *
+ * @param localDir
+ * @param urls varargs list of urls for remote repos
+ * @return repository list
+ * @throws PlexusMercuryException
+ */
+ public List<Repository> constructRepositories( String localDir , String... urls )
+ throws RepositoryException;
+
+ /**
+ * construct a list of repositories from strings and retains them for future use by this instance of PlexusMercury
+ *
+ * @param localDir
+ * @param urls varargs list of urls for remote repos
+ * @return repository list
+ * @throws PlexusMercuryException
+ */
+ public PlexusMercury setRepositories( String localDir , String... urls )
+ throws RepositoryException;
/**
* write (deploy) given Artifact(s) to the repository
Modified: maven/mercury/trunk/mercury-plexus/src/main/resources/org/apache/maven/mercury/plexus/Messages.properties
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/main/resources/org/apache/maven/mercury/plexus/Messages.properties?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/main/resources/org/apache/maven/mercury/plexus/Messages.properties (original)
+++ maven/mercury/trunk/mercury-plexus/src/main/resources/org/apache/maven/mercury/plexus/Messages.properties Tue Feb 24 00:02:44 2009
@@ -19,4 +19,4 @@
null.repo=cannot do anything with null repository
no.artifacts=no Artifacts supplied - null or empty collection
no.plexus.injected=plexus framework did not inject plexus container, cannot proceed
-no.dep.processor.injected=cannot find a {0} DependencyProcessor in plexus framework, cannot proceed. Error {1}
+no.dep.processor.injected=cannot find a {0} DependencyProcessor in plexus framework, cannot proceed
Modified: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java Tue Feb 24 00:02:44 2009
@@ -18,6 +18,8 @@
*/
package org.apache.maven.mercury.repository.api;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -29,7 +31,6 @@
import org.codehaus.plexus.lang.DefaultLanguage;
import org.codehaus.plexus.lang.Language;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
@@ -46,207 +47,267 @@
*/
/**
- * parent of all repositories and also a helper class for registration of readers/writers
- *
- *
+ * parent of all repositories and also a helper class for registration of readers/writers
*/
public abstract class AbstractRepository
-implements Repository
+ implements Repository
{
- private static final Language LANG = new DefaultLanguage( AbstractRepository.class );
- //---------------------------------------------------------------------------
- public static final String DEFAULT_REMOTE_READ_PROTOCOL = "http";
- public static final String DEFAULT_REMOTE_WRITE_PROTOCOL = "http";
-
- public static final String DEFAULT_LOCAL_READ_PROTOCOL = "file";
- public static final String DEFAULT_LOCAL_WRITE_PROTOCOL = "file";
-
- public static final String DEFAULT_REPOSITORY_TYPE = "m2";
-
- private String id;
-
- private String defaultReadProtocol = DEFAULT_REMOTE_READ_PROTOCOL;
-
- private String defaultWriteProtocol = DEFAULT_REMOTE_WRITE_PROTOCOL;
- //---------------------------------------------------------------------------
- private static Map< String, RepositoryReaderFactory > readerRegistry = Collections.synchronizedMap( new HashMap<String, RepositoryReaderFactory>(4) );
- private static Map< String, RepositoryWriterFactory > writerRegistry = Collections.synchronizedMap( new HashMap<String, RepositoryWriterFactory>(4) );
- //---------------------------------------------------------------------------
- protected String type = DEFAULT_REPOSITORY_TYPE;
-
- protected QualityRange repositoryQualityRange = QualityRange.ALL;
-
- protected QualityRange versionRangeQualityRange = QualityRange.ALL;
-
- protected DependencyProcessor dependencyProcessor;
-
- protected Server server;
- //---------------------------------------------------------------------------
- public AbstractRepository( String id, String type )
- {
- this.id = id;
- this.type = type;
- }
- //---------------------------------------------------------------------------
- public String getId()
- {
- return id;
- }
- //---------------------------------------------------------------------------
- public QualityRange getRepositoryQualityRange()
- {
- return repositoryQualityRange;
- }
- //---------------------------------------------------------------------------
- public void setRepositoryQualityRange(
- QualityRange repositoryQualityRange )
- {
- this.repositoryQualityRange = repositoryQualityRange;
- }
- //---------------------------------------------------------------------------
- public QualityRange getVersionRangeQualityRange()
- {
- return versionRangeQualityRange;
- }
- //---------------------------------------------------------------------------
- public void setVersionRangeQualityRange( QualityRange versionRangeQualityRange )
- {
- this.versionRangeQualityRange = versionRangeQualityRange;
- }
- //---------------------------------------------------------------------------
- public String getDefaultReadProtocol()
- {
- return defaultReadProtocol;
- }
- //---------------------------------------------------------------------------
- public void setDefaultReadProtocol( String defaultReadProtocol )
- {
- this.defaultReadProtocol = defaultReadProtocol;
- }
- //---------------------------------------------------------------------------
- public String getDefaultWriteProtocol()
- {
- return defaultWriteProtocol;
- }
- //---------------------------------------------------------------------------
- public void setDefaultWriteProtocol( String defaultWriteProtocol )
- {
- this.defaultWriteProtocol = defaultWriteProtocol;
- }
- //---------------------------------------------------------------------------
- public static void register( String type, RepositoryReaderFactory readerFactory )
- throws IllegalArgumentException
- {
- if( type == null || type.length() < 1 )
- throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
-
- if( readerFactory == null )
- throw new IllegalArgumentException( LANG.getMessage( "null.reader.factory" ) );
-
- readerRegistry.put( type, readerFactory );
- }
- //---------------------------------------------------------------------------
- public static void register( String type, RepositoryWriterFactory writerFactory )
- throws IllegalArgumentException
- {
- if( type == null || type.length() < 1 )
- throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
-
- if( writerFactory == null )
- throw new IllegalArgumentException( LANG.getMessage( "null.writer.factory" ) );
-
- writerRegistry.put( type, writerFactory );
- }
- //---------------------------------------------------------------------------
- public static void unregisterReader( String type )
- throws IllegalArgumentException
- {
- if( type == null || type.length() < 1 )
- throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
-
- readerRegistry.remove( type );
- }
- //---------------------------------------------------------------------------
- public static void unregisterWriter( String type )
- throws IllegalArgumentException
- {
- if( type == null || type.length() < 1 )
- throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
-
- writerRegistry.remove( type );
- }
- //---------------------------------------------------------------------------
- public static RepositoryReader getReader( String type, Repository repo, DependencyProcessor mdProcessor )
- throws IllegalArgumentException, RepositoryException
- {
- if( type == null || type.length() < 1 )
- throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
-
- if( repo == null )
- throw new IllegalArgumentException( LANG.getMessage( "null.reader.repo" ) );
-
- RepositoryReaderFactory rf = readerRegistry.get( type );
-
- if( rf == null )
- throw new RepositoryException( LANG.getMessage( "null.reader.factory.found" ) );
-
- return rf.getReader( repo, mdProcessor );
- }
- //---------------------------------------------------------------------------
- public static RepositoryWriter getWriter( String type, Repository repo )
- throws IllegalArgumentException, RepositoryException
- {
- if( type == null || type.length() < 1 )
- throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
-
- if( repo == null )
- throw new IllegalArgumentException( LANG.getMessage( "null.writer.repo" ) );
-
- RepositoryWriterFactory wf = writerRegistry.get( type );
-
- if( wf == null )
- throw new RepositoryException( LANG.getMessage( "null.writer.factory.found" ) );
-
- return wf.getWriter( repo );
- }
- //---------------------------------------------------------------------------
- public boolean isSnapshots()
- {
- return repositoryQualityRange.isAcceptedQuality( Quality.SNAPSHOT_QUALITY );
- }
- //---------------------------------------------------------------------------
- public boolean isReleases()
- {
- return repositoryQualityRange.isAcceptedQuality( Quality.RELEASE_QUALITY );
- }
- //---------------------------------------------------------------------------
- public boolean isAcceptedQuality( Quality quality )
- {
- return repositoryQualityRange.isAcceptedQuality( quality );
- }
- //---------------------------------------------------------------------------
- public boolean hasServer()
- {
- return server != null;
- }
- //---------------------------------------------------------------------------
- public Server getServer()
- {
- return server;
- }
- //---------------------------------------------------------------------------
- public boolean hasDependencyProcessor()
- {
- return dependencyProcessor == null;
- }
- public DependencyProcessor getDependencyProcessor()
- {
- return dependencyProcessor;
- }
- public void setDependencyProcessor( DependencyProcessor dependencyProcessor )
- {
- this.dependencyProcessor = dependencyProcessor;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
+ private static final Language LANG = new DefaultLanguage( AbstractRepository.class );
+
+ // ---------------------------------------------------------------------------
+ public static final String DEFAULT_REMOTE_READ_PROTOCOL = "http";
+
+ public static final String DEFAULT_REMOTE_WRITE_PROTOCOL = "http";
+
+ public static final String DEFAULT_LOCAL_READ_PROTOCOL = "file";
+
+ public static final String DEFAULT_LOCAL_WRITE_PROTOCOL = "file";
+
+ public static final String DEFAULT_REPOSITORY_TYPE = "m2";
+
+ private String id;
+
+ private String defaultReadProtocol = DEFAULT_REMOTE_READ_PROTOCOL;
+
+ private String defaultWriteProtocol = DEFAULT_REMOTE_WRITE_PROTOCOL;
+
+ // ---------------------------------------------------------------------------
+ private static Map<String, RepositoryReaderFactory> readerRegistry =
+ Collections.synchronizedMap( new HashMap<String, RepositoryReaderFactory>( 4 ) );
+
+ private static Map<String, RepositoryWriterFactory> writerRegistry =
+ Collections.synchronizedMap( new HashMap<String, RepositoryWriterFactory>( 4 ) );
+
+ // ---------------------------------------------------------------------------
+ protected String type = DEFAULT_REPOSITORY_TYPE;
+
+ protected QualityRange repositoryQualityRange = QualityRange.ALL;
+
+ protected QualityRange versionRangeQualityRange = QualityRange.ALL;
+
+ protected DependencyProcessor dependencyProcessor;
+
+ protected Server server;
+
+ private static final byte[] __HEX_DIGITS = "0123456789abcdef".getBytes();
+
+ // ---------------------------------------------------------------------------
+ public AbstractRepository( String id, String type )
+ {
+ this.id = hashId( id );
+
+ this.type = type;
+ }
+ // ---------------------------------------------------------------------------
+ public static String hashId( String id )
+ {
+ try
+ {
+ MessageDigest digest = MessageDigest.getInstance( "SHA-1" );
+
+ digest.update( id.getBytes() );
+
+ byte[] bytes = digest.digest();
+
+ int len = bytes.length;
+
+ byte[] raw = new byte[len * 2];
+
+ for ( int i = 0, j = 0; i < len; i++ )
+ {
+ raw[j++] = __HEX_DIGITS[( 0xF0 & bytes[i] ) >>> 4];
+ raw[j++] = __HEX_DIGITS[0x0F & bytes[i]];
+ }
+
+ return new String( raw );
+ }
+ catch ( NoSuchAlgorithmException e )
+ {
+ throw new IllegalArgumentException( e );
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+ public String getId()
+ {
+ return id;
+ }
+
+ // ---------------------------------------------------------------------------
+ public QualityRange getRepositoryQualityRange()
+ {
+ return repositoryQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setRepositoryQualityRange( QualityRange repositoryQualityRange )
+ {
+ this.repositoryQualityRange = repositoryQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public QualityRange getVersionRangeQualityRange()
+ {
+ return versionRangeQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setVersionRangeQualityRange( QualityRange versionRangeQualityRange )
+ {
+ this.versionRangeQualityRange = versionRangeQualityRange;
+ }
+
+ // ---------------------------------------------------------------------------
+ public String getDefaultReadProtocol()
+ {
+ return defaultReadProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setDefaultReadProtocol( String defaultReadProtocol )
+ {
+ this.defaultReadProtocol = defaultReadProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public String getDefaultWriteProtocol()
+ {
+ return defaultWriteProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public void setDefaultWriteProtocol( String defaultWriteProtocol )
+ {
+ this.defaultWriteProtocol = defaultWriteProtocol;
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void register( String type, RepositoryReaderFactory readerFactory )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
+
+ if ( readerFactory == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.factory" ) );
+
+ readerRegistry.put( type, readerFactory );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void register( String type, RepositoryWriterFactory writerFactory )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
+
+ if ( writerFactory == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.factory" ) );
+
+ writerRegistry.put( type, writerFactory );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void unregisterReader( String type )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
+
+ readerRegistry.remove( type );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static void unregisterWriter( String type )
+ throws IllegalArgumentException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
+
+ writerRegistry.remove( type );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static RepositoryReader getReader( String type, Repository repo, DependencyProcessor mdProcessor )
+ throws IllegalArgumentException, RepositoryException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.type" ) );
+
+ if ( repo == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.reader.repo" ) );
+
+ RepositoryReaderFactory rf = readerRegistry.get( type );
+
+ if ( rf == null )
+ throw new RepositoryException( LANG.getMessage( "null.reader.factory.found" ) );
+
+ return rf.getReader( repo, mdProcessor );
+ }
+
+ // ---------------------------------------------------------------------------
+ public static RepositoryWriter getWriter( String type, Repository repo )
+ throws IllegalArgumentException, RepositoryException
+ {
+ if ( type == null || type.length() < 1 )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.type" ) );
+
+ if ( repo == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.writer.repo" ) );
+
+ RepositoryWriterFactory wf = writerRegistry.get( type );
+
+ if ( wf == null )
+ throw new RepositoryException( LANG.getMessage( "null.writer.factory.found" ) );
+
+ return wf.getWriter( repo );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean isSnapshots()
+ {
+ return repositoryQualityRange.isAcceptedQuality( Quality.SNAPSHOT_QUALITY );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean isReleases()
+ {
+ return repositoryQualityRange.isAcceptedQuality( Quality.RELEASE_QUALITY );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean isAcceptedQuality( Quality quality )
+ {
+ return repositoryQualityRange.isAcceptedQuality( quality );
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean hasServer()
+ {
+ return server != null;
+ }
+
+ // ---------------------------------------------------------------------------
+ public Server getServer()
+ {
+ return server;
+ }
+
+ // ---------------------------------------------------------------------------
+ public boolean hasDependencyProcessor()
+ {
+ return dependencyProcessor == null;
+ }
+
+ public DependencyProcessor getDependencyProcessor()
+ {
+ return dependencyProcessor;
+ }
+
+ public void setDependencyProcessor( DependencyProcessor dependencyProcessor )
+ {
+ this.dependencyProcessor = dependencyProcessor;
+ }
+ // ---------------------------------------------------------------------------
+ // ---------------------------------------------------------------------------
}
Added: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/test/java/org/apache/maven/mercury/repository/api/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-api/src/test/java/org/apache/maven/mercury/repository/api/AbstractRepositoryTest.java?rev=747226&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-api/src/test/java/org/apache/maven/mercury/repository/api/AbstractRepositoryTest.java (added)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-api/src/test/java/org/apache/maven/mercury/repository/api/AbstractRepositoryTest.java Tue Feb 24 00:02:44 2009
@@ -0,0 +1,40 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+package org.apache.maven.mercury.repository.api;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class AbstractRepositoryTest
+ extends TestCase
+{
+ public void testIdHash()
+ {
+ String res = AbstractRepository.hashId( "central" );
+
+ assertEquals( "233ec5bda5fa468329234788b4ee61711ea3041e", res );
+ }
+}
Propchange: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/test/java/org/apache/maven/mercury/repository/api/AbstractRepositoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-repo/mercury-repo-api/src/test/java/org/apache/maven/mercury/repository/api/AbstractRepositoryTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/flat/LocalRepositoryFlat.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/flat/LocalRepositoryFlat.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/flat/LocalRepositoryFlat.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/flat/LocalRepositoryFlat.java Tue Feb 24 00:02:44 2009
@@ -19,6 +19,7 @@
package org.apache.maven.mercury.repository.local.flat;
import java.io.File;
+import java.io.IOException;
import org.apache.maven.mercury.repository.api.AbstractRepository;
import org.apache.maven.mercury.repository.api.LocalRepository;
@@ -40,6 +41,18 @@
private boolean createGroupFolders = false;
//----------------------------------------------------------------------------------
+ public LocalRepositoryFlat( File directory )
+ throws IOException
+ {
+ this( directory, false, false );
+ }
+ //----------------------------------------------------------------------------------
+ public LocalRepositoryFlat( File directory, boolean createGroupFolders, boolean createPoms )
+ throws IOException
+ {
+ this( directory.getCanonicalPath(), directory, createGroupFolders, createPoms );
+ }
+ //----------------------------------------------------------------------------------
public LocalRepositoryFlat( String id, File directory, boolean createGroupFolders, boolean createPoms )
{
super( id, FLAT_REPOSITORY_TYPE );
Modified: maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryM2.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryM2.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryM2.java Tue Feb 24 00:02:44 2009
@@ -19,6 +19,7 @@
package org.apache.maven.mercury.repository.local.m2;
import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.maven.mercury.builder.api.DependencyProcessor;
@@ -65,6 +66,12 @@
setDependencyProcessor( dependencyProcessor );
}
//----------------------------------------------------------------------------------
+ public LocalRepositoryM2( File directory, DependencyProcessor dependencyProcessor )
+ throws IOException
+ {
+ this( directory.getCanonicalPath(), directory, DEFAULT_REPOSITORY_TYPE, dependencyProcessor );
+ }
+ //----------------------------------------------------------------------------------
public LocalRepositoryM2( String id, File directory, DependencyProcessor dependencyProcessor )
{
this( id, directory, DEFAULT_REPOSITORY_TYPE, dependencyProcessor );
@@ -73,6 +80,7 @@
public LocalRepositoryM2( String id, File directory, String type, DependencyProcessor dependencyProcessor )
{
super( id, type );
+
setDirectory( directory );
setDependencyProcessor( dependencyProcessor );
Modified: maven/mercury/trunk/mercury-repo/mercury-repo-local-map/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryMap.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-map/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryMap.java?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-local-map/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryMap.java (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-local-map/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryMap.java Tue Feb 24 00:02:44 2009
@@ -43,7 +43,7 @@
protected Storage _storage;
protected MetadataReader _mdReader;
-
+
// ----------------------------------------------------------------------------------
public Storage getStorage()
{
@@ -57,6 +57,11 @@
_storage = storage;
}
+ // ----------------------------------------------------------------------------------
+ public LocalRepositoryMap( DependencyProcessor dp, Storage storage )
+ {
+ this( "" + System.currentTimeMillis() + (int)(Math.random()*10000), dp, storage );
+ }
public void setMetadataReader( MetadataReader reader )
{
Modified: maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/Messages.properties
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/Messages.properties?rev=747226&r1=747225&r2=747226&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/Messages.properties (original)
+++ maven/mercury/trunk/mercury-repo/mercury-repo-remote-m2/src/main/java/org/apache/maven/mercury/repository/remote/m2/Messages.properties Tue Feb 24 00:02:44 2009
@@ -44,7 +44,3 @@
cached.data.problem=problem {0} reading cached data for {1}. Moving on ..
cached.metadata.reading.exception=problem {0} reading cached data for {1}, server {2}
-lrepo.no.dir=local repo has a null dir
-lrepo.dir.not.exists=local repo dir {0} does not exist
-lrepo.null=local reposupplied is null
-dest.is.file=Destanation {0} is a file. Cannot copy to it