diff --git a/src/it/MCOMPILER-540/code/pom.xml b/src/it/MCOMPILER-540/code/pom.xml
new file mode 100644
index 000000000..e0847e01d
--- /dev/null
+++ b/src/it/MCOMPILER-540/code/pom.xml
@@ -0,0 +1,87 @@
+
+
+
+ 4.0.0
+
+ foo
+ bar
+ 1.0-SNAPSHOT
+
+ 1.0-SNAPSHOT
+ jar
+ code
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 3.1.0
+
+
+
+
+
+
+
+ actualBuild
+
+
+ foo
+ processor
+ 1.0-SNAPSHOT
+ provided
+
+
+
+
+
+ touchFiles
+
+ false
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ touch-gen-src
+
+ run
+
+ validate
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/it/MCOMPILER-540/code/src/main/java/bar/MyAnnotatedClass.java b/src/it/MCOMPILER-540/code/src/main/java/bar/MyAnnotatedClass.java
new file mode 100644
index 000000000..cc4126d8f
--- /dev/null
+++ b/src/it/MCOMPILER-540/code/src/main/java/bar/MyAnnotatedClass.java
@@ -0,0 +1,29 @@
+/*
+ * 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 bar;
+
+import foo.MyAnnotation;
+
+@MyAnnotation
+public class MyAnnotatedClass {
+ MyGeneratedClass generatedClass = new MyGeneratedClass();
+
+ // foo
+
+}
diff --git a/src/it/MCOMPILER-540/invoker.properties b/src/it/MCOMPILER-540/invoker.properties
new file mode 100644
index 000000000..bf1b59413
--- /dev/null
+++ b/src/it/MCOMPILER-540/invoker.properties
@@ -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.
+
+# NOTE: The first time, we run up to "integration-test" phase which includes the AntRun execution which saves the
+# timestamp of the first JAR for comparison with the timestamp of the JAR from the final "package" invocation.
+# Note:
+invoker.goals.1 = clean compile -PactualBuild
+invoker.goals.2 = validate -PtouchFiles
+invoker.goals.3 = compile -PactualBuild
diff --git a/src/it/MCOMPILER-540/pom.xml b/src/it/MCOMPILER-540/pom.xml
new file mode 100644
index 000000000..3f3e57775
--- /dev/null
+++ b/src/it/MCOMPILER-540/pom.xml
@@ -0,0 +1,70 @@
+
+
+
+ 4.0.0
+ foo
+ bar
+ 1.0-SNAPSHOT
+ pom
+
+
+ UTF-8
+
+
+
+ processor
+ code
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ @project.version@
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ UTF-8
+ true
+ true
+ true
+ false
+
+ -Xlint:all,-processing
+ -Xdoclint:all,-missing,-accessibility
+ -Xmaxerrs
+ 2147483647
+ -Xmaxwarns
+ 2147483647
+
+
+
+
+
+
diff --git a/src/it/MCOMPILER-540/processor/pom.xml b/src/it/MCOMPILER-540/processor/pom.xml
new file mode 100644
index 000000000..8c49c7da7
--- /dev/null
+++ b/src/it/MCOMPILER-540/processor/pom.xml
@@ -0,0 +1,43 @@
+
+
+
+ 4.0.0
+
+ foo
+ bar
+ 1.0-SNAPSHOT
+
+ 1.0-SNAPSHOT
+ processor
+ jar
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ none
+
+
+
+
+
diff --git a/src/it/MCOMPILER-540/processor/src/main/java/foo/MyAnnotation.java b/src/it/MCOMPILER-540/processor/src/main/java/foo/MyAnnotation.java
new file mode 100644
index 000000000..88431aef8
--- /dev/null
+++ b/src/it/MCOMPILER-540/processor/src/main/java/foo/MyAnnotation.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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.SOURCE)
+@Target(ElementType.TYPE)
+public @interface MyAnnotation {}
diff --git a/src/it/MCOMPILER-540/processor/src/main/java/foo/MyProcessor.java b/src/it/MCOMPILER-540/processor/src/main/java/foo/MyProcessor.java
new file mode 100644
index 000000000..88db35760
--- /dev/null
+++ b/src/it/MCOMPILER-540/processor/src/main/java/foo/MyProcessor.java
@@ -0,0 +1,67 @@
+/*
+ * 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 javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Set;
+
+@SupportedAnnotationTypes("foo.MyAnnotation")
+public class MyProcessor extends AbstractProcessor {
+
+ private int procRun = 0;
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latestSupported();
+ }
+
+ @Override
+ public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ try {
+ generate(annotations, roundEnv);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ return false;
+ }
+
+ private void generate(Set extends TypeElement> annotations, RoundEnvironment roundEnv) throws IOException {
+ Messager msg = processingEnv.getMessager();
+ msg.printMessage(Diagnostic.Kind.NOTE, String.format("[%d]: Hello Info", procRun));
+ msg.printMessage(Diagnostic.Kind.WARNING, String.format("[%d]: Hello Warning", procRun));
+ procRun++;
+
+ if (procRun > 1) {
+ return;
+ }
+
+ JavaFileObject file = processingEnv.getFiler().createSourceFile("bar.MyGeneratedClass");
+ try (Writer writer = file.openWriter()) {
+ writer.write("package bar;\npublic class MyGeneratedClass {}");
+ }
+ }
+}
diff --git a/src/it/MCOMPILER-540/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/src/it/MCOMPILER-540/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 000000000..678af7bad
--- /dev/null
+++ b/src/it/MCOMPILER-540/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -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.
+
+foo.MyProcessor
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 e9290bcf9..1aebf4c89 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -1000,6 +1000,7 @@ private void executeReal() throws MojoExecutionException, CompilationFailureExce
return;
}
+ staleSources = filterSourceFiles(staleSources);
compilerConfiguration.setSourceFiles(staleSources);
try {
@@ -1887,6 +1888,17 @@ public void setRelease(String release) {
targetOrReleaseSet = true;
}
+ private Set filterSourceFiles(Set sourceFiles) {
+ final File generatedSources = getGeneratedSourcesDirectory();
+ if (generatedSources == null) {
+ return sourceFiles;
+ }
+ final String generatedSourcesPath = generatedSources.getAbsolutePath();
+ return sourceFiles.stream()
+ .filter(x -> !x.getAbsolutePath().startsWith(generatedSourcesPath))
+ .collect(Collectors.toSet());
+ }
+
final String getImplicit() {
return implicit;
}