[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:
Kristian Rosenvold 2010-04-13 20:09:15 +00:00
parent dbc214def7
commit 12b34781ec
4 changed files with 26 additions and 29 deletions

View File

@ -39,7 +39,6 @@
import org.apache.maven.execution.ProjectDependencyGraph;
import org.apache.maven.lifecycle.LifecycleExecutor;
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.ModelSource;
import org.apache.maven.model.building.UrlModelSource;
@ -112,6 +111,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
return result;
}
@SuppressWarnings({"ThrowableInstanceNeverThrown", "ThrowableResultOfMethodCallIgnored"})
private MavenExecutionResult doExecute( MavenExecutionRequest request )
{
//TODO: Need a general way to inject standard properties
@ -182,8 +182,7 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request )
// Reactor
// Workspace
// User Local Repository
final boolean isWeaveMode = LifecycleWeaveBuilder.isWeaveMode( request);
delegatingLocalArtifactRepository.setBuildReactor( new ReactorArtifactRepository( projectMap, isWeaveMode ) );
delegatingLocalArtifactRepository.setBuildReactor( new ReactorArtifactRepository( projectMap ) );
}
catch ( org.apache.maven.DuplicateProjectException e )
{
@ -248,13 +247,14 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request )
validateActivatedProfiles( session.getProjects(), request.getActiveProfiles() );
if ( session.getResult().hasExceptions() )
{
{
return processResult( result, session.getResult().getExceptions().get( 0 ) );
}
return result;
}
@SuppressWarnings({"ResultOfMethodCallIgnored"})
private void validateLocalRepository( MavenExecutionRequest request )
throws LocalRepositoryNotAccessibleException
{

View File

@ -21,15 +21,12 @@ public class ReactorArtifactRepository
private Map<String, List<String>> availableVersions;
private final boolean isWeaveMode;
private final int hashCode;
@SuppressWarnings({"ConstantConditions"})
public ReactorArtifactRepository( Map<String, MavenProject> reactorProjects, boolean isWeaveMode )
@SuppressWarnings({"ConstantConditions"})
public ReactorArtifactRepository( Map<String, MavenProject> reactorProjects )
{
this.reactorProjects = reactorProjects;
this.isWeaveMode = isWeaveMode;
hashCode = ( reactorProjects != null ) ? reactorProjects.keySet().hashCode() : 0;
availableVersions = new HashMap<String, List<String>>( reactorProjects.size() * 2 );
@ -53,7 +50,7 @@ public ReactorArtifactRepository( Map<String, MavenProject> reactorProjects, boo
public Artifact find( Artifact artifact )
{
String projectKey = ArtifactUtils.key( artifact );
MavenProject project = reactorProjects.get( projectKey );
if ( project != null )
@ -68,35 +65,32 @@ public Artifact find( Artifact 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() );
}
else
{
Collection<String> lifecyclePhases = project.getLifecyclePhases();
if ( !lifecyclePhases.contains( "package" ) )
if ( !project.hasCompletedPhase( "package" ) )
{
if ( isTestArtifact( artifact ) )
{
if ( lifecyclePhases.contains( "test-compile" ) )
if ( project.hasCompletedPhase( "test-compile" ) )
{
resolve( artifact, new File( project.getBuild().getTestOutputDirectory() ) );
}
}
else
{
if ( lifecyclePhases.contains( "compile" ) )
if ( project.hasCompletedPhase( "compile" ) )
{
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 Artifact find( Artifact artifact )
return artifact;
}
private boolean hasArtifactFileFromPackagePhase( Artifact projectArtifact )
{
return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists();
}
private void resolve( Artifact artifact, File file )
{
artifact.setFile( file );

View File

@ -19,7 +19,7 @@
/**
* @author Benjamin Bentmann
* @author Kristian Rosenvold (extrace class)
* @author Kristian Rosenvold (extract class)
* <p/>
* NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
*/

View File

@ -222,7 +222,6 @@ public void setParentFile( File parentFile )
/**
* Constructor
*
* @param artifactFactory - may not be null
* @param repositorySystem - may not be null
* @param mavenProjectBuilder
* @param projectBuilderConfiguration
@ -2084,15 +2083,14 @@ public void setArtifactFilter( ArtifactFilter artifactFilter )
}
/**
* Gets the set of lifecycle phases this project has successfully completed.
*
* @return The (unmodifiable) set of lifecycle phases this project has successfully completed, can be empty but
* never {@code null}.
* Indicates if the project has completed the specified lifecycle phase.
*
* @param phase The phase to check for completion
* @return true if the phase has been completed
*/
public Set<String> getLifecyclePhases()
public boolean hasCompletedPhase( String phase )
{
return ( lifecyclePhases != null ) ? Collections.unmodifiableSet( lifecyclePhases )
: Collections.<String> emptySet();
return lifecyclePhases != null && lifecyclePhases.contains( phase );
}
/**
@ -2107,7 +2105,7 @@ public void addLifecyclePhase( String lifecyclePhase )
{
if ( lifecyclePhases == null )
{
lifecyclePhases = new LinkedHashSet<String>();
lifecyclePhases = Collections.synchronizedSet( new LinkedHashSet<String>() );
}
lifecyclePhases.add( lifecyclePhase );
}