mirror of https://github.com/apache/maven.git
[MNG-4633] Removed isWeaveMode from ReactorArtifactRepository
This feature was incorrect, and weave mode requires no special handling here. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@933771 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dbc214def7
commit
12b34781ec
|
@ -39,7 +39,6 @@ import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.execution.ProjectDependencyGraph;
|
import org.apache.maven.execution.ProjectDependencyGraph;
|
||||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||||
import org.apache.maven.lifecycle.internal.ExecutionEventCatapult;
|
import org.apache.maven.lifecycle.internal.ExecutionEventCatapult;
|
||||||
import org.apache.maven.lifecycle.internal.LifecycleWeaveBuilder;
|
|
||||||
import org.apache.maven.model.building.ModelProblem;
|
import org.apache.maven.model.building.ModelProblem;
|
||||||
import org.apache.maven.model.building.ModelSource;
|
import org.apache.maven.model.building.ModelSource;
|
||||||
import org.apache.maven.model.building.UrlModelSource;
|
import org.apache.maven.model.building.UrlModelSource;
|
||||||
|
@ -112,6 +111,7 @@ public class DefaultMaven
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"ThrowableInstanceNeverThrown", "ThrowableResultOfMethodCallIgnored"})
|
||||||
private MavenExecutionResult doExecute( MavenExecutionRequest request )
|
private MavenExecutionResult doExecute( MavenExecutionRequest request )
|
||||||
{
|
{
|
||||||
//TODO: Need a general way to inject standard properties
|
//TODO: Need a general way to inject standard properties
|
||||||
|
@ -182,8 +182,7 @@ public class DefaultMaven
|
||||||
// Reactor
|
// Reactor
|
||||||
// Workspace
|
// Workspace
|
||||||
// User Local Repository
|
// User Local Repository
|
||||||
final boolean isWeaveMode = LifecycleWeaveBuilder.isWeaveMode( request);
|
delegatingLocalArtifactRepository.setBuildReactor( new ReactorArtifactRepository( projectMap ) );
|
||||||
delegatingLocalArtifactRepository.setBuildReactor( new ReactorArtifactRepository( projectMap, isWeaveMode ) );
|
|
||||||
}
|
}
|
||||||
catch ( org.apache.maven.DuplicateProjectException e )
|
catch ( org.apache.maven.DuplicateProjectException e )
|
||||||
{
|
{
|
||||||
|
@ -248,13 +247,14 @@ public class DefaultMaven
|
||||||
validateActivatedProfiles( session.getProjects(), request.getActiveProfiles() );
|
validateActivatedProfiles( session.getProjects(), request.getActiveProfiles() );
|
||||||
|
|
||||||
if ( session.getResult().hasExceptions() )
|
if ( session.getResult().hasExceptions() )
|
||||||
{
|
{
|
||||||
return processResult( result, session.getResult().getExceptions().get( 0 ) );
|
return processResult( result, session.getResult().getExceptions().get( 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"ResultOfMethodCallIgnored"})
|
||||||
private void validateLocalRepository( MavenExecutionRequest request )
|
private void validateLocalRepository( MavenExecutionRequest request )
|
||||||
throws LocalRepositoryNotAccessibleException
|
throws LocalRepositoryNotAccessibleException
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,15 +21,12 @@ public class ReactorArtifactRepository
|
||||||
|
|
||||||
private Map<String, List<String>> availableVersions;
|
private Map<String, List<String>> availableVersions;
|
||||||
|
|
||||||
private final boolean isWeaveMode;
|
|
||||||
|
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
|
|
||||||
@SuppressWarnings({"ConstantConditions"})
|
@SuppressWarnings({"ConstantConditions"})
|
||||||
public ReactorArtifactRepository( Map<String, MavenProject> reactorProjects, boolean isWeaveMode )
|
public ReactorArtifactRepository( Map<String, MavenProject> reactorProjects )
|
||||||
{
|
{
|
||||||
this.reactorProjects = reactorProjects;
|
this.reactorProjects = reactorProjects;
|
||||||
this.isWeaveMode = isWeaveMode;
|
|
||||||
hashCode = ( reactorProjects != null ) ? reactorProjects.keySet().hashCode() : 0;
|
hashCode = ( reactorProjects != null ) ? reactorProjects.keySet().hashCode() : 0;
|
||||||
|
|
||||||
availableVersions = new HashMap<String, List<String>>( reactorProjects.size() * 2 );
|
availableVersions = new HashMap<String, List<String>>( reactorProjects.size() * 2 );
|
||||||
|
@ -53,7 +50,7 @@ public class ReactorArtifactRepository
|
||||||
public Artifact find( Artifact artifact )
|
public Artifact find( Artifact artifact )
|
||||||
{
|
{
|
||||||
String projectKey = ArtifactUtils.key( artifact );
|
String projectKey = ArtifactUtils.key( artifact );
|
||||||
|
|
||||||
MavenProject project = reactorProjects.get( projectKey );
|
MavenProject project = reactorProjects.get( projectKey );
|
||||||
|
|
||||||
if ( project != null )
|
if ( project != null )
|
||||||
|
@ -68,35 +65,32 @@ public class ReactorArtifactRepository
|
||||||
|
|
||||||
Artifact projectArtifact = findMatchingArtifact( project, artifact );
|
Artifact projectArtifact = findMatchingArtifact( project, artifact );
|
||||||
|
|
||||||
if ( !isWeaveMode && (projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists()) )
|
if ( hasArtifactFileFromPackagePhase( projectArtifact ) )
|
||||||
{
|
{
|
||||||
//TODO: This is really completely wrong and should probably be based on the phase that is currently being executed.
|
|
||||||
// If we are running before the packaging phase there is going to be no archive anyway, but if we are running prior to package
|
|
||||||
// we shouldn't even take the archive anyway.
|
|
||||||
|
|
||||||
resolve( artifact, projectArtifact.getFile() );
|
resolve( artifact, projectArtifact.getFile() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Collection<String> lifecyclePhases = project.getLifecyclePhases();
|
if ( !project.hasCompletedPhase( "package" ) )
|
||||||
|
|
||||||
if ( !lifecyclePhases.contains( "package" ) )
|
|
||||||
{
|
{
|
||||||
if ( isTestArtifact( artifact ) )
|
if ( isTestArtifact( artifact ) )
|
||||||
{
|
{
|
||||||
if ( lifecyclePhases.contains( "test-compile" ) )
|
if ( project.hasCompletedPhase( "test-compile" ) )
|
||||||
{
|
{
|
||||||
resolve( artifact, new File( project.getBuild().getTestOutputDirectory() ) );
|
resolve( artifact, new File( project.getBuild().getTestOutputDirectory() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( lifecyclePhases.contains( "compile" ) )
|
if ( project.hasCompletedPhase( "compile" ) )
|
||||||
{
|
{
|
||||||
resolve( artifact, new File( project.getBuild().getOutputDirectory() ) );
|
resolve( artifact, new File( project.getBuild().getOutputDirectory() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The fall-through indicates that the artifact cannot be found;
|
||||||
|
// for instance if package produced nothing or classifier problems.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +98,11 @@ public class ReactorArtifactRepository
|
||||||
return artifact;
|
return artifact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasArtifactFileFromPackagePhase( Artifact projectArtifact )
|
||||||
|
{
|
||||||
|
return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists();
|
||||||
|
}
|
||||||
|
|
||||||
private void resolve( Artifact artifact, File file )
|
private void resolve( Artifact artifact, File file )
|
||||||
{
|
{
|
||||||
artifact.setFile( file );
|
artifact.setFile( file );
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.apache.maven.project.MavenProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Benjamin Bentmann
|
* @author Benjamin Bentmann
|
||||||
* @author Kristian Rosenvold (extrace class)
|
* @author Kristian Rosenvold (extract class)
|
||||||
* <p/>
|
* <p/>
|
||||||
* NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
|
* NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -222,7 +222,6 @@ public class MavenProject
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param artifactFactory - may not be null
|
|
||||||
* @param repositorySystem - may not be null
|
* @param repositorySystem - may not be null
|
||||||
* @param mavenProjectBuilder
|
* @param mavenProjectBuilder
|
||||||
* @param projectBuilderConfiguration
|
* @param projectBuilderConfiguration
|
||||||
|
@ -2084,15 +2083,14 @@ public class MavenProject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the set of lifecycle phases this project has successfully completed.
|
* Indicates if the project has completed the specified lifecycle phase.
|
||||||
*
|
*
|
||||||
* @return The (unmodifiable) set of lifecycle phases this project has successfully completed, can be empty but
|
* @param phase The phase to check for completion
|
||||||
* never {@code null}.
|
* @return true if the phase has been completed
|
||||||
*/
|
*/
|
||||||
public Set<String> getLifecyclePhases()
|
public boolean hasCompletedPhase( String phase )
|
||||||
{
|
{
|
||||||
return ( lifecyclePhases != null ) ? Collections.unmodifiableSet( lifecyclePhases )
|
return lifecyclePhases != null && lifecyclePhases.contains( phase );
|
||||||
: Collections.<String> emptySet();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2107,7 +2105,7 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
if ( lifecyclePhases == null )
|
if ( lifecyclePhases == null )
|
||||||
{
|
{
|
||||||
lifecyclePhases = new LinkedHashSet<String>();
|
lifecyclePhases = Collections.synchronizedSet( new LinkedHashSet<String>() );
|
||||||
}
|
}
|
||||||
lifecyclePhases.add( lifecyclePhase );
|
lifecyclePhases.add( lifecyclePhase );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue