You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Karl Heinz Marbaise (JIRA)" <ji...@apache.org> on 2017/09/30 16:49:00 UTC

[jira] [Created] (MCOMPILER-310) Different behaviour between JDK 8 / JDK 9 related to annotation processor usage

Karl Heinz Marbaise created MCOMPILER-310:
---------------------------------------------

             Summary: 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
(v6.4.14#64029)