mirror of https://github.com/apache/maven.git
[MNG-4814] Eary dependency resolution attempts for reactor projects prevent their later resolution from the reactor
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@997938 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
62b1a5ffb0
commit
fefa169604
|
@ -36,9 +36,11 @@ import org.codehaus.plexus.component.annotations.Component;
|
|||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.sonatype.aether.ConfigurationProperties;
|
||||
import org.sonatype.aether.RepositoryCache;
|
||||
import org.sonatype.aether.RepositoryListener;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
import org.sonatype.aether.util.artifact.SubArtifact;
|
||||
import org.sonatype.aether.util.listener.DefaultRepositoryEvent;
|
||||
import org.sonatype.aether.util.metadata.DefaultMetadata;
|
||||
import org.sonatype.aether.artifact.Artifact;
|
||||
|
@ -116,7 +118,7 @@ public class DefaultVersionResolver
|
|||
|
||||
Key cacheKey = null;
|
||||
RepositoryCache cache = session.getCache();
|
||||
if ( cache != null )
|
||||
if ( cache != null && !ConfigurationProperties.get( session, "aether.versionResolver.noCache", false ) )
|
||||
{
|
||||
cacheKey = new Key( session, request );
|
||||
|
||||
|
@ -248,7 +250,7 @@ public class DefaultVersionResolver
|
|||
}
|
||||
}
|
||||
|
||||
if ( cacheKey != null && metadata != null )
|
||||
if ( cacheKey != null && metadata != null && isSafelyCacheable( session, artifact ) )
|
||||
{
|
||||
cache.put( session, cacheKey, new Record( result.getVersion(), result.getRepository() ) );
|
||||
}
|
||||
|
@ -365,6 +367,28 @@ public class DefaultVersionResolver
|
|||
return StringUtils.clean( classifier ) + ':' + StringUtils.clean( extension );
|
||||
}
|
||||
|
||||
private boolean isSafelyCacheable( RepositorySystemSession session, Artifact artifact )
|
||||
{
|
||||
/*
|
||||
* The workspace/reactor is in flux so we better not assume definitive information for any of its
|
||||
* artifacts/projects.
|
||||
*/
|
||||
|
||||
WorkspaceReader workspace = session.getWorkspaceReader();
|
||||
if ( workspace == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Artifact pomArtifact = artifact;
|
||||
if ( pomArtifact.getClassifier().length() > 0 || !"pom".equals( pomArtifact.getExtension() ) )
|
||||
{
|
||||
pomArtifact = new SubArtifact( artifact, "", "pom" );
|
||||
}
|
||||
|
||||
return workspace.findArtifact( pomArtifact ) == null;
|
||||
}
|
||||
|
||||
private static class VersionInfo
|
||||
{
|
||||
|
||||
|
|
|
@ -96,7 +96,9 @@ public class DefaultProjectDependenciesResolver
|
|||
if ( !JavaScopes.SYSTEM.equals( dep.getScope() ) && dep.getArtifact().getFile() != null )
|
||||
{
|
||||
// enable re-resolution
|
||||
dep = dep.setArtifact( dep.getArtifact().setFile( null ) );
|
||||
org.sonatype.aether.artifact.Artifact art = dep.getArtifact();
|
||||
art = art.setFile( null ).setVersion( art.getBaseVersion() );
|
||||
dep = dep.setArtifact( art );
|
||||
}
|
||||
collect.addDependency( dep );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue