You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/09/28 00:18:02 UTC
svn commit: r1001935 - in /maven/maven-3/trunk/maven-core/src:
main/java/org/apache/maven/ReactorReader.java
main/java/org/apache/maven/project/MavenProject.java
test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java
Author: bentmann
Date: Mon Sep 27 22:18:02 2010
New Revision: 1001935
URL: http://svn.apache.org/viewvc?rev=1001935&view=rev
Log:
o Cleaned up code to slightly better account for lifecycle phases without any mojo executions
Modified:
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/ReactorReader.java
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/ReactorReader.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/ReactorReader.java?rev=1001935&r1=1001934&r2=1001935&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/ReactorReader.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/ReactorReader.java Mon Sep 27 22:18:02 2010
@@ -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.
*
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java?rev=1001935&r1=1001934&r2=1001935&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java Mon Sep 27 22:18:02 2010
@@ -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.
Modified: maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java?rev=1001935&r1=1001934&r2=1001935&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java (original)
+++ maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/PhaseRecorderTest.java Mon Sep 27 22:18:02 2010
@@ -35,8 +35,8 @@ public class PhaseRecorderTest extends T
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));