o Cleaned up code to slightly better account for lifecycle phases without any mojo executions

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1001935 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-09-27 22:18:02 +00:00
parent f7809d3981
commit 2307863420
3 changed files with 20 additions and 11 deletions

View File

@ -86,18 +86,20 @@ class ReactorReader
{
return projectArtifact.getFile();
}
else if ( !project.hasCompletedPhase( "package" ) )
else if ( !hasBeenPackaged( project ) )
{
// fallback to loose class files only if artifacts haven't been packaged yet
if ( isTestArtifact( artifact ) )
{
if ( project.hasCompletedPhase( "test-compile" ) )
if ( project.hasLifecyclePhase( "test-compile" ) )
{
return new File( project.getBuild().getTestOutputDirectory() );
}
}
else
{
if ( project.hasCompletedPhase( "compile" ) )
if ( project.hasLifecyclePhase( "compile" ) )
{
return new File( project.getBuild().getOutputDirectory() );
}
@ -114,6 +116,12 @@ class ReactorReader
return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists();
}
private boolean hasBeenPackaged( MavenProject project )
{
return project.hasLifecyclePhase( "package" ) || project.hasLifecyclePhase( "install" )
|| project.hasLifecyclePhase( "deploy" );
}
/**
* Tries to resolve the specified artifact from the artifacts of the given project.
*

View File

@ -2122,18 +2122,19 @@ public class MavenProject
}
/**
* 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
* <strong>Warning:</strong> This is an internal utility method that is only public for technical reasons, it is not
* part of the public API. In particular, this method can be changed or deleted without prior notice and must not be
* used by plugins.
*
* @param phase The phase to check for, must not be {@code null}.
* @return {@code true} if the phase has been seen.
*/
public boolean hasCompletedPhase( String phase )
public boolean hasLifecyclePhase( String phase )
{
return lifecyclePhases.contains( phase );
}
/**
* Adds the specified lifecycle phase to the phases this project has successfully completed.
* <strong>Warning:</strong> This is an internal utility method that is only public for technical reasons, it is not
* part of the public API. In particular, this method can be changed or deleted without prior notice and must not be
* used by plugins.

View File

@ -35,8 +35,8 @@ public class PhaseRecorderTest extends TestCase
final MojoExecution mojoExecution2 = executions.get( 1 );
phaseRecorder.observeExecution( mojoExecution1 );
assertTrue( ProjectDependencyGraphStub.A.hasCompletedPhase( mojoExecution1.getLifecyclePhase() ));
assertFalse( ProjectDependencyGraphStub.A.hasCompletedPhase( mojoExecution2.getLifecyclePhase() ));
assertTrue( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution1.getLifecyclePhase() ));
assertFalse( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution2.getLifecyclePhase() ));
assertFalse( phaseRecorder.isDifferentPhase( mojoExecution1));
assertTrue( phaseRecorder.isDifferentPhase( mojoExecution2));