diff --git a/src/it/MCOMPILER-474_recompile-dependent-when-package/dependent-module/pom.xml b/src/it/MCOMPILER-474_recompile-dependent-when-package/dependent-module/pom.xml
new file mode 100644
index 00000000..5ca16685
--- /dev/null
+++ b/src/it/MCOMPILER-474_recompile-dependent-when-package/dependent-module/pom.xml
@@ -0,0 +1,42 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.plugins.compiler.it
+ mcompiler-474-test
+ 1.0-SNAPSHOT
+
+
+ dependent-module
+
+
+
+ org.apache.maven.plugins.compiler.it
+ service
+ 1.0-SNAPSHOT
+
+
+
+
diff --git a/src/it/MCOMPILER-474_recompile-dependent-when-package/dependent-module/src/main/java/Main.java b/src/it/MCOMPILER-474_recompile-dependent-when-package/dependent-module/src/main/java/Main.java
new file mode 100644
index 00000000..dbad7cf7
--- /dev/null
+++ b/src/it/MCOMPILER-474_recompile-dependent-when-package/dependent-module/src/main/java/Main.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+public class Main
+{
+ public static void main( String[] args )
+ {
+ TestService testService = new TestService();
+ testService.run();
+ }
+}
diff --git a/src/it/MCOMPILER-474_recompile-dependent-when-package/invoker.properties b/src/it/MCOMPILER-474_recompile-dependent-when-package/invoker.properties
new file mode 100644
index 00000000..f0faec3e
--- /dev/null
+++ b/src/it/MCOMPILER-474_recompile-dependent-when-package/invoker.properties
@@ -0,0 +1,21 @@
+# 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.goals = clean package
+invoker.goals.2 = groovy:execute
+invoker.goals.3 = package
+invoker.buildResult.3 = failure
diff --git a/src/it/MCOMPILER-474_recompile-dependent-when-package/pom.xml b/src/it/MCOMPILER-474_recompile-dependent-when-package/pom.xml
new file mode 100644
index 00000000..fd7035be
--- /dev/null
+++ b/src/it/MCOMPILER-474_recompile-dependent-when-package/pom.xml
@@ -0,0 +1,79 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.plugins.compiler.it
+ mcompiler-474-test
+ 1.0-SNAPSHOT
+ pom
+
+
+ Integration test to verify that dependent-module is recompiled when run 'mvn package' without 'clean'
+ if module dependency changed.
+ The compilation should fail as dependent-module uses method that no longer exists (run() method of TestService
+ renamed to newMethodName()).
+
+
+
+ dependent-module
+ service
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ @project.version@
+
+
+ org.codehaus.gmaven
+ groovy-maven-plugin
+ 2.0
+
+
+
+
+
+ org.codehaus.groovy
+ groovy-all
+ 2.4.21
+
+
+
+
+
+
+
+
diff --git a/src/it/MCOMPILER-474_recompile-dependent-when-package/service/pom.xml b/src/it/MCOMPILER-474_recompile-dependent-when-package/service/pom.xml
new file mode 100644
index 00000000..26b2c872
--- /dev/null
+++ b/src/it/MCOMPILER-474_recompile-dependent-when-package/service/pom.xml
@@ -0,0 +1,34 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.plugins.compiler.it
+ mcompiler-474-test
+ 1.0-SNAPSHOT
+
+
+ service
+
+
diff --git a/src/it/MCOMPILER-474_recompile-dependent-when-package/service/src/main/java/TestService.java b/src/it/MCOMPILER-474_recompile-dependent-when-package/service/src/main/java/TestService.java
new file mode 100644
index 00000000..7d5e8787
--- /dev/null
+++ b/src/it/MCOMPILER-474_recompile-dependent-when-package/service/src/main/java/TestService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+public class TestService
+{
+
+ public void run()
+ {
+
+ }
+}
diff --git a/src/it/MCOMPILER-474_recompile-dependent-when-package/verify.groovy b/src/it/MCOMPILER-474_recompile-dependent-when-package/verify.groovy
new file mode 100644
index 00000000..11789f72
--- /dev/null
+++ b/src/it/MCOMPILER-474_recompile-dependent-when-package/verify.groovy
@@ -0,0 +1,24 @@
+
+/*
+ * 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 logFile = new File( basedir, 'build.log' )
+assert logFile.exists()
+content = logFile.text
+
+assert content.contains( 'COMPILATION ERROR :' )
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 93fa6aa7..5b3b09c7 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -493,8 +493,8 @@ public abstract class AbstractCompilerMojo
private MojoExecution mojoExecution;
/**
- * file extensions to check timestamp for incremental build
- * default contains only class
+ * File extensions to check timestamp for incremental build.
+ * Default contains only class and jar.
*
* @since 3.1
*/
@@ -1603,7 +1603,7 @@ protected boolean isDependencyChanged()
if ( fileExtensions == null || fileExtensions.isEmpty() )
{
- fileExtensions = Collections.singletonList( "class" );
+ fileExtensions = Collections.unmodifiableList( Arrays.asList( "class", "jar" ) );
}
Date buildStartTime = getBuildStartTime();
@@ -1614,10 +1614,8 @@ protected boolean isDependencyChanged()
for ( String pathElement : pathElements )
{
- // ProjectArtifacts are artifacts which are available in the local project
- // that's the only ones we are interested in now.
File artifactPath = new File( pathElement );
- if ( artifactPath.isDirectory() )
+ if ( artifactPath.isDirectory() || artifactPath.isFile() )
{
if ( hasNewFile( artifactPath, buildStartTime ) )
{