switched to mercury-alpha-7-SN dependency to enable managed version maps, the lifecycle UTs pass

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@763438 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Gusakov 2009-04-08 22:40:24 +00:00
parent 419248d61f
commit a309c4022d
8 changed files with 267 additions and 56 deletions

View File

@ -0,0 +1,48 @@
BOOTSTRAPPING BASICS
-----------------------
You'll need:
- Java 1.5
- Ant 1.6.5 or later
First, give Ant a location into which the completed Maven distro should be installed:
export M2_HOME=$HOME/apps/maven/apache-maven-3.0-SNAPSHOT
Then, run Ant:
ant -f build-mercury.xml
You can use additiona options on ant command line:
-Dmaven.repo.update.policy={never|always|daily}
-Dmaven.repo.system={mercury|legacy}
-Dmaven.home=$HOME/apps/maven/apache-maven-3.0-SNAPSHOT
if you'd like to debug the bootstrap from Eclipse, issue the following command:
export ANT_OPTS='-Dmercury.log.level=info -Dmercury.dump.tree=../forest'
export ANT_OPTS=$ANT_OPTS' -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'
the additional options:
-Dmercury.log.level={info|warn|error|debug} - defines mercury verbocity
-Dmercury.dump.tree=../forest - tells mercury to spit all the resolved trees into files ../forest-xxx.xml, where xxx is a timestamp
Then connect Eclipse debugging session to local port 8000
for example:
For the first time - run the following, it will update the local repo
export ANT_OPTS='-Dmercury.log.level=info -Dmercury.dump.tree=../forest'
export ANT_OPTS=$ANT_OPTS' -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'
ant -f build-mercury.xml -Dmaven.repo.update.policy=always
then you can run
ant -f build-mercury.xml -Dmaven.repo.update.policy=never -Dmaven.repo.system=mercury
to debug the bootstrap

View File

@ -173,10 +173,10 @@ END SNIPPET: ant-bootstrap -->
<property name="mc" refid="mercury.classpath"/>
<echo>mercury.classpath=${mc}</echo>
<echo>========================================================================</echo>
<!--
-->
<!--
<delete file="${basedir}/dependencies.xml"/>
-->
<tstamp><format property="modello.start.time" pattern="${tsFormat}"/></tstamp>
@ -297,18 +297,20 @@ END SNIPPET: ant-bootstrap -->
<target name="maven-compile" depends="compile-boot,process-classes" description="compiles Maven using the bootstrap Maven, skipping automated tests">
<java fork="true" classname="org.apache.maven.cli.MavenCli" failonerror="true">
<classpath refid="maven.classpath"/>
<arg value="-e"/>
<arg value="-X"/>
<arg value="-B"/>
<arg value="clean"/>
<arg value="install"/>
<arg value="-Dmaven.repo.local=${maven.repo.local}"/>
<arg value="-Dsurefire.useFile=${surefire.useFile}"/>
<!-- <debug-the-bootstrap>
<!--
<debug-the-bootstrap>
-->
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xnoagent"/>
<jvmarg value="-Djava.compiler=NONE"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/>
<!--
</debug-the-bootstrap>
-->
</java>

View File

