question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maven jvm.config instead of fork/compilerArgs

See original GitHub issue

The error prone maven instructions for jdk16+^1 recommend using compilerArgs and fork. I was able to supply those same args to maven itself via .mvn/jvm.config file^2 and get a 4x improvement of build times by no longer forking the compiler.

Anecdotally, with my sample size of 1, using a maven reactor with 80 modules the build time for mvn clean compile was 11s using .mvn/jvm.config and 44s when forking the compiler.

The maven-compiler-plugin docs^3 leads me to believe that fork was designed for use cases where a different JDK was wanting to be used, rather than for configuration isolation while using the default javac. Thats not to say it can’t also work when config isolation is desired, like in this case.

Does errorprone need that level of isolation on the exports/opens configuration? Would the maintainers be open to updating the docs to include the .mvn/jvm.config option with the pros/con between the two approaches? or if the config isolation is not needed and the performance impact is impactful enough, change the recommendation to the non-forking option.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
hisenercommented, Dec 31, 2021

get a 4x improvement of build times by no longer forking the compiler.

@mattnelson Funnily enough, I applied the exact change on Tuesday, and the build times went from ~20 minutes to 8-9 minutes. However, the downside is that the Metaspace usage went up because the number of classes loaded increased significantly. Did you experience the same?


it’s really just about having a way to pass the JVM flags to javac, and passing -J flags to javac only works with fork enabled.

@cushon By looking at the maven-compiler-plugin code, I suspect the following description misleading:

Sets the arguments to be passed to the compiler if fork is set to true. https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#compilerArgs

Should we file an MCOMPILER ticket? 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Apache Maven
MAVEN_OPTS environment variable: This variable contains parameters used to start up the JVM running Maven and can be used to supply additional options...
Read more >
IDEA-205178 - YouTrack
Possible solution: - Check your maven runner VM options. Open Maven Runner settings. - Check your .mvn/jvm.config in module ...
Read more >
Find Java options used by Maven - Stack Overflow
mvn /jvm.config file per project. It's an alternative to MAVEN_OPTS and a more narrowed scope (per project). However, since it sis a new...
Read more >
Part 7 – Configuring Apache Maven - C. V. Guntur
mvn /jvm.config file is a more modern take on specifying JVM arguments and can be used in lieu of the MAVEN_OPTS shared earlier....
Read more >
How to Set Default Maven and Java settings per Project
config file in place, when we run mvn clean package from the command-line, Maven will automatically pull these options in. Java.config. More ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found