mirror of https://github.com/apache/lucene.git
An alternative workaround for gradle -J javac arg passing bug (#11937)
This commit is contained in:
parent
b292151f21
commit
a5e2525946
|
@ -44,15 +44,26 @@ allprojects {
|
|||
// This applies to any JVM when javac runs forked (e.g. error-prone)
|
||||
// Avoiding the fork entirely is best.
|
||||
tasks.withType(JavaCompile) { JavaCompile task ->
|
||||
if (task.path == ":lucene:core:compileMain19Java") {
|
||||
// uses "uschindler" toolchain method, which erases "dweiss" method, but later at configure time
|
||||
task.options.forkOptions.jvmArgs += vmOpts
|
||||
} else if (task.options.forkOptions.javaHome != null) {
|
||||
// uses "dweiss" toolchain method
|
||||
task.options.forkOptions.jvmArgs += vmOpts.collect {"-J" + it}
|
||||
} else {
|
||||
// native or error-prone
|
||||
task.options.forkOptions.jvmArgs += vmOpts
|
||||
}
|
||||
task.options.forkOptions.jvmArgumentProviders.add(new CommandLineArgumentProvider() {
|
||||
@Override
|
||||
Iterable<String> asArguments() {
|
||||
// Gradle bug: https://github.com/gradle/gradle/issues/22746
|
||||
//
|
||||
// Evaluation of this block is delayed until execution time when
|
||||
// we know which "mode" java compiler task will pick and can set arguments
|
||||
// accordingly.
|
||||
//
|
||||
// There is a side-effect to this that arguments passed via the provider
|
||||
// are not part of up-to-date checks but these are internal JVM flags so we
|
||||
// don't care.
|
||||
//
|
||||
// Pass VM options via -J only with a custom javaHome AND when java toolchains are not used.
|
||||
if (task.options.forkOptions.javaHome != null && task.javaCompiler.getOrNull() == null) {
|
||||
return vmOpts.collect {"-J" + it}
|
||||
} else {
|
||||
return vmOpts
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue