This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new eb7840c [MCOMPILER-567] - Fail to compile if the
"generated-sources/annotations" does not exist
eb7840c is described below
commit eb7840cf9f0d29c1cf805c5aec180f7f78e454ac
Author: Jorge Solórzano <[email protected]>
AuthorDate: Tue Dec 19 01:27:52 2023 +0100
[MCOMPILER-567] - Fail to compile if the "generated-sources/annotations"
does not exist
Signed-off-by: Jorge Solórzano <[email protected]>
---
src/it/MCOMPILER-567-kt/invoker.properties | 18 +++++
src/it/MCOMPILER-567-kt/pom.xml | 78 ++++++++++++++++++++++
.../src/main/kotlin/KotlinService.kt | 26 ++++++++
src/it/MCOMPILER-567-kt/verify.groovy | 23 +++++++
src/it/MCOMPILER-567/invoker.properties | 18 +++++
src/it/MCOMPILER-567/pom.xml | 39 +++++++++++
src/it/MCOMPILER-567/src/main/java/Main.java | 19 ++++++
src/it/MCOMPILER-567/src/test/java/.keep | 16 +++++
src/it/MCOMPILER-567/verify.groovy | 23 +++++++
.../plugin/compiler/AbstractCompilerMojo.java | 6 +-
10 files changed, 264 insertions(+), 2 deletions(-)
diff --git a/src/it/MCOMPILER-567-kt/invoker.properties
b/src/it/MCOMPILER-567-kt/invoker.properties
new file mode 100644
index 0000000..df01a38
--- /dev/null
+++ b/src/it/MCOMPILER-567-kt/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.goals = clean compile
diff --git a/src/it/MCOMPILER-567-kt/pom.xml b/src/it/MCOMPILER-567-kt/pom.xml
new file mode 100644
index 0000000..a4cf61d
--- /dev/null
+++ b/src/it/MCOMPILER-567-kt/pom.xml
@@ -0,0 +1,78 @@
+<?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</groupId>
+ <artifactId>MCOMPILER-567-kt</artifactId>
+ <name>MCOMPILER-567-kt</name>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib</artifactId>
+ <version>1.9.21</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-maven-plugin</artifactId>
+ <version>1.9.21</version>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>java-compile</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/MCOMPILER-567-kt/src/main/kotlin/KotlinService.kt
b/src/it/MCOMPILER-567-kt/src/main/kotlin/KotlinService.kt
new file mode 100644
index 0000000..31aee97
--- /dev/null
+++ b/src/it/MCOMPILER-567-kt/src/main/kotlin/KotlinService.kt
@@ -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.
+ */
+
+class KotlinService {
+
+ fun sayHello() {
+ System.out.println("Kotlin says 'Hello World!'")
+ }
+
+}
diff --git a/src/it/MCOMPILER-567-kt/verify.groovy
b/src/it/MCOMPILER-567-kt/verify.groovy
new file mode 100644
index 0000000..5d1960e
--- /dev/null
+++ b/src/it/MCOMPILER-567-kt/verify.groovy
@@ -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.
+ */
+
+File target = new File( basedir, "target" );
+assert target.isDirectory()
+
+assert new File( target, "classes/KotlinService.class" ).exists();
diff --git a/src/it/MCOMPILER-567/invoker.properties
b/src/it/MCOMPILER-567/invoker.properties
new file mode 100644
index 0000000..e08297d
--- /dev/null
+++ b/src/it/MCOMPILER-567/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.goals = test
diff --git a/src/it/MCOMPILER-567/pom.xml b/src/it/MCOMPILER-567/pom.xml
new file mode 100644
index 0000000..1c0af3c
--- /dev/null
+++ b/src/it/MCOMPILER-567/pom.xml
@@ -0,0 +1,39 @@
+<?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</groupId>
+ <artifactId>MCOMPILER-567</artifactId>
+ <name>MCOMPILER-567</name>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/MCOMPILER-567/src/main/java/Main.java
b/src/it/MCOMPILER-567/src/main/java/Main.java
new file mode 100644
index 0000000..48add13
--- /dev/null
+++ b/src/it/MCOMPILER-567/src/main/java/Main.java
@@ -0,0 +1,19 @@
+/*
+ * 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 {}
diff --git a/src/it/MCOMPILER-567/src/test/java/.keep
b/src/it/MCOMPILER-567/src/test/java/.keep
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/src/it/MCOMPILER-567/src/test/java/.keep
@@ -0,0 +1,16 @@
+# 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.
diff --git a/src/it/MCOMPILER-567/verify.groovy
b/src/it/MCOMPILER-567/verify.groovy
new file mode 100644
index 0000000..d71fe34
--- /dev/null
+++ b/src/it/MCOMPILER-567/verify.groovy
@@ -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.
+ */
+
+File target = new File( basedir, "target" );
+assert target.isDirectory()
+
+assert new File( target, "classes/Main.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 fb285af..83fa779 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -1166,12 +1166,14 @@ public abstract class AbstractCompilerMojo extends
AbstractMojo {
if (useIncrementalCompilation) {
incrementalBuildHelperRequest.outputDirectory(getOutputDirectory());
- // Cleanup the generated source files created by annotation
processing
- // they are regenerated by the java compiler.
+ // MCOMPILER-333: Cleanup the generated source files created by
annotation processing
+ // to avoid issues with `javac` compiler when the source code is
rebuild.
if (getGeneratedSourcesDirectory() != null) {
try (Stream<Path> walk =
Files.walk(getGeneratedSourcesDirectory().toPath())) {
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
+ // MCOMPILER-567: The directory must already exist because
javac does not create it.
+
Files.createDirectories(getGeneratedSourcesDirectory().toPath());
} catch (IOException ex) {
getLog().warn("I/O error deleting the annotation
processing generated files: " + ex.getMessage());
}