IntelliJ ignores Maven compiler options

Answered


I need to compile some Java classes using "javac -parameters" in a Maven project. (So that I can use the Jackson Parameter-names module for json without annotations.)

This can be done by using the following Maven config:

 <artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>

There are two ways to compile classes in IntelliJ: 1) via Maven "compile" and/or 2) via automatically via IntelliJ when you edit a file. The problem is that when you specify compiler options in pom.xml, IntelliJ doesn't use these options when compiling files automatically when you edit them.

A solution is to add "-parameters" in the IntelliJ settings: "Settings" > "Build, Execution, Deployment" > "Compiler" > "Java Compiler" > add "-parameters" as "Additional command line parameters".

But I'm looking for a way to have IntelliJ automatically use the pom.xml compiler config/options. Is this possible?

 

0
3 comments

There is an open request for this feature, please vote: https://youtrack.jetbrains.com/v2/issue/IDEA-143742.

0

Hi Serge and thanks for linking the issue.

However, this issue and all related ones seem to be implemented in build 183.65, but were not included into any IDEA version. So now we cannot vote for any of these issues anymore.

Also, this issue becomes really hot with JDK 9/10 --add-modules javac param, because options like these need to be manually configured in IDE UI to work properly with Build / Rebuild All / Run Test / ...:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerVersion>${java.version}</compilerVersion>
<source>${java.version}</source>
<target>${java.version}</target>
<parameters>true</parameters>
<compilerArgument>--add-modules=jdk.incubator.httpclient</compilerArgument>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.1.1</version> <!-- Use newer version of ASM for Java 10 -->
</dependency>
</dependencies>
</plugin>

Please provide some ETA on feature availability.

 

0

Hi, the fix will be available in a next EAP build (the one after 182.3208.16).

0

Please sign in to leave a comment.