Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target Java 8 in Java 9 build #4037

Merged

Conversation

ssoloff
Copy link
Member

@ssoloff ssoloff commented Sep 13, 2018

Overview

Fixes #2803.

Functional Changes

  • Pass --release 8 to the compiler in the Java 9 build to ensure it links against the Java 8 runtime.
  • Because the --release flag only uses the public JDK, it does not include any extensions that may be installed, and JavaFX is considered an extension to Java 8. Therefore, we have to bring the JavaFX 8 runtime in as a dependency. This dependency is not available publicly, so the version from the latest JDK 8 was added to our assets repo (Add JavaFX 8 library assets#21).

Manual Testing Performed

Ran a local build using Java 9 to produce the game-headed artifacts. Ran the portable build artifact under Java 8 and verified I could connect to the lobby (the original problem reported in #2801). Also verified the JavaFX client ran correctly from both Java 8 and Java 9.

apply from: "${rootProject.projectDir}/gradle/scripts/release.gradle"
apply from: "${rootProject.projectDir}/gradle/scripts/remote-lib.gradle"
apply from: "${rootProject.projectDir}/gradle/scripts/version.gradle"

group = 'triplea'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a regression from when I was consolidating the buildscripts. The sourceCompatibility and targetCompatibility properties must be set after the java plugin is applied, otherwise they will be overwritten with the version of the running JVM.

testCompile project(':test-common')
testCompile "org.sonatype.goodies:goodies-prefs:$sonatypeGoodiesPrefsVersion"
testCompile "org.testfx:testfx-core:$testFxVersion"
testCompile "org.testfx:testfx-junit5:$testFxVersion"

if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
testCompileOnly remoteLib(javaFxRuntimeUrl)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the testCompileOnly configuration does not inherit from the compileOnly configuration. Research shows this appears to be a design decision by the Gradle maintainers (to be different than how Maven works with its provideCompile configuration).


def remoteLibsDir = file('.remote-libs')

ext.remoteLib = { url ->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I had to re-introduce this functionality in order to download the JavaFX dependency from the assets repo. To keep things clean, I extracted all the related code into this standalone script.

@RoiEXLab RoiEXLab merged commit 0123ba4 into triplea-game:master Sep 13, 2018
@ssoloff ssoloff deleted the issue-2803-target-java-8-in-java-9-build branch September 13, 2018 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants