You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by so...@apache.org on 2018/05/12 14:22:12 UTC

[maven-compiler-plugin] branch MCOMPILER-341 updated (5586162 -> 699fd09)

This is an automated email from the ASF dual-hosted git repository.

sor pushed a change to branch MCOMPILER-341
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git.


 discard 5586162  [MCOMPILER-341] Compile modules descriptors with TestCompilerMojo
     new 699fd09  [MCOMPILER-341] Compile modules descriptors with TestCompilerMojo

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5586162)
            \
             N -- N -- N   refs/heads/MCOMPILER-341 (699fd09)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../jpms_compile-test-modules}/invoker.properties  |   0
 .../app => jpms_compile-test-modules}/pom.xml      | 103 +++++++++++++--------
 .../src/main/java/foo/Foo.java}                    |   7 +-
 .../src/main}/java/module-info.java                |   5 +-
 .../src/test/java/foo/FooTests.java}               |  17 +++-
 .../src/test}/java/module-info.java                |  50 +++++-----
 .../verify.groovy                                  |  55 ++++++-----
 .../plugin/compiler/CompilerMojoTestCase.java      |  25 -----
 .../unit/compiler-jpms-test/plugin-config.xml      |  38 --------
 .../src/main/java/module-info.java                 |  22 -----
 10 files changed, 137 insertions(+), 185 deletions(-)
 rename src/{test/resources/unit/compiler-jpms-test => it/jpms_compile-test-modules}/invoker.properties (100%)
 copy src/it/{MCOMPILER-294/app => jpms_compile-test-modules}/pom.xml (51%)
 rename src/{test/resources/unit/compiler-jpms-test/src/main/java/foo/TestJpms0.java => it/jpms_compile-test-modules/src/main/java/foo/Foo.java} (94%)
 rename src/{test/resources/unit/compiler-jpms-test/src/test => it/jpms_compile-test-modules/src/main}/java/module-info.java (93%)
 rename src/{test/resources/unit/compiler-jpms-test/src/test/java/foo/TestJpms0Test.java => it/jpms_compile-test-modules/src/test/java/foo/FooTests.java} (69%)
 copy src/it/{MCOMPILER-268_modulepath/src/main => jpms_compile-test-modules/src/test}/java/module-info.java (88%)
 copy src/it/{jpms_patch-module => jpms_compile-test-modules}/verify.groovy (62%)
 delete mode 100644 src/test/resources/unit/compiler-jpms-test/plugin-config.xml
 delete mode 100644 src/test/resources/unit/compiler-jpms-test/src/main/java/module-info.java

-- 
To stop receiving notification emails like this one, please contact
sor@apache.org.

[maven-compiler-plugin] 01/01: [MCOMPILER-341] Compile modules descriptors with TestCompilerMojo

Posted by so...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sor pushed a commit to branch MCOMPILER-341
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git

commit 699fd0955ec83386f0b6a719eb291c202f58b3d2
Author: Christian Stein <so...@gmail.com>
AuthorDate: Tue Apr 17 14:30:50 2018 +0200

    [MCOMPILER-341] Compile modules descriptors with TestCompilerMojo
    
    Prior to this commit module descriptors `module-info.java` were not
    compiled by the TestCompilerMojo. This commit introduces support for
    test sources organized with module descriptors.
    
    See motivation: https://twitter.com/rfscholte/status/927132319374331904
    
    https://issues.apache.org/jira/browse/MCOMPILER-341
---
 .../jpms_compile-test-modules/invoker.properties   |  18 +++
 src/it/jpms_compile-test-modules/pom.xml           |  62 ++++++++
 .../src/main/java/foo/Foo.java                     |  28 ++++
 .../src/main/java/module-info.java                 |  23 +++
 .../src/test/java/foo/FooTests.java                |  37 +++++
 .../src/test/java/module-info.java                 |  28 ++++
 src/it/jpms_compile-test-modules/verify.groovy     |  30 ++++
 .../plugin/compiler/AbstractCompilerMojo.java      |   5 +-
 .../maven/plugin/compiler/TestCompilerMojo.java    | 156 +++++++++++++++------
 .../plugin/compiler/CompilerMojoTestCase.java      |   2 +
 10 files changed, 346 insertions(+), 43 deletions(-)