@ -426,10 +426,8 @@ public class DefaultPluginManager
Set<Artifact> resolved = new LinkedHashSet<Artifact>();
for ( Iterator<Artifact> it = result.getArtifacts().iterator(); it.hasNext(); )
for ( Artifact artifact : result.getArtifacts() )
{
Artifact artifact = it.next();
if ( !artifact.equals( pluginArtifact ) )
{
artifact = project.replaceWithActiveArtifact( artifact );

View File

@ -31,7 +31,7 @@ under the License.
<description>Mercury implementation for the Maven Repository System</description>
<properties>
<mercury.version>1.0-alpha-6-SNAPSHOT</mercury.version>
<mercury.version>1.0-alpha-7-SNAPSHOT</mercury.version>
</properties>
<dependencies>

View File

@ -36,6 +36,8 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
import org.apache.maven.artifact.resolver.filter.IncludesArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.mercury.artifact.ArtifactMetadata;
import org.apache.maven.mercury.artifact.ArtifactScopeEnum;
@ -60,7 +62,7 @@ public class MercuryAdaptor
private static Map<String, Repository> _repos = Collections.synchronizedMap( new HashMap<String, Repository>() );
public static List<Repository> toMercuryRepos( ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
List<?> remoteRepositories,
DependencyProcessor dependencyProcessor
)
{
@ -99,9 +101,25 @@ public class MercuryAdaptor
if ( !Util.isEmpty( remoteRepositories ) )
{
for ( ArtifactRepository ar : remoteRepositories )
for ( Object o : remoteRepositories )
{
String url = ar.getUrl();
String url;
String id;
if( ArtifactRepository.class.isAssignableFrom( o.getClass() ))
{
ArtifactRepository ar = (ArtifactRepository) o;
url = ar.getUrl();
id = ar.getId();
}
else if( org.apache.maven.model.Repository.class.isAssignableFrom( o.getClass() ))
{
org.apache.maven.model.Repository ar = (org.apache.maven.model.Repository) o;
url = ar.getUrl();
id = ar.getId();
}
else
throw new IllegalArgumentException( "found illegal class in the remote repository list - " + o.getClass().getName() );
RemoteRepositoryM2 rr = (RemoteRepositoryM2) _repos.get( url );
@ -110,7 +128,7 @@ public class MercuryAdaptor
Server server;
try
{
server = new Server( ar.getId(), new URL( url ) );
server = new Server( id, new URL( url ) );
}
catch ( MalformedURLException e )
{
@ -134,16 +152,20 @@ public class MercuryAdaptor
return res;
}
public static ArtifactMetadata toMercuryBasicMetadata( Artifact a )
private static void setInExClusion( ArtifactMetadata md, List<String> patterns, boolean inc )
{
ArtifactMetadata md = new ArtifactMetadata();
md.setGroupId( a.getGroupId() );
md.setArtifactId( a.getArtifactId() );
md.setVersion( a.getVersion() );
md.setType( a.getType() );
md.setScope( a.getScope() );
if( Util.isEmpty( patterns ) )
return;
return md;
List<ArtifactMetadata> lusions = new ArrayList<ArtifactMetadata>( patterns.size() );
for( String pattern : patterns )
lusions.add( new ArtifactMetadata(pattern) );
if( inc )
md.setInclusions( lusions );
else
md.setExclusions( lusions );
}
public static ArtifactMetadata toMercuryMetadata( Artifact a )
@ -155,20 +177,45 @@ public class MercuryAdaptor
md.setType( a.getType() );
md.setScope( a.getScope() );
if( "test-jar".equals( a.getType() ) )
{
md.setType( "jar" );
md.setClassifier( "tests" );
}
ArtifactFilter af = a.getDependencyFilter();
if( af != null )
{
if( ExcludesArtifactFilter.class.isAssignableFrom( af.getClass() ) )
{
setInExClusion( md, ((ExcludesArtifactFilter)af).getPatterns(), false );
}
else if( IncludesArtifactFilter.class.isAssignableFrom( af.getClass() ) )
{
setInExClusion( md, ((IncludesArtifactFilter)af).getPatterns(), true );
}
}
return md;
}
public static Artifact toMavenArtifact( ArtifactFactory af, org.apache.maven.mercury.artifact.Artifact a )
{
Artifact ma = a.getClassifier() == null
? af.createArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getScope(), a.getType() )
: af.createArtifactWithClassifier( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier() )
boolean isTestJar = "test-jar".equals( a.getType() );
String type = isTestJar ? "jar" : a.getType();
String classifier = isTestJar ? "tests" : a.getType();
Artifact ma = classifier == null
? af.createArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getScope(), type )
: af.createArtifactWithClassifier( a.getGroupId(), a.getArtifactId(), a.getVersion(), type, classifier )
;
ma.setScope( a.getScope() );
ma.setFile( a.getFile() );
ma.setResolved( true );
ma.setResolved( a.getFile() != null );
ma.setResolvedVersion( a.getVersion() );
@ -177,9 +224,15 @@ public class MercuryAdaptor
public static Artifact toMavenArtifact( ArtifactFactory af, org.apache.maven.mercury.artifact.ArtifactMetadata a )
{
Artifact ma = a.getClassifier() == null
? af.createArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getScope(), a.getType() )
: af.createArtifactWithClassifier( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier() )
boolean isTestJar = "test-jar".equals( a.getType() );
String type = isTestJar ? "jar" : a.getType();
String classifier = isTestJar ? "tests" : a.getType();
Artifact ma = classifier == null
? af.createArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getScope(), type )
: af.createArtifactWithClassifier( a.getGroupId(), a.getArtifactId(), a.getVersion(), type, classifier )
;
ma.setScope( a.getScope() );
@ -200,6 +253,12 @@ public class MercuryAdaptor
mmd.setClassifier( md.getClassifier() );
mmd.setType( md.getType() );
if( "test-jar".equals( md.getType() ) )
{
mmd.setType( "jar" );
mmd.setClassifier( "tests" );
}
return mmd;
}
@ -212,6 +271,12 @@ public class MercuryAdaptor
mmd.setClassifier( md.getClassifier() );
mmd.setType( md.getType() );
if( "test-jar".equals( md.getType() ) )
{
mmd.setType( "jar" );
mmd.setClassifier( "tests" );
}
return mmd;
}
@ -224,6 +289,12 @@ public class MercuryAdaptor
mmd.setClassifier( md.getClassifier() );
mmd.setType( md.getType() );
if( "test-jar".equals( md.getType() ) )
{
mmd.setType( "jar" );
mmd.setClassifier( "tests" );
}
return mmd;
}
@ -278,10 +349,10 @@ public class MercuryAdaptor
scopeStr = ((ScopeArtifactFilter)filter).getScope();
}
if( "org.apache.maven.plugins:maven-remote-resources-plugin".equals(
reqArtifact.getGroupId()+":"+reqArtifact.getArtifactId()
)
) scopeStr = null;
// if( "org.apache.maven.plugins:maven-remote-resources-plugin".equals(
// reqArtifact.getGroupId()+":"+reqArtifact.getArtifactId()
// )
// ) scopeStr = null;
// else if( isPlugin )
// scopeStr = org.apache.maven.mercury.artifact.Artifact.SCOPE_RUNTIME;
@ -296,6 +367,8 @@ public class MercuryAdaptor
return ArtifactScopeEnum.provided;
else if( org.apache.maven.mercury.artifact.Artifact.SCOPE_RUNTIME.equals( scopeStr ) )
return ArtifactScopeEnum.runtime;
else if( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM.equals( scopeStr ) )
return ArtifactScopeEnum.runtime;
else if( org.apache.maven.mercury.artifact.Artifact.SCOPE_SYSTEM.equals( scopeStr ) )
return ArtifactScopeEnum.system;
}
@ -303,4 +376,19 @@ public class MercuryAdaptor
return null;
}
public static Map<String,ArtifactMetadata> toMercuryVersionMap(Map<String,Artifact> map )
{
if( Util.isEmpty( map ) )
return null;
Map<String,ArtifactMetadata> res = new HashMap<String, ArtifactMetadata>( map.size() );
for( Entry<String, Artifact> e : map.entrySet() )
{
res.put( e.getKey(), toMercuryMetadata( e.getValue() ) );
}
return res;
}
}

