Skip to content

Commit 85b84ef

Browse files
yrodiereSanne
authored andcommitted
HHH-14315 Force JVM options when using toolchains
Apparently Gradle won't just use the same options as in its own JVM. Signed-off-by: Yoann Rodière <[email protected]>
1 parent 9616e24 commit 85b84ef

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

documentation/documentation.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ task aggregateJavadocs(type: Javadoc) {
141141
}
142142

143143
options.addStringOption( 'Xdoclint:none', '-quiet' )
144+
145+
if ( gradle.ext.javaToolchainEnabled ) {
146+
options.setJFlags( getProperty( 'toolchain.javadoc.jvmargs' ).toString().
147+
split( ' ' ).toList().findAll( { !it.isEmpty() } ) )
148+
}
144149
}
145150

146151
if ( gradle.ext.javaToolchainEnabled ) {

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# Keep system properties in sync with test system properties (java-module.gradle)!
1+
# Keep all these properties in sync unless you know what you are doing!
22
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
3+
toolchain.compiler.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
4+
toolchain.javadoc.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
5+
toolchain.launcher.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
36

47
# JDK auto-detection is not quite ready yet in Gradle 6.7.
58
# On Fedora in particular, if you have the package java-1.8.0-openjdk-headless-1.8.0.265.b01-1.fc32.x86_64 installed,

gradle/java-module.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ else {
160160
}
161161
}
162162

163+
// Configure JVM Options
164+
tasks.withType( JavaCompile ).configureEach {
165+
options.forkOptions.jvmArgs.addAll( getProperty( 'toolchain.compiler.jvmargs' ).toString().split( ' ' ) )
166+
}
167+
tasks.withType( Javadoc ).configureEach {
168+
options.setJFlags( getProperty( 'toolchain.javadoc.jvmargs' ).toString().split( ' ' ).toList().findAll( { !it.isEmpty() } ) )
169+
}
170+
163171
// Display version of Java tools
164172
tasks.withType( JavaCompile ).configureEach {
165173
doFirst {
@@ -219,6 +227,10 @@ if ( gradle.ext.javaToolchainEnabled ) {
219227
javaLauncher = javaToolchains.launcherFor {
220228
languageVersion = gradle.ext.javaVersions.test.launcher
221229
}
230+
231+
// Configure JVM Options
232+
jvmArgs.addAll( getProperty( 'toolchain.launcher.jvmargs' ).toString().split( ' ' ) )
233+
222234
// Display version of Java tools
223235
doFirst {
224236
logger.lifecycle "Testing with '${javaLauncher.get().metadata.installationPath}'"

hibernate-core/hibernate-core.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ task testJavassist(type: Test) {
259259
languageVersion = gradle.ext.javaVersions.test.launcher
260260
}
261261

262-
// Display version of Java tools
262+
// Configure JVM Options
263+
jvmArgs.addAll( getProperty( 'toolchain.launcher.jvmargs' ).toString().split( ' ' ) )
264+
265+
// Display version of Java tools
263266
doFirst {
264267
logger.lifecycle "Testing javassist with '${javaLauncher.get().metadata.installationPath}'"
265268
}

0 commit comments

Comments
 (0)