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 2014/08/26 22:41:57 UTC
svn commit: r1620726 - in /maven/plugins/trunk/maven-compiler-plugin: pom.xml
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
Author: rfscholte
Date: Tue Aug 26 20:41:57 2014
New Revision: 1620726
URL: http://svn.apache.org/r1620726
Log:
Remove duplicate MavenSession
Modified:
maven/plugins/trunk/maven-compiler-plugin/pom.xml
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
Modified: maven/plugins/trunk/maven-compiler-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/pom.xml?rev=1620726&r1=1620725&r2=1620726&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-compiler-plugin/pom.xml Tue Aug 26 20:41:57 2014
@@ -198,6 +198,12 @@ under the License.
</dependency>
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java?rev=1620726&r1=1620725&r2=1620726&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java Tue Aug 26 20:41:57 2014
@@ -360,14 +360,6 @@ public abstract class AbstractCompilerMo
private MojoExecution mojoExecution;
/**
- * We need this to determine the start timestamp of the build.
- *
- * @since 3.0
- */
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
- protected MavenSession mavenSession; // TODO why not reuse "session"?
-
- /**
* file extensions to check timestamp for incremental build
* <b>default contains only <code>.class</code></b>
*
@@ -622,7 +614,7 @@ public abstract class AbstractCompilerMo
boolean canUpdateTarget;
- IncrementalBuildHelper incrementalBuildHelper = new IncrementalBuildHelper( mojoExecution, mavenSession );
+ IncrementalBuildHelper incrementalBuildHelper = new IncrementalBuildHelper( mojoExecution, session );
Set<File> sources;
@@ -1168,7 +1160,7 @@ public abstract class AbstractCompilerMo
*/
protected boolean isDependencyChanged()
{
- if ( mavenSession == null )
+ if ( session == null )
{
// we just cannot determine it, so don't do anything beside logging
getLog().info( "Cannot determine build start date, skipping incremental build detection." );
Modified: maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java?rev=1620726&r1=1620725&r2=1620726&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java Tue Aug 26 20:41:57 2014
@@ -19,6 +19,18 @@ package org.apache.maven.plugin.compiler
* under the License.
*/
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution;
@@ -30,15 +42,6 @@ import org.apache.maven.plugin.testing.A
import org.apache.maven.plugin.testing.stubs.ArtifactStub;
import org.apache.maven.project.MavenProject;
-import java.io.File;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
public class CompilerMojoTestCase
extends AbstractMojoTestCase
{
@@ -299,7 +302,7 @@ public class CompilerMojoTestCase
setVariableValueToObject( mojo, "log", new DebugEnabledLog() );
setVariableValueToObject( mojo, "projectArtifact", new ArtifactStub() );
setVariableValueToObject( mojo, "classpathElements", Collections.EMPTY_LIST );
- setVariableValueToObject( mojo, "mavenSession", getMockMavenSession() );
+ setVariableValueToObject( mojo, "session", getMockMavenSession() );
setVariableValueToObject( mojo, "mojoExecution", getMockMojoExecution() );
assertNotNull( mojo );
@@ -341,7 +344,7 @@ public class CompilerMojoTestCase
String testSourceRoot = testPom.getParent() + "/src/test/java";
setVariableValueToObject( mojo, "compileSourceRoots", Collections.singletonList( testSourceRoot ) );
- setVariableValueToObject( mojo, "mavenSession", getMockMavenSession() );
+ setVariableValueToObject( mojo, "session", getMockMavenSession() );
setVariableValueToObject( mojo, "mojoExecution", getMockMojoExecution() );
return mojo;
@@ -357,11 +360,11 @@ public class CompilerMojoTestCase
private MavenSession getMockMavenSession()
{
- //X MavenExecutionRequest er = new DefaultMavenExecutionRequest();
- MavenSession ms = new MavenSession( null, null, null, null, null, null, null, null, null );
- ms.setCurrentProject( getMockMavenProject() );
-
- return ms;
+ MavenSession session = mock( MavenSession.class );
+ // when( session.getPluginContext( isA(PluginDescriptor.class), isA(MavenProject.class) ) ).thenReturn(
+ // Collections.emptyMap() );
+ when( session.getCurrentProject() ).thenReturn( getMockMavenProject() );
+ return session;
}
private MojoExecution getMockMojoExecution()