Gradle problems using Java 9 onwards due to bug in java Command-Line Argument Files


I noticed Gradle is making use of the new java Command-Line Argument Files which was a feature introduced in Java9.

Unfortunately, due to a bug in this feature, there are not uncommon cases where Gradle builds fail, and do not fail consistently. The JDK bug is reported here:

Please can you tell me whether there is a flag in gradle that I can set, to avoid using Command-Line Argument Files to pass the classpath to gradle workers?

There is no switch and I don’t think it would help, because if your classpath is very long (as described in the JDK bug), you would probably get a “command line too long” instead.

This only became an issue when I migrated my project from Java8 to Java9. The classpath wasn’t too long in Java8 so it should continue to work in Java9 if a switch was made available.

That’s because we had a hack to keep it short, but that doesn’t work anymore in Java 9.