You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Scholte (JIRA)" <ji...@apache.org> on 2019/06/06 19:14:00 UTC

[jira] [Closed] (MTOOLCHAINS-28) Toolchain does not respect fork

     [ https://issues.apache.org/jira/browse/MTOOLCHAINS-28?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Scholte closed MTOOLCHAINS-28.
-------------------------------------
    Resolution: Invalid
      Assignee: Robert Scholte

bq. Forked process will use JDK 1.8, not Java 11, even with toolchain.

Looking at you configuration, the main issue that toolchain is not picked up is because it configured within pluginManagement. If you move it to project/build/plugins you'll the toolchain will be picked up.

The analysis from Jim is correct, and the comment above the mentioned line probably says it all: even though you want to use a different compilerId, it should still use the jdk. It is quite easy to verify: set the executable-parameter to Java 11 and you'll see a different error.

This is something that needs to be fixed in the maven-compiler-plugin, so I'll close this as "Invalid"

> Toolchain does not respect fork
> -------------------------------
>
>                 Key: MTOOLCHAINS-28
>                 URL: https://issues.apache.org/jira/browse/MTOOLCHAINS-28
>             Project: Maven Toolchains Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>         Environment: Java 11, JDK 1.8, Maven 3.5.0
>            Reporter: Max Edmiston
>            Assignee: Robert Scholte
>            Priority: Major
>
> I am using maven-compiler-plugin with fork option, configured for Java 11 using the toolchain plugin. I have set my local environment to use JDK 1.8 by default. Forked process will use JDK 1.8, not Java 11, even with toolchain. I have tried this with and without the jdkToolchain xml tag in maven-compiler-plugin configuration.
> Relevant pom.xml:
>  
> {code:xml}
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-compiler-plugin</artifactId>
>     <version>${maven-compiler-plugin.version}</version>
>     <configuration>
>         <compilerId>groovy-eclipse-compiler</compilerId>
>         <fork>true</fork>
>         <compilerArguments>
>             <javaAgentClass>lombok.launch.Agent</javaAgentClass>
>         </compilerArguments>
>     </configuration>
>     <dependencies>
>         <dependency>
>             <groupId>org.codehaus.groovy</groupId>
>             <artifactId>groovy-eclipse-compiler</artifactId>
>             <version>${groovy-eclipse-compiler.version}</version>
>         </dependency>
>         <dependency>
>             <groupId>org.codehaus.groovy</groupId>
>             <artifactId>groovy-eclipse-batch</artifactId>
>             <version>${groovy-eclipse-batch.version}</version>
>         </dependency>
>         <dependency>
>         <groupId>org.projectlombok</groupId>
>         <artifactId>lombok</artifactId>
>         <version>1.18.6</version>
>         </dependency>
>     </dependencies>
> </plugin>
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-toolchains-plugin</artifactId>
>     <version>1.1</version>
>     <executions>
>         <execution>
>             <goals>
>                 <goal>toolchain</goal>
>             </goals>
>         </execution>
>     </executions>
>     <configuration>
>         <toolchains>
>             <jdk>
>                 <version>11</version>
>                 <vendor>openjdk</vendor>
>             </jdk>
>         </toolchains>
>     </configuration>
> </plugin>
> {code}
>  
> toolchains.xml:
> {code:xml}
> <?xml version="1.0" encoding="UTF8"?> 
> <toolchains> 
>     <toolchain> 
>         <type>jdk</type> 
>         <provides> 
>             <version>11</version> 
>             <vendor>openjdk</vendor> 
>         </provides> 
>         <configuration> 
>             <jdkHome>/Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home/</jdkHome> 
>         </configuration> 
>     </toolchain> 
> </toolchains>
> {code}
> Sample error:
> {code:java}
> [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile)  ---
> [INFO] Toolchain in maven-compiler-plugin: JDK[/Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home/]
> [INFO] Changes detected - recompiling the module!
> [INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
> [INFO] Compiling in a forked process using /Users/max.edmiston/.m2/repository/org/codehaus/groovy/groovy-eclipse-batch/2.5.4-01/groovy-eclipse-batch-2.5.4-01.jar
> [INFO] -------------------------------------------------------------
> [ERROR] COMPILATION ERROR : 
> [INFO] -------------------------------------------------------------
> [ERROR] Failure executing groovy-eclipse compiler:
> ----------
> 1. ERROR in ***Test.java (at line 39)
> 	***.stream().findFirst().orElseThrow();
> 	                          ^^^^^^^^^^^
> The method orElseThrow(Supplier<? extends X>) in the type Optional<Thing> is not applicable for the arguments ()
> ...
> ----------
> 5 problems (5 errors)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)