View File

@ -19,9 +19,14 @@ under the License.
package org.apache.maven.repository.mercury;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
@ -78,6 +83,8 @@ System.out.println("mercury: request for "+request.getArtifact()
if ( request.getArtifact() == null )
throw new IllegalArgumentException( LANG.getMessage( "null.request.artifact" ) );
Map<String, ArtifactMetadata> versionMap = MercuryAdaptor.toMercuryVersionMap( (Map<String,Artifact>)request.getManagedVersionMap() );
ArtifactResolutionResult result = new ArtifactResolutionResult();
List<Repository> repos =
@ -89,58 +96,123 @@ System.out.println("mercury: request for "+request.getArtifact()
try
{
long start = System.currentTimeMillis();
org.apache.maven.artifact.Artifact mavenRootArtifact = request.getArtifact();
org.apache.maven.artifact.Artifact mavenPluginArtifact = mavenRootArtifact;
boolean isPlugin = "maven-plugin".equals( mavenRootArtifact.getType() );
org.apache.maven.artifact.Artifact rootArtifact = request.getArtifact();
ArtifactScopeEnum scope = MercuryAdaptor.extractScope( mavenRootArtifact, isPlugin, request.getFilter() );
org.apache.maven.artifact.Artifact mavenPluginArtifact = rootArtifact;
Set<Artifact> artifacts = request.getArtifactDependencies();
boolean isPlugin = "maven-plugin".equals( rootArtifact.getType() );
ArtifactScopeEnum scope = MercuryAdaptor.extractScope( rootArtifact, isPlugin, request.getFilter() );
if( isPlugin )
mavenRootArtifact = createArtifact( mavenRootArtifact.getGroupId()
, mavenRootArtifact.getArtifactId()
, mavenRootArtifact.getVersion()
, mavenRootArtifact.getScope()
rootArtifact = createArtifact( rootArtifact.getGroupId()
, rootArtifact.getArtifactId()
, rootArtifact.getVersion()
, rootArtifact.getScope()
, "jar"
);
ArtifactMetadata rootMd = MercuryAdaptor.toMercuryMetadata( mavenRootArtifact );
ArtifactMetadata rootMd = MercuryAdaptor.toMercuryMetadata( rootArtifact );
List<ArtifactMetadata> mercuryMetadataList = _mercury.resolve( repos, scope, rootMd );
org.apache.maven.artifact.Artifact root = null;
// copied from artifact resolver
if ( request.isResolveRoot() && rootArtifact.getFile() == null && Util.isEmpty( artifacts ) )
{
try
{
List<ArtifactMetadata> mercuryMetadataList = new ArrayList<ArtifactMetadata>(1);
mercuryMetadataList.add( rootMd );
List<org.apache.maven.mercury.artifact.Artifact> mercuryArtifactList =
_mercury.read( repos, mercuryMetadataList );
if( Util.isEmpty( mercuryArtifactList ) )
{
result.addErrorArtifactException( new ArtifactResolutionException( "scope="+scope, rootArtifact) );
return result;
}
root = isPlugin ? mavenPluginArtifact : rootArtifact;
org.apache.maven.mercury.artifact.Artifact a = mercuryArtifactList.get( 0 );
root.setFile( a.getFile() );
root.setResolved( true );
root.setResolvedVersion( a.getVersion() );
result.addArtifact( rootArtifact );
result.addRequestedArtifact( rootArtifact );
}
catch ( Exception e )
{
result.addMissingArtifact( request.getArtifact() );
return result;
}
}
if ( Util.isEmpty( artifacts ) )
{
return result;
}
List<ArtifactMetadata> mercuryMetadataList = null;
if ( Util.isEmpty( artifacts ) )
mercuryMetadataList = _mercury.resolve( repos, scope, rootMd );
else
{
List<ArtifactMetadata> query = new ArrayList<ArtifactMetadata>( artifacts.size() + 1 );
query.add( rootMd );
for( Artifact a : artifacts )
query.add( MercuryAdaptor.toMercuryMetadata( a ) );
mercuryMetadataList = _mercury.resolve( repos, scope, new ArtifactQueryList(query), null, null, versionMap );
}
List<org.apache.maven.mercury.artifact.Artifact> mercuryArtifactList =
_mercury.read( repos, mercuryMetadataList );
long diff = System.currentTimeMillis() - start;
org.apache.maven.artifact.Artifact root = null;
if ( !Util.isEmpty( mercuryArtifactList ) )
{
for ( org.apache.maven.mercury.artifact.Artifact a : mercuryArtifactList )
{
if( a.getGroupId().equals( rootMd.getGroupId() ) && a.getArtifactId().equals( rootMd.getArtifactId() ) )
{ // root artifact processing
root = isPlugin ? mavenPluginArtifact : mavenRootArtifact;
root = isPlugin ? mavenPluginArtifact : rootArtifact;
root.setFile( a.getFile() );
root.setResolved( true );
root.setResolvedVersion( a.getVersion() );
result.addArtifact( root );
result.addRequestedArtifact( root );
}
else
{
result.addArtifact( MercuryAdaptor.toMavenArtifact( _artifactFactory, a ) );
Artifact ma = MercuryAdaptor.toMavenArtifact( _artifactFactory, a );
result.addArtifact( ma );
result.addRequestedArtifact( ma );
}
}
System.out.println("mercury: resolved("+diff+") "+root+"("+scope+") as file "+root.getFile() );
//for( Artifact a: result.getArtifacts() )
//System.out.println("mercury dependency: "+a+" as file "+a.getFile() );
}
else
{
result.addMissingArtifact( mavenRootArtifact );
System.out.println("mercury: missing artifact("+diff+") "+mavenRootArtifact+"("+scope+")" );
result.addMissingArtifact( rootArtifact );
System.out.println("mercury: missing artifact("+diff+") "+rootArtifact+"("+scope+")" );
}
}

View File

@ -375,9 +375,12 @@ public class LegacyRepositorySystem
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{
//System.out.println("legacy: request with "+request.getRemoteRepostories().size()+" repos" );
if(request.getRemoteRepostories() != null && request.getRemoteRepostories().size() > 10 )
{
System.out.println("legacy: request with "+request.getRemoteRepostories().size()+" remote repositories" );
}
ArtifactResolutionResult res = artifactResolver.resolve( request );
//System.out.println( "legacy resolved: "+request.getArtifact() );
return res;
}

View File

@ -63,7 +63,7 @@ under the License.
<plexusWebdavVersion>1.0</plexusWebdavVersion>
<wagonVersion>1.0-beta-5</wagonVersion>
<modelBuilderVersion>1.8</modelBuilderVersion>
<mercuryVersion>1.0-alpha-6-SNAPSHOT</mercuryVersion>
<mercuryVersion>1.0-alpha-7-SNAPSHOT</mercuryVersion>
<mercuryMp3Version>1.0-alpha-1</mercuryMp3Version>
<securityDispatcherVersion>1.2</securityDispatcherVersion>
<woodstoxVersion>3.2.6</woodstoxVersion>