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 2008/11/08 02:20:36 UTC
svn commit: r712337 - in /maven/mercury/trunk/mercury-plexus/src:
main/java/org/apache/maven/mercury/plexus/
test/java/org/apache/maven/mercury/plexus/
Author: ogusakov
Date: Fri Nov 7 17:20:36 2008
New Revision: 712337
URL: http://svn.apache.org/viewvc?rev=712337&view=rev
Log:
changed APIs - added inclusions/exclusions
Modified:
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/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java
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=712337&r1=712336&r2=712337&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 Fri Nov 7 17:20:36 2008
@@ -14,6 +14,7 @@
import org.apache.maven.mercury.artifact.Artifact;
import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.artifact.ArtifactMetadataList;
import org.apache.maven.mercury.artifact.ArtifactScopeEnum;
import org.apache.maven.mercury.crypto.api.StreamObserverFactory;
import org.apache.maven.mercury.crypto.api.StreamVerifierAttributes;
@@ -211,15 +212,15 @@
);
}
//---------------------------------------------------------------
-
- public List<ArtifactMetadata> resolve(
- List<Repository> repos,
- ArtifactScopeEnum scope,
- List<ArtifactBasicMetadata> artifacts
+ public List<ArtifactMetadata> resolve( List<Repository> repos
+ , ArtifactScopeEnum scope
+ , ArtifactMetadataList artifacts
+ , ArtifactMetadataList inclusions
+ , ArtifactMetadataList exclusions
)
throws RepositoryException
{
- if( Util.isEmpty( artifacts ) )
+ if( Util.isEmpty( artifacts ) || artifacts.isEmpty() )
throw new IllegalArgumentException( _lang.getMessage( "no.artifacts" ) );
if( artifacts.size() > 1 )
@@ -229,7 +230,16 @@
{
DependencyBuilder depBuilder = DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL, repos, null, null, null );
- MetadataTreeNode root = depBuilder.buildTree( artifacts.get(0), scope );
+ ArtifactBasicMetadata a = artifacts.getMetadataList().get( 0 );
+
+ if( inclusions != null && ! inclusions.isEmpty() )
+ a.setInclusions( inclusions.getMetadataList() );
+
+ if( exclusions != null && ! exclusions.isEmpty() )
+ a.setExclusions( exclusions.getMetadataList() );
+
+ MetadataTreeNode root = depBuilder.buildTree( a, scope );
+
List<ArtifactMetadata> res = depBuilder.resolveConflicts( root );
return res;
@@ -239,15 +249,6 @@
throw new RepositoryException( e );
}
}
-
- public List<ArtifactMetadata> resolve( List<Repository> repos
- , ArtifactScopeEnum scope
- , ArtifactBasicMetadata... artifacts
- )
- throws RepositoryException
- {
- return resolve( repos, scope, Arrays.asList( artifacts ) );
- }
//---------------------------------------------------------------
//---------------------------------------------------------------
}
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=712337&r1=712336&r2=712337&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 Fri Nov 7 17:20:36 2008
@@ -9,6 +9,8 @@
import org.apache.maven.mercury.artifact.Artifact;
import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.artifact.ArtifactMetadataList;
import org.apache.maven.mercury.artifact.ArtifactScopeEnum;
import org.apache.maven.mercury.crypto.api.StreamObserverFactory;
import org.apache.maven.mercury.crypto.api.StreamVerifierException;
@@ -138,22 +140,21 @@
throws RepositoryException;
/**
- * resolve Artifact dependencies
+ * resolve Artifact dependencies. The inclusions and exclusions accept version ranges as parameters
*
* @param repo repository instance to search
- * @param artfifacts to read
+ * @param scope scope enumeration member indication the scope to resolve for
+ * @param artfifacts list of artifact metadatas to resolve
+ * @param inclusions list of artifact metadatas to include - only these will be in the resolved classpath
+ * @param exclusions list of artifact metadatas to exclude - is applied after the inclusion, if one is present
* @return
* @throws PlexusMercuryException
*/
- public List<? extends ArtifactBasicMetadata> resolve( List<Repository> repos
- , ArtifactScopeEnum scope
- , ArtifactBasicMetadata... artifacts
- )
- throws RepositoryException;
-
- public List<? extends ArtifactBasicMetadata> resolve( List<Repository> repos
+ public List<ArtifactMetadata> resolve( List<Repository> repos
, ArtifactScopeEnum scope
- , List<ArtifactBasicMetadata> artifacts
+ , ArtifactMetadataList artifacts
+ , ArtifactMetadataList inclusions
+ , ArtifactMetadataList exclusions
)
throws RepositoryException;
}
Modified: maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java?rev=712337&r1=712336&r2=712337&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java (original)
+++ maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java Fri Nov 7 17:20:36 2008
@@ -12,6 +12,7 @@
import org.apache.maven.mercury.artifact.Artifact;
import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.artifact.ArtifactMetadataList;
import org.apache.maven.mercury.artifact.ArtifactScopeEnum;
import org.apache.maven.mercury.artifact.DefaultArtifact;
import org.apache.maven.mercury.crypto.api.StreamVerifierFactory;
@@ -120,7 +121,7 @@
super.tearDown();
}
//----------------------------------------------------------------------------------------------
- private static boolean assertHasArtifact( List<ArtifactBasicMetadata> res, String gav )
+ private static boolean assertHasArtifact( List<ArtifactMetadata> res, String gav )
{
ArtifactMetadata gavMd = new ArtifactMetadata(gav);
@@ -168,16 +169,14 @@
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") );
+ 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) );
String artifactId = "asm:asm-xml:3.0";
- ArtifactBasicMetadata bmd = new ArtifactBasicMetadata( artifactId );
-
- List<ArtifactBasicMetadata> res = (List<ArtifactBasicMetadata>)pm.resolve( repos, ArtifactScopeEnum.compile, bmd );
+ List<ArtifactMetadata> res = pm.resolve( repos, ArtifactScopeEnum.compile, new ArtifactMetadataList(artifactId), null, null );
System.out.println("Resolved as "+res);
@@ -194,21 +193,19 @@
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") );
+ 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) );
String artifactId = "asm:asm-xml:3.0";
- ArtifactBasicMetadata bmd = new ArtifactBasicMetadata( artifactId );
-
- List<ArtifactBasicMetadata> exclusions = new ArrayList<ArtifactBasicMetadata>();
- exclusions.add( new ArtifactBasicMetadata("asm:asm:3.0") );
-
- bmd.setExclusions( exclusions );
-
- List<ArtifactBasicMetadata> res = (List<ArtifactBasicMetadata>)pm.resolve( repos, ArtifactScopeEnum.compile, bmd );
+ List<ArtifactMetadata> res = pm.resolve( repos
+ , ArtifactScopeEnum.compile
+ , new ArtifactMetadataList(artifactId)
+ , null
+ , new ArtifactMetadataList("asm:asm:3.0")
+ );
System.out.println("Resolved as "+res);