[
https://issues.apache.org/jira/browse/MCOMPILER-310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16351641#comment-16351641
]
Martin Miller commented on MCOMPILER-310:
-----------------------------------------
Well its not a big issue now that I found out about the change required, but I
lost many hours !
I have my own little Annotation Processor that was working under maven, but as
soon as module-info.java are created, it complained it did not find the
<annotationprocessor> specified in the pom. Compiling by hand did work but not
with maven.{color:#e8bf6a}
{color}
by hand:
/usr/lib/jvm/java-9-jdk/bin/javac -d target/classes -classpath
target/classes:../annotation-processor/target/annotation-processor-1.0-SNAPSHOT.jar
-sourcepath example/src/main/java -target 1.9 -source 1.9
src/main/java/com/test/App.java
I don't know how different maven used javac parameters to compile, but it
didn't work out of the box without the processor paths.
Maybe this should be more documented (java 9 modules + annotation processors
not require paths) ?
> Different behaviour between JDK 8 / JDK 9 related to annotation processor
> usage
> -------------------------------------------------------------------------------
>
> Key: MCOMPILER-310
> URL: https://issues.apache.org/jira/browse/MCOMPILER-310
> Project: Maven Compiler Plugin
> Issue Type: Bug
> Affects Versions: 3.7.0
> Reporter: Karl Heinz Marbaise
> Priority: Critical
>
> Based on the
> [https://stackoverflow.com/questions/46500984/immutables-dont-generate-code-with-java-9-with-modules|SO
> question] is looks like we have a difference in behaviour between JDK 8 /
> JDK 9 related to the picking up of annotation processors.
> If you run the following code under JDK 8 (except for a module-info.java
> file):
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <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/xsd/maven-4.0.0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>example</groupId>
> <artifactId>jigsaw</artifactId>
> <version>1.0-SNAPSHOT</version>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
> <dependencies>
> <dependency>
> <groupId>org.immutables</groupId>
> <artifactId>value</artifactId>
> <version>2.5.6</version>
> <scope>provided</scope>
> </dependency>
> </dependencies>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.7.0</version>
> </plugin>
> </plugins>
> </build>
> </project>
> {code}
> The maven-compiler-plugin will automatically pickup the annotation processor
> and produce the classed from the annotation.
> If you run the same with JDK 9 this will not work anymore. Only if you
> explicitly add the annotation processor configuration to
> maven-compiler-plugin it will work as expected:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <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/xsd/maven-4.0.0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>example</groupId>
> <artifactId>jigsaw</artifactId>
> <version>1.0-SNAPSHOT</version>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
> <dependencies>
> <dependency>
> <groupId>org.immutables</groupId>
> <artifactId>value</artifactId>
> <version>2.5.6</version>
> <scope>provided</scope>
> </dependency>
> </dependencies>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.7.0</version>
> <configuration>
> <source>9</source>
> <target>9</target>
> <annotationProcessorPaths>
> <dependency>
> <groupId>org.immutables</groupId>
> <artifactId>value</artifactId>
> <version>2.5.6</version>
> </dependency>
> </annotationProcessorPaths>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
> {code}
> I'm not sure if this is based on the usage of modules (module-path instead of
> classpath)?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)