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 2018/08/07 21:26:26 UTC

[maven-compiler-plugin] 01/01: - changed dependency detection. Default fileExtensions contained '.class', while FileUtils#getExtension( method used in AbstractCompilerMojo#hasNewFile returns file extension without '.' (e.g. 'class')

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

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

commit 9aeb7e14bbb5f910c499b024b284c486a8744177
Author: a.tsyganenko <a....@intive.com>
AuthorDate: Wed Aug 1 13:22:37 2018 +0200

    - changed dependency detection. Default fileExtensions contained '.class', while FileUtils#getExtension( method used in AbstractCompilerMojo#hasNewFile returns file extension without '.' (e.g. 'class')
---
 .../dependent-module/pom.xml                       | 44 +++++++++++++
 .../dependent-module/src/main/java/Main.java       | 27 ++++++++
 .../invoker.properties                             | 21 ++++++
 src/it/MCOMPILER-349_dependencyChanged/pom.xml     | 75 ++++++++++++++++++++++
 .../service/pom.xml                                | 36 +++++++++++
 .../service/src/main/java/TestService.java         | 27 ++++++++
 .../MCOMPILER-349_dependencyChanged/verify.groovy  | 26 ++++++++
 .../plugin/compiler/AbstractCompilerMojo.java      |  2 +-
 8 files changed, 257 insertions(+), 1 deletion(-)

diff --git a/src/it/MCOMPILER-349_dependencyChanged/dependent-module/pom.xml b/src/it/MCOMPILER-349_dependencyChanged/dependent-module/pom.xml
new file mode 100644
index 0000000..c022050
--- /dev/null
+++ b/src/it/MCOMPILER-349_dependencyChanged/dependent-module/pom.xml
@@ -0,0 +1,44 @@
+<?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>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.compiler.it</groupId>
+    <artifactId>mcompiler349-test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>dependent-module</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugins.compiler.it</groupId>
+      <artifactId>service</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+</project>
+
+
diff --git a/src/it/MCOMPILER-349_dependencyChanged/dependent-module/src/main/java/Main.java b/src/it/MCOMPILER-349_dependencyChanged/dependent-module/src/main/java/Main.java
new file mode 100644
index 0000000..f77ad07
--- /dev/null
+++ b/src/it/MCOMPILER-349_dependencyChanged/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();
+    }
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-349_dependencyChanged/invoker.properties b/src/it/MCOMPILER-349_dependencyChanged/invoker.properties
new file mode 100644
index 0000000..572447a
--- /dev/null
+++ b/src/it/MCOMPILER-349_dependencyChanged/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 compile
+invoker.goals.2 = groovy:execute
+invoker.goals.3 = compile
+invoker.buildResult.3 = failure
diff --git a/src/it/MCOMPILER-349_dependencyChanged/pom.xml b/src/it/MCOMPILER-349_dependencyChanged/pom.xml
new file mode 100644
index 0000000..d985a19
--- /dev/null
+++ b/src/it/MCOMPILER-349_dependencyChanged/pom.xml
@@ -0,0 +1,75 @@
+<?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>mcompiler349-test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>
+    IT test to verify that dependent-module recompile, when run 'mvn compile' without 'clean' if module dependency
+    changed.
+    The compilation should fail as dependent-module use method that is no longer exists (run() method of TestService
+    renamed to
+    newMethodName()).
+  </description>
+
+  <modules>
+    <module>dependent-module</module>
+    <module>service</module>
+  </modules>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>@project.version@</version>
+        </plugin>
+        <plugin>
+          <groupId>org.codehaus.gmaven</groupId>
+          <artifactId>groovy-maven-plugin</artifactId>
+          <version>2.0</version>
+          <configuration>
+            <source>
+              def fileToModify = new File(project.basedir, 'service/src/main/java/TestService.java')
+              processFileInplace(fileToModify) { text ->
+                text.replaceAll(/run/, 'newMethodName')
+              }
+
+              def processFileInplace(file, Closure processText) {
+                file.write(processText(file.text))
+              }
+            </source>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+</project>
+
+
diff --git a/src/it/MCOMPILER-349_dependencyChanged/service/pom.xml b/src/it/MCOMPILER-349_dependencyChanged/service/pom.xml
new file mode 100644
index 0000000..57a08fa
--- /dev/null
+++ b/src/it/MCOMPILER-349_dependencyChanged/service/pom.xml
@@ -0,0 +1,36 @@
+<?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>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.compiler.it</groupId>
+    <artifactId>mcompiler349-test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>service</artifactId>
+
+</project>
+
+
diff --git a/src/it/MCOMPILER-349_dependencyChanged/service/src/main/java/TestService.java b/src/it/MCOMPILER-349_dependencyChanged/service/src/main/java/TestService.java
new file mode 100644
index 0000000..df21d26
--- /dev/null
+++ b/src/it/MCOMPILER-349_dependencyChanged/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()
+    {
+
+    }
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-349_dependencyChanged/verify.groovy b/src/it/MCOMPILER-349_dependencyChanged/verify.groovy
new file mode 100644
index 0000000..c218281
--- /dev/null
+++ b/src/it/MCOMPILER-349_dependencyChanged/verify.groovy
@@ -0,0 +1,26 @@
+
+/*
+ * 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 e213f3b..9295499 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -1577,7 +1577,7 @@ public abstract class AbstractCompilerMojo
         if ( fileExtensions == null || fileExtensions.isEmpty() )
         {
             fileExtensions = new ArrayList<String>();
-            fileExtensions.add( ".class" );
+            fileExtensions.add( "class" );
         }
 
         Date buildStartTime = getBuildStartTime();