You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2011/08/27 18:39:22 UTC

svn commit: r1162398 - in /maven/plugins/trunk/maven-compiler-plugin/src: main/java/org/apache/maven/plugin/CompilerMojo.java test/java/org/apache/maven/plugin/CompilerMojoTestCase.java

Author: rfscholte
Date: Sat Aug 27 16:39:22 2011
New Revision: 1162398

URL: http://svn.apache.org/viewvc?rev=1162398&view=rev
Log:
Fix MCOMPILER-94: compiler sets artifact file to target/classes, even if nothing is compiled

Modified:
    maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
    maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java

Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java?rev=1162398&r1=1162397&r2=1162398&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java Sat Aug 27 16:39:22 2011
@@ -127,7 +127,10 @@ public class CompilerMojo
     {
         super.execute();
 
-        projectArtifact.setFile( outputDirectory );
+        if ( outputDirectory.isDirectory() )
+        {
+            projectArtifact.setFile( outputDirectory );
+        }
     }
 
     protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )

Modified: maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java?rev=1162398&r1=1162397&r2=1162398&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/CompilerMojoTestCase.java Sat Aug 27 16:39:22 2011
@@ -19,11 +19,6 @@ package org.apache.maven.plugin;
  * under the License.
  */
 
-import org.apache.maven.plugin.stubs.CompilerManagerStub;
-import org.apache.maven.plugin.stubs.DebugEnabledLog;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugin.testing.stubs.ArtifactStub;
-
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -31,6 +26,12 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.stubs.CompilerManagerStub;
+import org.apache.maven.plugin.stubs.DebugEnabledLog;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+
 public class CompilerMojoTestCase
     extends AbstractMojoTestCase
 {
@@ -54,6 +55,9 @@ public class CompilerMojoTestCase
             getTestCompilerMojo( compileMojo, "target/test-classes/unit/compiler-basic-test/plugin-config.xml" );
 
         testCompileMojo.execute();
+        
+        Artifact projectArtifact = (Artifact) getVariableValueFromObject( compileMojo, "projectArtifact" );
+        assertNotNull( "MCOMPILER-94: artifact file should only be null if there is nothing to compile", projectArtifact.getFile() );
 
         testClass = new File( testCompileMojo.getOutputDirectory(), "TestCompile0Test.class" );
 
@@ -75,6 +79,9 @@ public class CompilerMojoTestCase
 
         assertFalse( compileMojo.getOutputDirectory().exists() );
 
+        Artifact projectArtifact = (Artifact) getVariableValueFromObject( compileMojo, "projectArtifact" );
+        assertNull( "MCOMPILER-94: artifact file should be null if there is nothing to compile", projectArtifact.getFile() );
+
         TestCompilerMojo testCompileMojo =
             getTestCompilerMojo( compileMojo, "target/test-classes/unit/compiler-empty-source-test/plugin-config.xml" );