mirror of https://github.com/apache/maven.git
intermediate commit to revert lagacy repo system to default status
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@763103 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
068f969719
commit
9c56369edd
|
@ -27,13 +27,18 @@ import java.net.URL;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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.ScopeArtifactFilter;
|
||||
import org.apache.maven.mercury.artifact.ArtifactMetadata;
|
||||
import org.apache.maven.mercury.artifact.ArtifactScopeEnum;
|
||||
import org.apache.maven.mercury.artifact.MetadataTreeNode;
|
||||
import org.apache.maven.mercury.builder.api.DependencyProcessor;
|
||||
import org.apache.maven.mercury.repository.api.Repository;
|
||||
|
@ -61,11 +66,12 @@ public class MercuryAdaptor
|
|||
{
|
||||
if ( localRepository == null && Util.isEmpty( remoteRepositories ) )
|
||||
return null;
|
||||
|
||||
|
||||
int nRepos =
|
||||
( localRepository == null ? 0 : 1 ) + ( Util.isEmpty( remoteRepositories ) ? 0 : remoteRepositories.size() );
|
||||
|
||||
List<Repository> res = new ArrayList<Repository>( nRepos );
|
||||
Map<String, Repository> repos = new LinkedHashMap<String, Repository>(nRepos);
|
||||
|
||||
|
||||
if ( localRepository != null )
|
||||
{
|
||||
|
@ -88,7 +94,7 @@ public class MercuryAdaptor
|
|||
{
|
||||
throw new IllegalArgumentException( e );
|
||||
}
|
||||
res.add( lr );
|
||||
repos.put( url, lr );
|
||||
}
|
||||
|
||||
if ( !Util.isEmpty( remoteRepositories ) )
|
||||
|
@ -114,10 +120,17 @@ public class MercuryAdaptor
|
|||
_repos.put( url, rr );
|
||||
}
|
||||
|
||||
res.add( rr );
|
||||
repos.put( url, rr );
|
||||
}
|
||||
}
|
||||
|
||||
List<Repository> res = new ArrayList<Repository>( repos.size() );
|
||||
|
||||
for( Entry<String, Repository> e : repos.entrySet() )
|
||||
res.add( e.getValue() );
|
||||
|
||||
//System.out.println("Converted "+nRepos+" -> "+res.size());
|
||||
//
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -154,6 +167,10 @@ public class MercuryAdaptor
|
|||
ma.setScope( a.getScope() );
|
||||
|
||||
ma.setFile( a.getFile() );
|
||||
|
||||
ma.setResolved( true );
|
||||
|
||||
ma.setResolvedVersion( a.getVersion() );
|
||||
|
||||
return ma;
|
||||
}
|
||||
|
@ -245,4 +262,45 @@ public class MercuryAdaptor
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reqArtifact
|
||||
* @param isPlugin
|
||||
* @param filter
|
||||
* @return
|
||||
*/
|
||||
public static ArtifactScopeEnum extractScope( Artifact reqArtifact, boolean isPlugin, ArtifactFilter filter )
|
||||
{
|
||||
String scopeStr = reqArtifact.getScope(); //org.apache.maven.mercury.artifact.Artifact.SCOPE_COMPILE;
|
||||
|
||||
if( filter != null )
|
||||
{
|
||||
if( ScopeArtifactFilter.class.isAssignableFrom( filter.getClass() ) )
|
||||
scopeStr = ((ScopeArtifactFilter)filter).getScope();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if( scopeStr != null )
|
||||
{
|
||||
if( org.apache.maven.mercury.artifact.Artifact.SCOPE_COMPILE.equals( scopeStr ) )
|
||||
return ArtifactScopeEnum.compile;
|
||||
else if( org.apache.maven.mercury.artifact.Artifact.SCOPE_TEST.equals( scopeStr ) )
|
||||
return ArtifactScopeEnum.test;
|
||||
else if( org.apache.maven.mercury.artifact.Artifact.SCOPE_PROVIDED.equals( scopeStr ) )
|
||||
return ArtifactScopeEnum.provided;
|
||||
else if( org.apache.maven.mercury.artifact.Artifact.SCOPE_RUNTIME.equals( scopeStr ) )
|
||||
return ArtifactScopeEnum.runtime;
|
||||
else if( org.apache.maven.mercury.artifact.Artifact.SCOPE_SYSTEM.equals( scopeStr ) )
|
||||
return ArtifactScopeEnum.system;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.maven.artifact.factory.ArtifactFactory;
|
|||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.mercury.artifact.Artifact;
|
||||
import org.apache.maven.mercury.artifact.ArtifactMetadata;
|
||||
import org.apache.maven.mercury.artifact.ArtifactQueryList;
|
||||
import org.apache.maven.mercury.artifact.ArtifactScopeEnum;
|
||||
|
@ -49,7 +48,7 @@ import org.codehaus.plexus.lang.Language;
|
|||
* @author Oleg Gusakov
|
||||
* @version $Id$
|
||||
*/
|
||||
@Component( role = RepositorySystem.class, hint = "default" )
|
||||
@Component( role = RepositorySystem.class, hint = "mercury" )
|
||||
public class MercuryRepositorySystem
|
||||
extends LegacyRepositorySystem
|
||||
implements RepositorySystem
|
||||
|
@ -71,38 +70,79 @@ public class MercuryRepositorySystem
|
|||
if ( request == null )
|
||||
throw new IllegalArgumentException( LANG.getMessage( "null.request" ) );
|
||||
|
||||
System.out.println("mercury: request for "+request.getArtifact()
|
||||
+"("+request.getArtifactDependencies()+") repos="+request.getRemoteRepostories().size()
|
||||
+" repos, map=" + request.getManagedVersionMap()
|
||||
);
|
||||
|
||||
if ( request.getArtifact() == null )
|
||||
throw new IllegalArgumentException( LANG.getMessage( "null.request.artifact" ) );
|
||||
|
||||
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
||||
|
||||
List<Repository> repos =
|
||||
MercuryAdaptor.toMercuryRepos( request.getLocalRepository()
|
||||
MercuryAdaptor.toMercuryRepos( request.getLocalRepository()
|
||||
, request.getRemoteRepostories()
|
||||
, _dependencyProcessor
|
||||
);
|
||||
|
||||
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() );
|
||||
|
||||
ArtifactScopeEnum scope = MercuryAdaptor.extractScope( mavenRootArtifact, isPlugin, request.getFilter() );
|
||||
|
||||
if( isPlugin )
|
||||
mavenRootArtifact = createArtifact( mavenRootArtifact.getGroupId()
|
||||
, mavenRootArtifact.getArtifactId()
|
||||
, mavenRootArtifact.getVersion()
|
||||
, mavenRootArtifact.getScope()
|
||||
, "jar"
|
||||
);
|
||||
|
||||
ArtifactMetadata rootMd = MercuryAdaptor.toMercuryMetadata( mavenRootArtifact );
|
||||
|
||||
List<ArtifactMetadata> mercuryMetadataList = _mercury.resolve( repos, null, rootMd );
|
||||
List<ArtifactMetadata> mercuryMetadataList = _mercury.resolve( repos, scope, rootMd );
|
||||
|
||||
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 )
|
||||
result.addArtifact( MercuryAdaptor.toMavenArtifact( _artifactFactory, a ) );
|
||||
|
||||
// maven likes the original artifact instance - fill it in
|
||||
Artifact mercuryRootArtifact = mercuryArtifactList.get( 0 );
|
||||
|
||||
mavenRootArtifact.setFile( mercuryRootArtifact.getFile() );
|
||||
{
|
||||
if( a.getGroupId().equals( rootMd.getGroupId() ) && a.getArtifactId().equals( rootMd.getArtifactId() ) )
|
||||
{ // root artifact processing
|
||||
root = isPlugin ? mavenPluginArtifact : mavenRootArtifact;
|
||||
|
||||
root.setFile( a.getFile() );
|
||||
root.setResolved( true );
|
||||
root.setResolvedVersion( a.getVersion() );
|
||||
|
||||
result.addArtifact( root );
|
||||
}
|
||||
else
|
||||
{
|
||||
result.addArtifact( MercuryAdaptor.toMavenArtifact( _artifactFactory, a ) );
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("mercury: resolved("+diff+") "+root+"("+scope+") as file "+root.getFile() );
|
||||
}
|
||||
else
|
||||
{
|
||||
result.addMissingArtifact( mavenRootArtifact );
|
||||
System.out.println("mercury: missing artifact("+diff+") "+mavenRootArtifact+"("+scope+")" );
|
||||
}
|
||||
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.codehaus.plexus.util.StringUtils;
|
|||
/**
|
||||
* @author Jason van Zyl
|
||||
*/
|
||||
@Component( role = RepositorySystem.class, hint = "legacy" )
|
||||
@Component( role = RepositorySystem.class, hint = "default" )
|
||||
public class LegacyRepositorySystem
|
||||
implements RepositorySystem
|
||||
{
|
||||
|
@ -373,8 +373,12 @@ public class LegacyRepositorySystem
|
|||
}
|
||||
|
||||
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
||||
{
|
||||
return artifactResolver.resolve( request );
|
||||
{
|
||||
|
||||
//System.out.println("legacy: request with "+request.getRemoteRepostories().size()+" repos" );
|
||||
ArtifactResolutionResult res = artifactResolver.resolve( request );
|
||||
//System.out.println( "legacy resolved: "+request.getArtifact() );
|
||||
return res;
|
||||
}
|
||||
|
||||
public void setOnline( boolean online )
|
||||
|
|
Loading…
Reference in New Issue