diff --git a/src/it/jpms_compile-test-modules/invoker.properties b/src/it/jpms_compile-test-modules/invoker.properties
new file mode 100644
index 0000000..9511718
--- /dev/null
+++ b/src/it/jpms_compile-test-modules/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.java.version = 9+
diff --git a/src/it/jpms_compile-test-modules/pom.xml b/src/it/jpms_compile-test-modules/pom.xml
new file mode 100644
index 0000000..5c85ccf
--- /dev/null
+++ b/src/it/jpms_compile-test-modules/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.plugins.compiler.it</groupId>
+    <artifactId>compile-test-modules</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <version>5.2.0</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>@project.version@</version>
+                    <configuration>
+                        <release>9</release>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>
diff --git a/src/it/jpms_compile-test-modules/src/main/java/foo/Foo.java b/src/it/jpms_compile-test-modules/src/main/java/foo/Foo.java
new file mode 100644
index 0000000..2e8fa3f
--- /dev/null
+++ b/src/it/jpms_compile-test-modules/src/main/java/foo/Foo.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package foo;
+
+class Foo
+{
+    Foo()
+    {
+        System.out.println( "Woo Hoo!" );
+    }
+}
\ No newline at end of file
diff --git a/src/it/jpms_compile-test-modules/src/main/java/module-info.java b/src/it/jpms_compile-test-modules/src/main/java/module-info.java
new file mode 100644
index 0000000..dbd4fea
--- /dev/null
+++ b/src/it/jpms_compile-test-modules/src/main/java/module-info.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+module foo
+{
+    requires org.apache.commons.lang3;
+}
diff --git a/src/it/jpms_compile-test-modules/src/test/java/foo/FooTests.java b/src/it/jpms_compile-test-modules/src/test/java/foo/FooTests.java
new file mode 100644
index 0000000..f81f740
--- /dev/null
+++ b/src/it/jpms_compile-test-modules/src/test/java/foo/FooTests.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package foo;
+
+import org.junit.jupiter.api.*;
+
+class FooTests
+{
+    @Test
+    void constructor()
+    {
+        Assertions.assertNotNull( new Foo() );
+    }
+
+    @Test
+    void moduleNameIsFoo()
+    {
+        Assumptions.assumeTrue( Foo.class.getModule().isNamed(), "Calculator resides in a named module" );
+        Assertions.assertEquals( "foo", Foo.class.getModule().getName() );
+    }
+}
\ No newline at end of file
diff --git a/src/it/jpms_compile-test-modules/src/test/java/module-info.java b/src/it/jpms_compile-test-modules/src/test/java/module-info.java
new file mode 100644
index 0000000..abcf3ca
--- /dev/null
+++ b/src/it/jpms_compile-test-modules/src/test/java/module-info.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+open module foo
+{
+    // main
+    requires org.apache.commons.lang3;
+
+    // test
+    requires java.logging;
+    requires org.junit.jupiter.api;
+}
diff --git a/src/it/jpms_compile-test-modules/verify.groovy b/src/it/jpms_compile-test-modules/verify.groovy
new file mode 100644
index 0000000..907175d
--- /dev/null
+++ b/src/it/jpms_compile-test-modules/verify.groovy
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def jpmsArgs = new File( basedir, 'target/test-classes/META-INF/jpms.args' )
+def lines = jpmsArgs.readLines()
+assert lines[0] == "--patch-module" // TODO --patch-module is not required here!
+assert lines[1] == "foo="
+
+assert new File( basedir, "target/classes/module-info.class" ).exists()
+assert new File( basedir, "target/classes/foo/Foo.class" ).exists()
+
+assert new File( basedir, "target/test-classes/module-info.class" ).exists()
+assert new File( basedir, "target/test-classes/foo/Foo.class" ).exists()
+assert new File( basedir, "target/test-classes/foo/FooTests.class" ).exists()
diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
index 294ae23..31179d7 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -1005,7 +1005,10 @@ public abstract class AbstractCompilerMojo
                         
                         if ( descriptor == null )
                         {
-                            getLog().warn( "Can't locate " + file );
+                            if ( ! Files.isDirectory( Paths.get ( file ) ) )
+                            {
+                                getLog().warn( "Can't locate " + file );
+                            }
                         }
                         else if ( !values[0].equals( descriptor.name() ) )
                         {
diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
index 78b0a0b..6fa080e 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -21,6 +21,8 @@ package org.apache.maven.plugin.compiler;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -207,22 +209,84 @@ public class TestCompilerMojo
     protected void preparePaths( Set<File> sourceFiles )
     {
         File mainOutputDirectory = new File( getProject().getBuild().getOutputDirectory() );
-        
-        File mainModuleDescriptor = new File( mainOutputDirectory, "module-info.class" );
 
-        boolean hasTestModuleDescriptor = false;
-        
-        // Go through the source files to respect includes/excludes 
+        File mainModuleDescriptorClassFile = new File( mainOutputDirectory, "module-info.class" );
+        JavaModuleDescriptor mainModuleDescriptor = null;
+
+        File testModuleDescriptorJavaFile = new File( "module-info.java" );
+        JavaModuleDescriptor testModuleDescriptor = null;
+
+        // Go through the source files to respect includes/excludes
         for ( File sourceFile : sourceFiles )
         {
             // @todo verify if it is the root of a sourcedirectory?
             if ( "module-info.java".equals( sourceFile.getName() ) ) 
             {
-                hasTestModuleDescriptor = true;
+                testModuleDescriptorJavaFile = sourceFile;
                 break;
             }
         }
-        
+
+        // Get additional information from the main module descriptor, if available
+        if ( mainModuleDescriptorClassFile.exists() )
+        {
+            ResolvePathsResult<String> result;
+
+            try
+            {
+                ResolvePathsRequest<String> request =
+                        ResolvePathsRequest.withStrings( testPath )
+                                .setMainModuleDescriptor( mainModuleDescriptorClassFile.getAbsolutePath() );
+
+                Toolchain toolchain = getToolchain();
+                if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
+                {
+                    request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() );
+                }
+
+                result = locationManager.resolvePaths( request );
+            }
+            catch ( IOException e )
+            {
+                throw new RuntimeException( e );
+            }
+
+            mainModuleDescriptor = result.getMainModuleDescriptor();
+
+            pathElements = new LinkedHashMap<String, JavaModuleDescriptor>( result.getPathElements().size() );
+            pathElements.putAll( result.getPathElements() );
+
+            modulepathElements = result.getModulepathElements().keySet();
+            classpathElements = result.getClasspathElements();
+        }
+
+        // Get additional information from the test module descriptor, if available
+        if ( testModuleDescriptorJavaFile.exists() )
+        {
+            ResolvePathsResult<String> result;
+
+            try
+            {
+                ResolvePathsRequest<String> request =
+                        ResolvePathsRequest.withStrings( testPath )
+                                .setMainModuleDescriptor( testModuleDescriptorJavaFile.getAbsolutePath() );
+
+                Toolchain toolchain = getToolchain();
+                if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
+                {
+                    request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() );
+                }
+
+                result = locationManager.resolvePaths( request );
+            }
+            catch ( IOException e )
+            {
+                throw new RuntimeException( e );
+            }
+
+            testModuleDescriptor = result.getMainModuleDescriptor();
+        }
+
         if ( release != null )
         {
             if ( Integer.valueOf( release ) < 9 )
@@ -241,17 +305,54 @@ public class TestCompilerMojo
             return;
         }
             
