-
Notifications
You must be signed in to change notification settings - Fork 5
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
Set JAVA_HOME
in gradle-jdks-setup script
#447
Conversation
Generate changelog in
|
caResources | ||
.readPalantirRootCaFromSystemTruststore() | ||
.map(AliasContentCert::getContent) | ||
.ifPresent(content -> { | ||
try { | ||
Files.write(workingDir.resolve("palantir.crt"), content.getBytes(StandardCharsets.UTF_8)); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to write cert", e); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer need this as we just read certs from the system truststore right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
# >>> Gradle JDK setup >>> | ||
# !! Contents within this block are managed by 'palantir/gradle-jdks' !! | ||
if [ -f gradle/gradle-jdks-setup.sh ]; then | ||
if ! . gradle/gradle-jdks-setup.sh; then | ||
echo "Failed to set up JDK, running gradle/gradle-jdks-setup.sh failed with non-zero exit code" | ||
exit 1 | ||
fi | ||
# Setting JAVA_HOME to the gradle daemon to make sure gradlew uses this jdk for `JAVACMD` | ||
JAVA_HOME="$GRADLE_DAEMON_JDK" | ||
fi | ||
echo "Example.com cert:" $(/root/.gradle/gradle-jdks/amazon-corretto-11.0.21.9.1/bin/keytool -keystore /root/.gradle/gradle-jdks/amazon-corretto-11.0.21.9.1/lib/security/cacerts -list -alias gradleJdks_example.com -storepass changeit) | ||
# <<< Gradle JDK setup <<< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this manually placed here or is it kept up to date with gradlew-patch.sh
somehow?
@@ -42,7 +42,7 @@ tasks.integrationTest { | |||
dependsOn tasks.fatJar | |||
} | |||
|
|||
tasks.build.dependsOn tasks.fatJar | |||
tasks.build.dependsOn tasks.fatJar, tasks.integrationTest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the integration tests were not running before :(
@@ -74,6 +74,7 @@ gradle_daemon_jdk_distribution_local_path=$(read_value "$APP_GRADLE_DIR"/jdks/"$ | |||
"$GRADLE_JDKS_HOME"/"$gradle_daemon_jdk_distribution_local_path"/bin/java -cp "$APP_GRADLE_DIR"/gradle-jdks-setup.jar com.palantir.gradle.jdks.setup.GradleJdkInstallationSetup daemonSetup "$APP_HOME" "$GRADLE_JDKS_HOME/$gradle_daemon_jdk_distribution_local_path" | |||
|
|||
# [Used by ./gradlew only] Setting the Gradle Daemon Java Home to the JDK distribution | |||
set -- "-Dorg.gradle.java.home=$GRADLE_JDKS_HOME/$gradle_daemon_jdk_distribution_local_path" "$@" | |||
export GRADLE_DAEMON_JDK="$GRADLE_JDKS_HOME/$gradle_daemon_jdk_distribution_local_path" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not setting the JAVA_HOME directly here as this script is called by the palantir-gradle-jdks intellij plugin as well and I don't think we should modify the JAVA_HOME there (when gradle jdk automanagement is set, then we also set the Project SDK
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am I right in thinking setting JAVA_HOME wouldn't really do anything bad though? We'd set the JAVA_HOME
then the script would end to no real effect (when called from intellij in the before gradle step right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I think it really matters, the export GRADLE_DAEMON_JDK
approach here is also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am I right in thinking setting JAVA_HOME wouldn't really do anything bad though? We'd set the JAVA_HOME then the script would end to no real effect (when called from intellij in the before gradle step right?
I think you are right (I tested this initially inside Intellij) and it seemed fine. But I wouldn't want to add to any confusion if in the end something inside Intellij changes and the java home is somehow used.
Released 0.52.0 |
Before this PR
In case there is no JAVA_HOME, then ./gradlew will look at
java
executable (https://github.com/palantir/gradle-jdks/blob/develop/gradlew#L142). If nojava
is installed, then the ./gradlew command will fail.example: https://app.circleci.com/pipelines/github/palantir/gradle-jdks/2274/workflows/66d6abd4-88f9-4525-aed9-e91363f1921a/jobs/6532 when trying to drop the "Install Java" step from the circle-ci template (369952b#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47L93-L98)
After this PR
Gradle JDK Automanagement will also set
JAVA_HOME
used by./gradlew
to launch Gradle (https://github.com/palantir/gradle-jdks/blob/develop/gradlew#L128-L150).==COMMIT_MSG==
gradle-jdks-setup.sh script sets
JAVA_HOME
to gradle JDK==COMMIT_MSG==
Possible downsides?