-        if ( hasTestModuleDescriptor )
+        if ( testModuleDescriptor != null )
         {
             modulepathElements = testPath;
             classpathElements = Collections.emptyList();
 
-            if ( mainModuleDescriptor.exists() )
+            if ( mainModuleDescriptor != null )
             {
-                // maybe some extra analysis required
+                if ( getLog().isDebugEnabled() )
+                {
+                    getLog().debug( "Main and test module descriptors exist:" );
+                    getLog().debug( "  main module = " + mainModuleDescriptor.name() );
+                    getLog().debug( "  test module = " + testModuleDescriptor.name() );
+                }
+
+                if ( testModuleDescriptor.name().equals( mainModuleDescriptor.name() ) )
+                {
+                    if ( compilerArgs == null )
+                    {
+                        compilerArgs = new ArrayList<String>();
+                    }
+                    compilerArgs.add( "--patch-module" );
+
+                    StringBuilder patchModuleValue = new StringBuilder();
+                    patchModuleValue.append( testModuleDescriptor.name() );
+                    patchModuleValue.append( '=' );
+
+                    for ( String root : getProject().getCompileSourceRoots() )
+                    {
+                        if ( Files.exists( Paths.get( root ) ) )
+                        {
+                            patchModuleValue.append( root ).append( PS );
+                        }
+                    }
+
+                    compilerArgs.add( patchModuleValue.toString() );
+                }
+                else
+                {
+                    getLog().debug( "Black-box testing - all is ready to compile" );
+                }
             }
             else
             {
+                // No main binaries available? Means we're a test-only project.
+                if ( !mainOutputDirectory.exists() )
+                {
+                    return;
+                }
                 // very odd
                 // Means that main sources must be compiled with -modulesource and -Xmodule:<moduleName>
                 // However, this has a huge impact since you can't simply use it as a classpathEntry 
@@ -262,44 +363,15 @@ public class TestCompilerMojo
         }
         else
         {
-            if ( mainModuleDescriptor.exists() )
+            if ( mainModuleDescriptor != null )
             {
-                ResolvePathsResult<String> result;
-                
-                try
-                {
-                    ResolvePathsRequest<String> request =
-                        ResolvePathsRequest.withStrings( testPath )
-                                           .setMainModuleDescriptor( mainModuleDescriptor.getAbsolutePath() );
-                    
-                    Toolchain toolchain = getToolchain();
-                    if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
-                    {
-                        request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() );
-                    }
-                    
-                    result = locationManager.resolvePaths( request );
-                }
-                catch ( IOException e )
-                {
-                    throw new RuntimeException( e );
-                }
-                
-                JavaModuleDescriptor moduleDescriptor = result.getMainModuleDescriptor();
-                
-                pathElements = new LinkedHashMap<String, JavaModuleDescriptor>( result.getPathElements().size() );
-                pathElements.putAll( result.getPathElements() );
-                                
-                modulepathElements = result.getModulepathElements().keySet();
-                classpathElements = result.getClasspathElements();
-                
                 if ( compilerArgs == null )
                 {
                     compilerArgs = new ArrayList<String>();
                 }
                 compilerArgs.add( "--patch-module" );
                 
-                StringBuilder patchModuleValue = new StringBuilder( moduleDescriptor.name() )
+                StringBuilder patchModuleValue = new StringBuilder( mainModuleDescriptor.name() )
                                 .append( '=' )
                                 .append( mainOutputDirectory )
                                 .append( PS );
@@ -311,7 +383,7 @@ public class TestCompilerMojo
                 compilerArgs.add( patchModuleValue.toString() );
                 
                 compilerArgs.add( "--add-reads" );
-                compilerArgs.add( moduleDescriptor.name() + "=ALL-UNNAMED" );
+                compilerArgs.add( mainModuleDescriptor.name() + "=ALL-UNNAMED" );
             }
             else
             {
diff --git a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
index dfa5ec5..446c015 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
@@ -419,6 +419,8 @@ public class CompilerMojoTestCase
         setVariableValueToObject( mojo, "compileSourceRoots", Collections.singletonList( testSourceRoot ) );
 
         MavenProject project = getMockMavenProject();
+        project.setFile( testPom );
+        project.addCompileSourceRoot("/src/main/java" );
         project.setArtifacts( Collections.singleton( junitArtifact )  );
         project.getBuild().setOutputDirectory( new File( buildDir, "classes" ).getAbsolutePath() );
         setVariableValueToObject( mojo, "project", project );

-- 
To stop receiving notification emails like this one, please contact
sor@apache.org.