├── changelog ├── @unreleased │ └── .gitkeep ├── 0.2.0 │ └── pr-15.v2.yml ├── 0.25.0 │ └── pr-89.v2.yml ├── 0.40.0 │ └── pr-376.v2.yml ├── 0.4.0 │ └── pr-19.v2.yml ├── 0.41.0 │ └── pr-377.v2.yml ├── 0.48.0 │ └── pr-420.v2.yml ├── 0.57.0 │ └── pr-465.v2.yml ├── 0.9.0 │ └── pr-36.v2.yml ├── 0.14.0 │ └── pr-55.v2.yml ├── 0.23.0 │ └── pr-86.v2.yml ├── 0.51.0 │ └── pr-437.v2.yml ├── 0.20.0 │ └── pr-73.v2.yml ├── 0.28.0 │ └── pr-141.v2.yml ├── 0.3.0 │ └── pr-17.v2.yml ├── 0.56.0 │ └── pr-461.v2.yml ├── 0.1.0 │ └── pr-1.v2.yml ├── 0.26.0 │ └── pr-98.v2.yml ├── 0.53.0 │ └── pr-453.v2.yml ├── 0.64.0 │ └── pr-479.v2.yml ├── 0.10.0 │ └── pr-39.v2.yml ├── 0.11.0 │ └── pr-40.v2.yml ├── 0.18.0 │ └── pr-68.v2.yml ├── 0.5.0 │ └── pr-26.v2.yml ├── 0.52.0 │ ├── pr-436.v2.yml │ └── pr-447.v2.yml ├── 0.36.0 │ └── pr-294.v2.yml ├── 0.58.0 │ └── pr-472.v2.yml ├── 0.61.0 │ └── pr-497.v2.yml ├── 0.63.0 │ └── pr-493.v2.yml ├── 0.65.0 │ └── pr-534.v2.yml ├── 0.68.0 │ ├── pr-544.v2.yml │ └── pr-575.v2.yml ├── 0.8.0 │ └── pr-33.v2.yml ├── 0.50.0 │ └── pr-432.v2.yml ├── 0.55.0 │ └── pr-458.v2.yml ├── 0.37.0 │ └── pr-338.v2.yml ├── 0.38.0 │ └── pr-341.v2.yml ├── 0.47.0 │ ├── pr-379.v2.yml │ └── pr-408.v2.yml ├── 0.44.0 │ └── pr-386.v2.yml ├── 0.54.0 │ └── pr-452.v2.yml ├── 0.6.0 │ └── pr-23.v2.yml ├── 0.45.0 │ └── pr-396.v2.yml ├── 0.59.0 │ └── pr-482.v2.yml ├── 0.42.0 │ └── pr-382.v2.yml ├── 0.46.0 │ └── pr-403.v2.yml ├── 0.35.0 │ └── pr-286.v2.yml ├── 0.13.0 │ └── pr-46.v2.yml ├── 0.39.0 │ └── pr-360.v2.yml ├── 0.24.0 │ └── pr-88.v2.yml ├── 0.69.0 │ └── pr-577.v2.yml ├── 0.43.0 │ └── pr-381.v2.yml ├── 0.12.0 │ └── pr-41.v2.yml ├── 0.19.0 │ └── pr-71.v2.yml ├── 0.62.0 │ └── pr-507.v2.yml ├── 0.66.0 │ └── pr-536.v2.yml ├── 0.7.0 │ └── pr-29.v2.yml ├── 0.27.0 │ └── pr-99.v2.yml ├── 0.29.0 │ └── pr-161.v2.yml ├── 0.32.0 │ └── pr-178.v2.yml ├── 0.30.0 │ └── pr-163.v2.yml ├── 0.60.0 │ └── pr-499.v2.yml ├── 0.15.0 │ └── pr-56.v2.yml ├── 0.31.0 │ └── pr-168.v2.yml ├── 0.34.0 │ └── pr-240.v2.yml └── 0.16.0 │ └── pr-51.v2.yml ├── gradle ├── gradle-daemon-jdk-version ├── jdks │ ├── 11 │ │ ├── macos │ │ │ ├── aarch64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ │ └── x86-64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ ├── windows │ │ │ ├── x86-64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ │ └── x86 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ ├── linux-glibc │ │ │ ├── aarch64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ │ ├── x86-64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ │ └── x86 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ └── linux-musl │ │ │ ├── aarch64 │ │ │ ├── local-path │ │ │ └── download-url │ │ │ └── x86-64 │ │ │ ├── local-path │ │ │ └── download-url │ ├── 17 │ │ ├── macos │ │ │ ├── aarch64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ │ └── x86-64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ ├── windows │ │ │ └── x86-64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ ├── linux-glibc │ │ │ ├── x86-64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ │ └── aarch64 │ │ │ │ ├── local-path │ │ │ │ └── download-url │ │ └── linux-musl │ │ │ ├── aarch64 │ │ │ ├── local-path │ │ │ └── download-url │ │ │ └── x86-64 │ │ │ ├── local-path │ │ │ └── download-url │ └── 21 │ │ ├── macos │ │ ├── aarch64 │ │ │ ├── local-path │ │ │ └── download-url │ │ └── x86-64 │ │ │ ├── local-path │ │ │ └── download-url │ │ ├── windows │ │ └── x86-64 │ │ │ ├── local-path │ │ │ └── download-url │ │ ├── linux-glibc │ │ ├── aarch64 │ │ │ ├── local-path │ │ │ └── download-url │ │ └── x86-64 │ │ │ ├── local-path │ │ │ └── download-url │ │ └── linux-musl │ │ ├── aarch64 │ │ ├── local-path │ │ └── download-url │ │ └── x86-64 │ │ ├── local-path │ │ └── download-url ├── gradle-jdks-setup.jar ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── gradle-jdks-setup.sh ├── gradle-jdks-setup-common ├── src │ ├── test │ │ ├── resources │ │ │ ├── file_no_patch.txt │ │ │ ├── patch.txt │ │ │ └── file_with_patch.txt │ │ └── java │ │ │ └── com │ │ │ └── palantir │ │ │ └── gradle │ │ │ └── jdks │ │ │ └── setup │ │ │ └── common │ │ │ └── GradleJdkPatchHelperTest.java │ └── main │ │ └── java │ │ └── com │ │ └── palantir │ │ └── gradle │ │ └── jdks │ │ └── setup │ │ └── common │ │ ├── CurrentArch.java │ │ ├── Arch.java │ │ └── UiNames.java └── build.gradle ├── .circleci ├── .gitattributes └── template.sh ├── gradle-jdks-setup ├── Intellij Gradle JDK.png ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── palantir │ │ │ │ └── gradle │ │ │ │ └── jdks │ │ │ │ └── setup │ │ │ │ ├── ILogger.java │ │ │ │ ├── StdErrLogger.java │ │ │ │ ├── AliasContentCert.java │ │ │ │ └── FileUtils.java │ │ └── resources │ │ │ └── gradle-jdks-setup.sh │ └── test │ │ ├── resources │ │ ├── apple-kdc-cert-with-duplicate-extension.pem │ │ ├── strongloop-cert-with-v3-extensions-but-v1-version.pem │ │ └── amazon-cas-with-whitespace-between.pem │ │ └── java │ │ └── com │ │ └── palantir │ │ └── gradle │ │ └── jdks │ │ └── setup │ │ ├── CommandRunnerTest.java │ │ ├── CaResourcesTest.java │ │ └── GradleJdkInstallationSetupTest.java └── build.gradle ├── gradle-jdks-excavator-configurations ├── src │ └── main │ │ └── resources │ │ ├── gradle-jdks-functions.sh │ │ └── install-jdks.sh └── build.gradle ├── .changelog.yml ├── gradle-jdks-enablement ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── palantir │ └── gradle │ └── jdks │ └── enablement │ └── GradleJdksEnablement.java ├── gradle-jdks-test-common └── build.gradle ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── stale.yml ├── gradle-jdks-distributions ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── palantir │ │ └── gradle │ │ └── jdks │ │ ├── ZuluVersionUtils.java │ │ └── JdkDistributionName.java │ └── test │ └── java │ └── com │ └── palantir │ └── gradle │ └── jdks │ ├── JdkDistributionNameTest.java │ └── ZuluVersionUtilsTest.java ├── .bulldozer.yml ├── gradle.properties ├── .excavator.yml ├── gradle-jdks ├── src │ ├── main │ │ ├── resources │ │ │ └── gradlew-patch.sh │ │ └── java │ │ │ └── com │ │ │ └── palantir │ │ │ └── gradle │ │ │ └── jdks │ │ │ ├── JdkDistribution.java │ │ │ ├── JdkDistributionExtension.java │ │ │ ├── PalantirCaExtension.java │ │ │ ├── JdkOsArchExtension.java │ │ │ ├── ConfigureUtil.java │ │ │ ├── JdkRelease.java │ │ │ ├── JdkDistributionConfig.java │ │ │ ├── SystemTools.java │ │ │ ├── JdkPath.java │ │ │ ├── GradleLogger.java │ │ │ ├── JdkDistributions.java │ │ │ ├── CaCerts.java │ │ │ ├── SynchronizedInterface.java │ │ │ ├── JdkDownloader.java │ │ │ ├── JdkDownloaders.java │ │ │ ├── JdkSpec.java │ │ │ ├── JdkOsExtension.java │ │ │ ├── PalantirCaPlugin.java │ │ │ ├── GraalVmCeDistribution.java │ │ │ ├── AmazonCorrettoJdkDistribution.java │ │ │ ├── flow │ │ │ └── ToolchainFailureFlowActionsPlugin.java │ │ │ ├── JdkExtension.java │ │ │ ├── GradleJdksJavaInstallationMetadata.java │ │ │ ├── GenerateGradleJdksConfigsTask.java │ │ │ ├── JdksPlugin.java │ │ │ ├── JarResources.java │ │ │ ├── SetupJdksTask.java │ │ │ ├── BaselineJavaJdksPlugin.java │ │ │ ├── CheckGradleJdksConfigsTask.java │ │ │ └── AzulZuluJdkDistribution.java │ ├── integTest │ │ └── resources │ │ │ ├── template.Dockerfile │ │ │ └── testing-script.template.sh │ └── test │ │ └── groovy │ │ └── com │ │ └── palantir │ │ └── gradle │ │ └── jdks │ │ ├── GraalVmCeDistributionTest.java │ │ ├── JdksExtensionProjectSpec.groovy │ │ ├── AmazonCorrettoJdkDistributionTest.java │ │ ├── GradleJdkIntegrationSpec.groovy │ │ ├── PalantirCaPluginIntegrationSpec.groovy │ │ └── AzulZuluJdkDistributionTest.java └── build.gradle ├── gradle-jdks-json ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── palantir │ └── gradle │ └── jdks │ └── json │ ├── package-info.java │ ├── JdkOsArchInfoJson.java │ ├── JdksInfoJson.java │ ├── JdkOsInfoJson.java │ └── JdkInfoJson.java ├── .gitignore ├── settings.gradle ├── .baseline ├── copyright │ └── 001_apache-2.0.txt ├── eclipse │ └── dynamic │ │ └── dotfile.checkstyle └── checkstyle │ └── checkstyle-suppressions.xml ├── versions.props ├── gradle-jdks-settings ├── build.gradle └── src │ └── test │ └── groovy │ └── com │ └── palantir │ └── gradle │ └── jdks │ └── settings │ └── ToolchainJdksSettingsPluginTest.groovy └── gradlew.bat /changelog/@unreleased/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gradle/gradle-daemon-jdk-version: -------------------------------------------------------------------------------- 1 | 21 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/macos/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/macos/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/windows/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/windows/x86/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/macos/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-17.0.17.10.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/macos/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-17.0.17.10.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/windows/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-17.0.17.10.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/macos/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-21.0.9.10.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/macos/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-21.0.9.10.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/windows/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-21.0.9.10.1 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-glibc/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1-glibc 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-glibc/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1-glibc 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-glibc/x86/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1-glibc 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-musl/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1-musl 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-musl/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-11.0.29.7.1-musl 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-glibc/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-17.0.17.10.1-glibc 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-musl/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-17.0.17.10.1-musl 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-musl/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-17.0.17.10.1-musl 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-glibc/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-21.0.9.11.1-glibc 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-glibc/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-21.0.9.11.1-glibc 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-musl/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-21.0.9.11.1-musl 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-musl/x86-64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-21.0.9.11.1-musl 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-glibc/aarch64/local-path: -------------------------------------------------------------------------------- 1 | amazon-corretto-17.0.17.10.1-glibc 2 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/src/test/resources/file_no_patch.txt: -------------------------------------------------------------------------------- 1 | a 2 | b 3 | c 4 | d 5 | e 6 | f 7 | g 8 | -------------------------------------------------------------------------------- /gradle/gradle-jdks-setup.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palantir/gradle-jdks/HEAD/gradle/gradle-jdks-setup.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palantir/gradle-jdks/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.circleci/.gitattributes: -------------------------------------------------------------------------------- 1 | # Mark .circleci/config.yml as generated for github reviews 2 | config.yml linguist-generated=true 3 | -------------------------------------------------------------------------------- /.circleci/template.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export CIRCLECI_TEMPLATE=java-library-oss 3 | export JDK=11 4 | export DOCKER_TESTS=true 5 | -------------------------------------------------------------------------------- /gradle-jdks-setup/Intellij Gradle JDK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palantir/gradle-jdks/HEAD/gradle-jdks-setup/Intellij Gradle JDK.png -------------------------------------------------------------------------------- /gradle/jdks/11/macos/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-macosx-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/macos/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/21.0.9.10.1/amazon-corretto-21.0.9.10.1-macosx-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-glibc/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-linux-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-glibc/x86/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-linux-i386.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/macos/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-macosx-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/windows/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-windows-x64-jdk.zip 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/windows/x86/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-windows-i386-jdk.zip 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/macos/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/17.0.17.10.1/amazon-corretto-17.0.17.10.1-macosx-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-glibc/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/21.0.9.11.1/amazon-corretto-21.0.9.11.1-linux-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/macos/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/21.0.9.10.1/amazon-corretto-21.0.9.10.1-macosx-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/windows/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/21.0.9.10.1/amazon-corretto-21.0.9.10.1-windows-x64-jdk.zip 2 | -------------------------------------------------------------------------------- /gradle-jdks-excavator-configurations/src/main/resources/gradle-jdks-functions.sh: -------------------------------------------------------------------------------- 1 | ../../../../gradle-jdks-setup/src/main/resources/gradle-jdks-functions.sh -------------------------------------------------------------------------------- /gradle/jdks/11/linux-glibc/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-linux-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-glibc/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/17.0.17.10.1/amazon-corretto-17.0.17.10.1-linux-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/macos/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/17.0.17.10.1/amazon-corretto-17.0.17.10.1-macosx-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/windows/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/17.0.17.10.1/amazon-corretto-17.0.17.10.1-windows-x64-jdk.zip 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-glibc/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/21.0.9.11.1/amazon-corretto-21.0.9.11.1-linux-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /changelog/0.2.0/pr-15.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fix publishing 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/15 6 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/src/test/resources/patch.txt: -------------------------------------------------------------------------------- 1 | # >>> Gradle JDK setup >>> 2 | # one comment 3 | entry 4 | entry 5 | entry 6 | # <<< Gradle JDK setup <<< -------------------------------------------------------------------------------- /gradle/jdks/11/linux-musl/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-alpine-linux-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-glibc/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/17.0.17.10.1/amazon-corretto-17.0.17.10.1-linux-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-musl/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/17.0.17.10.1/amazon-corretto-17.0.17.10.1-alpine-linux-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-musl/x86-64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/21.0.9.11.1/amazon-corretto-21.0.9.11.1-alpine-linux-x64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/11/linux-musl/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/11.0.29.7.1/amazon-corretto-11.0.29.7.1-alpine-linux-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/17/linux-musl/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/17.0.17.10.1/amazon-corretto-17.0.17.10.1-alpine-linux-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /gradle/jdks/21/linux-musl/aarch64/download-url: -------------------------------------------------------------------------------- 1 | https://corretto.aws/downloads/resources/21.0.9.11.1/amazon-corretto-21.0.9.11.1-alpine-linux-aarch64.tar.gz 2 | -------------------------------------------------------------------------------- /changelog/0.25.0/pr-89.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Use zip archives for Mac 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/89 6 | -------------------------------------------------------------------------------- /changelog/0.40.0/pr-376.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Bump intellij dependency 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/376 6 | -------------------------------------------------------------------------------- /changelog/0.4.0/pr-19.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Allow lazy configuration of JDKs 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/19 6 | -------------------------------------------------------------------------------- /changelog/0.41.0/pr-377.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Gradle JDK setup Readme update 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/377 6 | -------------------------------------------------------------------------------- /changelog/0.48.0/pr-420.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fixes caCerts retrieval in Windows 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/420 6 | -------------------------------------------------------------------------------- /changelog/0.57.0/pr-465.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Preserve empty line in patched file 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/465 6 | -------------------------------------------------------------------------------- /changelog/0.9.0/pr-36.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Use non conflicting baseline verison 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/36 6 | -------------------------------------------------------------------------------- /changelog/0.14.0/pr-55.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Handle older glibc in libc autodetection 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/55 6 | -------------------------------------------------------------------------------- /changelog/0.23.0/pr-86.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Support Zulu bundle flags 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/86 6 | -------------------------------------------------------------------------------- /changelog/0.51.0/pr-437.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: '[intellij plugin] Fix consoleView disposer' 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/437 6 | -------------------------------------------------------------------------------- /changelog/0.20.0/pr-73.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Lock jdk creation using file locks 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/73 6 | -------------------------------------------------------------------------------- /changelog/0.28.0/pr-141.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Support GraalVM CE distributions 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/141 6 | -------------------------------------------------------------------------------- /changelog/0.3.0/pr-17.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fix `ZuluVersionUtils` encoding the version wrongly. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/17 6 | -------------------------------------------------------------------------------- /changelog/0.56.0/pr-461.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Gradle JDK Automanagements writes output to stderr 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/461 6 | -------------------------------------------------------------------------------- /changelog/0.1.0/pr-1.v2.yml: -------------------------------------------------------------------------------- 1 | type: feature 2 | feature: 3 | description: Provide a way to add CA certs to all installed JDKs. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/1 6 | -------------------------------------------------------------------------------- /changelog/0.26.0/pr-98.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fix Amazon Corretto download paths so it actually works. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/98 6 | -------------------------------------------------------------------------------- /changelog/0.53.0/pr-453.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Rename check & setupJdks to disambiguate task shortcuts 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/453 6 | -------------------------------------------------------------------------------- /changelog/0.64.0/pr-479.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: '[Gradle JDK Automanagement] Install only used JDKs' 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/479 6 | -------------------------------------------------------------------------------- /changelog/0.10.0/pr-39.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fix `ConcurrentModificationException` from `JdkDownloaders`. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/39 6 | -------------------------------------------------------------------------------- /changelog/0.11.0/pr-40.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Prevent `Cannot get architecture for x86_64` errors on macos. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/40 6 | -------------------------------------------------------------------------------- /changelog/0.18.0/pr-68.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fixed an issue preventing this plugin from working on Windows. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/68 6 | -------------------------------------------------------------------------------- /changelog/0.5.0/pr-26.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Expose `gradle-jdks-distributions` as api in `gradle-jdks`. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/26 6 | -------------------------------------------------------------------------------- /changelog/0.52.0/pr-436.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Intellij code is moved to palantir/gradle-jdks-idea-plugin 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/436 6 | -------------------------------------------------------------------------------- /changelog/0.52.0/pr-447.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: gradle-jdks-setup.sh script sets `JAVA_HOME` to gradle JDK 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/447 6 | -------------------------------------------------------------------------------- /changelog/0.36.0/pr-294.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Try to avoid `This property is in an unexpected state` errors 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/294 6 | -------------------------------------------------------------------------------- /changelog/0.58.0/pr-472.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Add `daemonJdkOnly ` property for gradle jdk directory generation 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/472 6 | -------------------------------------------------------------------------------- /changelog/0.61.0/pr-497.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Support graal jdk automanagement installations 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/497 6 | -------------------------------------------------------------------------------- /changelog/0.63.0/pr-493.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Add default includeAllJdks option to generateGradleJdkConfigs 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/493 6 | -------------------------------------------------------------------------------- /changelog/0.65.0/pr-534.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Disable Gradle JDK Automanagement workflow when running on mingw 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/534 6 | -------------------------------------------------------------------------------- /changelog/0.68.0/pr-544.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: bump `gradle-idea-configuration` and move off deprecated methods 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/544 6 | -------------------------------------------------------------------------------- /changelog/0.8.0/pr-33.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Use `LazilyConfiguredMapping` from gradle-utils. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/33 6 | -------------------------------------------------------------------------------- /changelog/0.50.0/pr-432.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: '[Intellij plugin] GradleJvm is set to Project SDK' 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/432 6 | -------------------------------------------------------------------------------- /changelog/0.55.0/pr-458.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Remove noisy output that "JDK installation X was already configured". 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/458 6 | -------------------------------------------------------------------------------- /changelog/0.37.0/pr-338.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: '[Gradle JDK automanagment] Add gradlew patching logic' 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/338 6 | -------------------------------------------------------------------------------- /changelog/0.38.0/pr-341.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: '[Gradle JDK automanagment] GradleWrapperMain patching' 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/341 6 | -------------------------------------------------------------------------------- /changelog/0.47.0/pr-379.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: '[Intellij] Focus on `Gradle Jdk` Tool Window while the setup is running' 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/379 6 | -------------------------------------------------------------------------------- /changelog/0.47.0/pr-408.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Use com.palantir.external-publish-intellij for idea plugins 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/408 6 | -------------------------------------------------------------------------------- /changelog/0.44.0/pr-386.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Add `/usr/java/$java_version` symlink to `install-jdks.sh` excavator 4 | script 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/386 7 | -------------------------------------------------------------------------------- /changelog/0.54.0/pr-452.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: '[Fix] JDK is successfully installed if bin/java or sentinel files 4 | exist' 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/452 7 | -------------------------------------------------------------------------------- /changelog/0.6.0/pr-23.v2.yml: -------------------------------------------------------------------------------- 1 | type: feature 2 | feature: 3 | description: Palantir CA Plugin to automatically add Palantir CA certs to JDK truststores. 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/23 6 | -------------------------------------------------------------------------------- /changelog/0.45.0/pr-396.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Write the minimum version for the `palantir-gradle-jdks` intellij plugin 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/396 6 | -------------------------------------------------------------------------------- /changelog/0.59.0/pr-482.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Gradle JDK installation directory contains glibc/musl name for linux 4 | distributions 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/482 7 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/src/test/resources/file_with_patch.txt: -------------------------------------------------------------------------------- 1 | a 2 | b 3 | c 4 | d 5 | # >>> Gradle JDK setup >>> 6 | # one comment 7 | entry 8 | entry 9 | entry 10 | # <<< Gradle JDK setup <<< 11 | e 12 | f 13 | g 14 | -------------------------------------------------------------------------------- /changelog/0.42.0/pr-382.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: '[Gradle JDK] Fix when `palantir-gradle-jdks` is not installed and 4 | jdks are missing' 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/382 7 | -------------------------------------------------------------------------------- /changelog/0.46.0/pr-403.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: '[Gradle JDK Automanagement] Adding all systemCerts by default in the 4 | installed JDKs' 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/403 7 | -------------------------------------------------------------------------------- /changelog/0.35.0/pr-286.v2.yml: -------------------------------------------------------------------------------- 1 | type: feature 2 | feature: 3 | description: Allow specifying different versions of JDKs per operating system and 4 | architecture 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/286 7 | -------------------------------------------------------------------------------- /changelog/0.68.0/pr-575.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Switch to gradle-utils' `GradleOperatingSystem` to be configuration cache friendly 4 | links: 5 | - https://github.com/palantir/gradle-jdks/pull/575 6 | -------------------------------------------------------------------------------- /.changelog.yml: -------------------------------------------------------------------------------- 1 | # Excavator auto-updates this file. Please contribute improvements to the central template. 2 | 3 | # This file is intentionally empty. The file's existence enables changelog-app and is empty to use the default configuration. 4 | -------------------------------------------------------------------------------- /changelog/0.13.0/pr-46.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Use musl/alpine JDKs on linux distributions that use musl rather than 4 | glibc (like alpine linux). 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/46 7 | -------------------------------------------------------------------------------- /changelog/0.39.0/pr-360.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: '[Gradle Jdk Automanagement] Generate Gradle Jdks Configuration & Intellij 4 | setup' 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/360 7 | -------------------------------------------------------------------------------- /changelog/0.24.0/pr-88.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Omit the availability specifier if the user specified it. This enables 4 | specification of ea versions. 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/88 7 | -------------------------------------------------------------------------------- /changelog/0.69.0/pr-577.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fix ABI break for `isGradleJdkSetupEnabled` by readding the deleted 4 | `isGradleJdkSetupEnabled(Path)` method 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/577 7 | -------------------------------------------------------------------------------- /changelog/0.43.0/pr-381.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: '[Gradle JDK Automanagement] Add install-jdks.sh script and gradle 4 | jdk configuration generation' 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/381 7 | -------------------------------------------------------------------------------- /changelog/0.12.0/pr-41.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: The Azul JDK distribution uses tar.gz everywhere except windows, matching 4 | available distributions from the Azul CDN 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/41 7 | -------------------------------------------------------------------------------- /changelog/0.19.0/pr-71.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Attempt to move unpacked JDKs into place more safely with replace-existing 4 | and an attempted atomic move 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/71 7 | -------------------------------------------------------------------------------- /changelog/0.62.0/pr-507.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: update error message to redirect to internal docs for cases where all 4 | gradle-sls-docker plugins have been removed 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/507 7 | -------------------------------------------------------------------------------- /changelog/0.66.0/pr-536.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Allow `palantir-gradle-jdks` idea plugin dependency configuration via 4 | `idea-configuration plugin` 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/536 7 | -------------------------------------------------------------------------------- /changelog/0.7.0/pr-29.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: 'Do not atomically move the java home directory to avoid `Could not 4 | move java home: Directory not empty` exceptions' 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/29 7 | -------------------------------------------------------------------------------- /gradle-jdks-enablement/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.palantir.external-publish-jar' 2 | 3 | dependencies { 4 | compileOnly gradleApi() 5 | implementation project(':gradle-jdks-setup-common') 6 | implementation 'com.palantir.gradle.utils:platform' 7 | } 8 | -------------------------------------------------------------------------------- /gradle-jdks-test-common/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'groovy' 3 | 4 | dependencies { 5 | implementation project(':gradle-jdks-setup-common') 6 | implementation gradleTestKit() 7 | implementation 'org.apache.commons:commons-compress' 8 | } 9 | -------------------------------------------------------------------------------- /changelog/0.27.0/pr-99.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: If a JDK for a particular Java major version is not configured, error 4 | out instead of falling back to the Gradle auto-provisioning behaviour. 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/99 7 | -------------------------------------------------------------------------------- /changelog/0.29.0/pr-161.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Produce `com.palantir.jdks.palantir-ca` plugin for use by other Gradle 4 | plugins to enable using open source projects from within the corporate VPN. 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/161 7 | -------------------------------------------------------------------------------- /changelog/0.32.0/pr-178.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fix errors of the form `no more data allowed for version 1 certificate` 4 | when the system truststore has incorrectly versioned X.509 certs in it. 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/178 7 | -------------------------------------------------------------------------------- /changelog/0.30.0/pr-163.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: |- 4 | * Support reading Palantir CA from the truststores of Redhat based systems 5 | * Do not fail if the system truststore cannot be found on linux 6 | links: 7 | - https://github.com/palantir/gradle-jdks/pull/163 8 | -------------------------------------------------------------------------------- /changelog/0.60.0/pr-499.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Fix a possible project sync error when opening IntelliJ by removing 4 | an import to `org.gradle.internal.impldep.com.google.common.collect.ImmutableMap`. 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/499 7 | -------------------------------------------------------------------------------- /changelog/0.15.0/pr-56.v2.yml: -------------------------------------------------------------------------------- 1 | type: improvement 2 | improvement: 3 | description: Move default JDK storage location from `~/.gradle/caches/gradle-jdks` 4 | to `~/.gradle/gradle-jdks` to avoid caching the same data twice in CI. 5 | links: 6 | - https://github.com/palantir/gradle-jdks/pull/56 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /changelog/0.31.0/pr-168.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: For the Palantir CA plugin, skip over certificates in the system truststore 4 | if they contain duplicate extensions, to avoid the `Duplicate extensions not allowed` 5 | error message. 6 | links: 7 | - https://github.com/palantir/gradle-jdks/pull/168 8 | -------------------------------------------------------------------------------- /changelog/0.34.0/pr-240.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: Support Gradle 8, avoid errors of the form "ImmutableGradleJdksJavaInstallationMetadata 4 | does not define or inherit an implementation of the resolved method 'abstract 5 | boolean isCurrentJvm()'" 6 | links: 7 | - https://github.com/palantir/gradle-jdks/pull/240 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## What happened? 2 | 3 | 7 | 8 | ## What did you want to happen? 9 | 10 | 13 | -------------------------------------------------------------------------------- /gradle-jdks-distributions/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'com.palantir.external-publish-jar' 3 | 4 | dependencies { 5 | api project(':gradle-jdks-setup-common') 6 | api 'com.fasterxml.jackson.core:jackson-annotations' 7 | 8 | testImplementation 'org.junit.jupiter:junit-jupiter' 9 | testImplementation 'org.assertj:assertj-core' 10 | } 11 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Before this PR 2 | 3 | 4 | ## After this PR 5 | 6 | ==COMMIT_MSG== 7 | ==COMMIT_MSG== 8 | 9 | ## Possible downsides? 10 | 11 | 12 | -------------------------------------------------------------------------------- /changelog/0.16.0/pr-51.v2.yml: -------------------------------------------------------------------------------- 1 | type: fix 2 | fix: 3 | description: |- 4 | Synchronize Directory and Map property to avoid multithreading issues, particularly: 5 | 6 | > \> Failed to calculate the value of extension 'jdks' property 'jdkStorageLocation'. 7 | > \> This property is in an unexpected state. 8 | links: 9 | - https://github.com/palantir/gradle-jdks/pull/51 10 | -------------------------------------------------------------------------------- /.bulldozer.yml: -------------------------------------------------------------------------------- 1 | # Excavator auto-updates this file. Please contribute improvements to the central template. 2 | 3 | version: 1 4 | merge: 5 | trigger: 6 | labels: ["merge when ready"] 7 | ignore: 8 | labels: ["do not merge"] 9 | method: squash 10 | options: 11 | squash: 12 | body: pull_request_body 13 | message_delimiter: ==COMMIT_MSG== 14 | delete_after_merge: true 15 | update: 16 | trigger: 17 | labels: ["update me"] 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.parallel=true 2 | org.gradle.caching = true 3 | org.gradle.jvmargs = --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED 4 | palantir.jdk.setup.enabled=true 5 | palantir.native.formatter=true 6 | -------------------------------------------------------------------------------- /.excavator.yml: -------------------------------------------------------------------------------- 1 | # Excavator auto-updates this file. Please contribute improvements to the central template. 2 | 3 | auto-label: 4 | names: 5 | versions-props/upgrade-all: [ "merge when ready" ] 6 | circleci/manage-circleci: [ "merge when ready" ] 7 | tags: 8 | donotmerge: [ "do not merge" ] 9 | roomba: [ "merge when ready", "🤖 fix nits" ] 10 | automerge: [ "merge when ready", "🤖 fix nits" ] 11 | standards: [ "merge when ready", "🤖 fix nits" ] 12 | autorelease: [ "autorelease" ] 13 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Excavator auto-updates this file. Please contribute improvements to the central template: 2 | 3 | only: pulls 4 | staleLabel: stale 5 | pulls: 6 | daysUntilStale: 14 7 | daysUntilClose: 7 8 | exemptLabels: [ long-lived ] 9 | markComment: > 10 | This PR has been automatically marked as stale because it has not been touched in the last 14 days. 11 | If you'd like to keep it open, please leave a comment or add the 'long-lived' label, otherwise it'll be closed in 7 days. 12 | closeComment: false 13 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/resources/gradlew-patch.sh: -------------------------------------------------------------------------------- 1 | # >>> Gradle JDK setup >>> 2 | # !! Contents within this block are managed by 'palantir/gradle-jdks' !! 3 | if [ -f gradle/gradle-jdks-setup.sh ]; then 4 | if ! . gradle/gradle-jdks-setup.sh; then 5 | echo "Failed to set up JDK, running gradle/gradle-jdks-setup.sh failed with non-zero exit code" >&2 6 | exit 1 7 | fi 8 | # Setting JAVA_HOME to the gradle daemon to make sure gradlew uses this jdk for `JAVACMD` 9 | JAVA_HOME="$GRADLE_DAEMON_JDK" 10 | fi 11 | # <<< Gradle JDK setup <<< -------------------------------------------------------------------------------- /gradle-jdks-json/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'com.palantir.external-publish-jar' 3 | 4 | dependencies { 5 | api project(':gradle-jdks-distributions') 6 | api 'com.fasterxml.jackson.core:jackson-databind' 7 | 8 | implementation 'com.palantir.gradle.utils:platform' 9 | 10 | annotationProcessor 'org.immutables:value' 11 | compileOnlyApi 'org.immutables:value::annotations' 12 | compileOnlyApi 'org.immutables:serial' 13 | 14 | testImplementation 'org.junit.jupiter:junit-jupiter' 15 | testImplementation 'org.assertj:assertj-core' 16 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ 2 | *.iml 3 | *.ipr 4 | *.iws 5 | .idea/ 6 | .profileconfig.json 7 | 8 | # Eclipse 9 | .classpath 10 | .checkstyle 11 | .factorypath 12 | .project 13 | .settings 14 | *.launch 15 | 16 | # Codegen 17 | .generated 18 | .apt_generated 19 | generated_src/ 20 | **/src/generated/ 21 | 22 | # OS X 23 | .DS_Store 24 | 25 | # Java 26 | *.class 27 | 28 | # Build Systems 29 | .gradle/ 30 | bin/ 31 | build/ 32 | out/ 33 | reports/ 34 | 35 | 36 | # SublimeText + TextMate + Vim 37 | *.sublime-workspace 38 | *.sublime-project 39 | *.tmproj 40 | *.tmproject 41 | *.sw[op] 42 | 43 | # Gradle JDKs setup 44 | !gradle/* 45 | -------------------------------------------------------------------------------- /gradle-jdks/src/integTest/resources/template.Dockerfile: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE 2 | FROM ${BASE_IMAGE} 3 | ARG SCRIPT_SHELL 4 | ENV SCRIPT_SHELL $SCRIPT_SHELL 5 | ARG ADD_JDK_DIR=false 6 | ARG INSTALL_CURL=false 7 | # Update package lists and conditionally install curl 8 | RUN if [ "$INSTALL_CURL" = "true" ] ; then \ 9 | apt-get update && \ 10 | apt-get install -y curl; \ 11 | fi 12 | RUN if [ "$ADD_JDK_DIR" = "true" ] ; then \ 13 | mkdir -p "/root/.gradle/gradle-jdks/amazon-corretto-11.0.21.9.1"; \ 14 | fi 15 | COPY . / 16 | RUN mkdir -p /logsOutput &&\ 17 | $SCRIPT_SHELL /gradle/gradle-jdks-setup.sh > "/logsOutput/stdout" 18 | -------------------------------------------------------------------------------- /gradle-jdks-excavator-configurations/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'com.palantir.external-publish-jar' 3 | 4 | 5 | dependencies { 6 | implementation project(':gradle-jdks') 7 | 8 | implementation 'com.palantir.gradle.utils:platform' 9 | 10 | testImplementation project(':gradle-jdks-setup-common') 11 | testImplementation 'org.junit.jupiter:junit-jupiter' 12 | testImplementation 'org.assertj:assertj-core' 13 | } 14 | 15 | tasks.withType(ProcessResources.class).configureEach { 16 | from(project(':gradle-jdks-setup').tasks.named('fatJar')) { 17 | rename { 'gradle-jdks-setup.jar' } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | gradlePluginPortal() 5 | } 6 | dependencies { 7 | classpath 'com.palantir.gradle.jdks:gradle-jdks-settings:0.71.0' 8 | } 9 | } 10 | apply plugin: 'com.palantir.jdks.settings' 11 | rootProject.name = 'gradle-jdks-root' 12 | 13 | include 'gradle-jdks' 14 | include 'gradle-jdks-distributions' 15 | include 'gradle-jdks-json' 16 | include 'gradle-jdks-setup' 17 | include 'gradle-jdks-setup-common' 18 | include 'gradle-jdks-settings' 19 | include 'gradle-jdks-enablement' 20 | include 'gradle-jdks-excavator-configurations' 21 | include 'gradle-jdks-test-common' 22 | -------------------------------------------------------------------------------- /.baseline/copyright/001_apache-2.0.txt: -------------------------------------------------------------------------------- 1 | (c) Copyright ${today.year} Palantir Technologies Inc. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'com.palantir.external-publish-jar' 3 | 4 | dependencies { 5 | // Avoid adding large compile dependencies here, as they will also be added in the gradle-jdks-setup-all*.jar using the fatJar task 6 | implementation 'com.fasterxml.jackson.core:jackson-annotations' 7 | 8 | testImplementation platform('org.junit:junit-bom:5.9.1') 9 | testImplementation 'org.junit.jupiter:junit-jupiter' 10 | testImplementation 'org.assertj:assertj-core' 11 | } 12 | 13 | // Used by gradle-jdks-setup so it needs to keep Java 11 compatibility. 14 | javaVersion { 15 | target = 11 16 | javaCompiler = 21 17 | } 18 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | public interface JdkDistribution { 20 | String defaultBaseUrl(); 21 | 22 | JdkPath path(JdkRelease jdkRelease); 23 | } 24 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkDistributionExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import org.gradle.api.provider.Property; 20 | 21 | public abstract class JdkDistributionExtension { 22 | public abstract Property getBaseUrl(); 23 | } 24 | -------------------------------------------------------------------------------- /gradle-jdks/src/integTest/resources/testing-script.template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | /root/.gradle/gradle-jdks/amazon-corretto-11.0.21.9.1/bin/java -version 6 | # Running again the gradle-jdk-setup to check the JAVA_HOME. 7 | 8 | if [ -s /logsOutput/stdout ]; then 9 | echo "Unexpected output from build time: $(cat /logsOutput/stdout)" 10 | fi 11 | 12 | # inserting the lines from gradle-jdks/src/main/resources/gradlew-patch.sh 13 | PLACEHOLDER_INSERT_GRADLEW_PATCH 14 | 15 | echo "JAVA_HOME is set to: $JAVA_HOME" 16 | 17 | # running again Gradle JDKs setup, won't write anything to stdout/stderr 18 | . /gradle/gradle-jdks-setup.sh > /tmp/all-output 2>&1 19 | if [ -s /tmp/all-output ]; then 20 | echo "Unexpected output after all JDKs were installed: $(cat /tmp/all-output)" 21 | fi 22 | 23 | if [ ! -f /root/.gradle/gradle-jdks/graalvm-community-jdk-23.0.1/bin/java ]; then 24 | echo "GraalVM is not set" 25 | else 26 | /root/.gradle/gradle-jdks/graalvm-community-jdk-23.0.1/bin/java -version 27 | fi 28 | -------------------------------------------------------------------------------- /versions.props: -------------------------------------------------------------------------------- 1 | com.fasterxml.jackson.*:* = 2.20.1 2 | com.fasterxml.jackson.core:jackson-annotations = 2.20 3 | com.github.ben-manes.caffeine:caffeine = 3.2.0 4 | org.immutables:* = 2.10.1 5 | com.netflix.nebula:nebula-test = 10.6.2 6 | org.junit.jupiter:* = 5.11.4 7 | org.assertj:assertj-core = 3.27.3 8 | org.junit.platform:* = 1.11.4 9 | org.mockito:* = 5.15.2 10 | com.palantir.gradle.utils:* = 0.15.0 11 | com.google.guava:guava = 33.4.0-jre 12 | commons-io:commons-io = 2.18.0 13 | org.apache.commons:commons-compress = 1.27.1 14 | com.palantir.gradle.auto-parallelizable:* = 1.4.0 15 | org.ow2.asm:asm = 9.7.1 16 | com.palantir.gradle.failure-reports:* = 1.9.0 17 | com.palantir.gradle.idea-configuration:gradle-idea-configuration = 0.3.0 18 | 19 | # dependency-upgrader:OFF 20 | com.palantir.baseline:* = 5.53.0 21 | # dependency-upgrader:ON 22 | 23 | # conflict resolution 24 | com.google.code.findbugs:jsr305 = 3.0.2 25 | com.google.errorprone:error_prone_annotations = 2.11.0 26 | org.checkerframework:checker-qual = 3.49.0 27 | -------------------------------------------------------------------------------- /gradle-jdks-distributions/src/main/java/com/palantir/gradle/jdks/ZuluVersionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | public final class ZuluVersionUtils { 20 | public static String combineZuluVersions(String zuluVersion, String javaVersion) { 21 | return zuluVersion + "-" + javaVersion; 22 | } 23 | 24 | private ZuluVersionUtils() {} 25 | } 26 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/PalantirCaExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import org.gradle.api.logging.LogLevel; 20 | import org.gradle.api.provider.Property; 21 | 22 | public abstract class PalantirCaExtension { 23 | public abstract Property getLogLevel(); 24 | 25 | public PalantirCaExtension() { 26 | getLogLevel().set(LogLevel.INFO); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/main/java/com/palantir/gradle/jdks/setup/ILogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup; 18 | 19 | /** 20 | * Interface to log messages for the JDK certificate setup {@link CaResources}. 21 | */ 22 | public interface ILogger { 23 | 24 | /** 25 | * Logs an info message. 26 | */ 27 | void log(String message); 28 | 29 | /** 30 | * Logs an error message. 31 | */ 32 | void logError(String errorMessage); 33 | } 34 | -------------------------------------------------------------------------------- /gradle-jdks-distributions/src/test/java/com/palantir/gradle/jdks/JdkDistributionNameTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | class JdkDistributionNameTest { 24 | @Test 25 | void parses_names_correctly() { 26 | assertThat(JdkDistributionName.fromStringThrowing("azul-zulu")).isEqualTo(JdkDistributionName.AZUL_ZULU); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle-jdks-distributions/src/test/java/com/palantir/gradle/jdks/ZuluVersionUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | class ZuluVersionUtilsTest { 24 | @Test 25 | void ensure_version_is_encoded_properly() { 26 | assertThat(ZuluVersionUtils.combineZuluVersions("11.33.55", "11.0.4")).isEqualTo("11.33.55-11.0.4"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkOsArchExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.json.JdkOsArchInfoJson; 20 | import org.gradle.api.provider.Property; 21 | 22 | public abstract class JdkOsArchExtension { 23 | public abstract Property getJdkVersion(); 24 | 25 | public final void fromJson(JdkOsArchInfoJson archInfo) { 26 | getJdkVersion().set(archInfo.version()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle-jdks-json/src/main/java/com/palantir/gradle/jdks/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @Value.Style( 18 | visibility = ImplementationVisibility.PACKAGE, 19 | overshadowImplementation = true, 20 | jdkOnly = true, 21 | get = {"get*", "is*"}) 22 | @Serial.Structural 23 | package com.palantir.gradle.jdks.json; 24 | 25 | import org.immutables.serial.Serial; 26 | import org.immutables.value.Value; 27 | import org.immutables.value.Value.Style.ImplementationVisibility; 28 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/ConfigureUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import groovy.lang.Closure; 20 | import org.gradle.api.Action; 21 | 22 | final class ConfigureUtil { 23 | @SuppressWarnings("RawTypes") 24 | public static Action toAction(Closure closure) { 25 | return item -> { 26 | closure.setDelegate(item); 27 | closure.run(); 28 | }; 29 | } 30 | 31 | private ConfigureUtil() {} 32 | } 33 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkRelease.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.setup.common.Arch; 20 | import com.palantir.platform.OperatingSystem; 21 | import org.immutables.value.Value; 22 | 23 | @Value.Immutable 24 | public interface JdkRelease { 25 | String version(); 26 | 27 | OperatingSystem os(); 28 | 29 | Arch arch(); 30 | 31 | class Builder extends ImmutableJdkRelease.Builder {} 32 | 33 | static Builder builder() { 34 | return new Builder(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/main/java/com/palantir/gradle/jdks/setup/StdErrLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup; 18 | 19 | /** 20 | * A simple logger that logs to stderr only. Useful for writing diagnostic information. 21 | */ 22 | @SuppressWarnings({"BanSystemOut", "BanSystemErr"}) 23 | public final class StdErrLogger implements ILogger { 24 | 25 | @Override 26 | public void log(String message) { 27 | logError(message); 28 | } 29 | 30 | @Override 31 | public void logError(String errorMessae) { 32 | System.err.println(errorMessae); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/test/resources/apple-kdc-cert-with-duplicate-extension.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDLDCCAhSgAwIBAgIEPmaDxDANBgkqhkiG9w0BAQsFADA7MR8wHQYDVQQDDBZj 3 | b20uYXBwbGUua2VyYmVyb3Mua2RjMRgwFgYDVQQKDA9TeXN0ZW0gSWRlbnRpdHkw 4 | HhcNMTcwNzI1MjAyMjI1WhcNMzcwNzIwMjAyMjI1WjA7MR8wHQYDVQQDDBZjb20u 5 | YXBwbGUua2VyYmVyb3Mua2RjMRgwFgYDVQQKDA9TeXN0ZW0gSWRlbnRpdHkwggEi 6 | MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCwPYz8XEUbDjb+ahO1pucwHshY 7 | JGEY8JFXARHtdzZh5Y+Vq8rphgU91N1TwRSUjVfH2EprDF6ezsRvXG9hEDV5xg/d 8 | c5Ok/sRfoDwaGsu8pNXf4YRXuSjoM8xSAW3/w1m37KaYgFZ7IbOK5/F5DGHM9Efi 9 | Sb+sBE8UG96K8vlsEyJxM0fpj/8K7GmOlv4RpGR89NqPdBqzoptf6SWtyjJkMmsA 10 | uTtqzVe2u3IH6YvNcrSBACC2oI1fye36aCpNrmUjCJ+KWPQF+uTY31iLPrXriP61 11 | XIDQ6gEaJBXW09nG/YdJe537RUiR0KWRYqZqzv9rXXLVsP4IesA8u/ZfBkqRAgMB 12 | AAGjODA2MAsGA1UdDwQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATASBgNVHSUE 13 | CzAJBgcrBgEFAgMFMA0GCSqGSIb3DQEBCwUAA4IBAQA5NlbqjyEnNUXGG6Lq40iX 14 | KDCjZIgjlzcPchI4DVdrkF84TiWaOM4hGr59czRzhMkOoY/h+/8W1ycsr0/wzTzi 15 | 6vQXgBoiZDuad3ZTw9cXOtIYtLgOH+dhhayXC/pvMSTXYTotIL1c9pjrj+mM9zua 16 | hCEqiiuGFXSHhkWMYXJ5CF9gHezlgvYZ1G4eOnzmB7fSjkBrBS6QMwKBMcqkJ0wt 17 | 2dcJFAZZKak5BUY8/tPQKnjRNarTkUXVjX0W4a3RbpHJqaNkGJz7/ntQtF/jmojC 18 | ONazLybpg225oQqoHBEcSIvsHQYnmEwWHF6sswhGyzpY9TxRCfWJ+jrSnLcVK0FZ 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkDistributionConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.setup.common.Arch; 20 | import com.palantir.platform.OperatingSystem; 21 | import org.gradle.api.provider.Property; 22 | import org.gradle.api.tasks.Input; 23 | 24 | public interface JdkDistributionConfig { 25 | 26 | @Input 27 | Property getDownloadUrl(); 28 | 29 | @Input 30 | Property getLocalPath(); 31 | 32 | @Input 33 | Property getOs(); 34 | 35 | @Input 36 | Property getArch(); 37 | } 38 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/test/resources/strongloop-cert-with-v3-extensions-but-v1-version.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDJjCCAg4CAhnOMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD 3 | VQQIDAJDQTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEZMBcGA1UECgwQU3Ryb25 4 | n 5 | TG9vcCwgSW5jLjESMBAGA1UECwwJU3Ryb25nT3BzMRowGAYDVQQDDBFjYS5zdHJv 6 | bmdsb29wLmNvbTAeFw0xNTEyMDgyMzM1MzNaFw00MzA0MjQyMzM1MzNaMBkxFz 7 | AV 8 | BgNVBAMMDnN0cm9uZ2xvb3AuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB 9 | CgKCAQEAwOYI7OZ2FX/YjRgLZoDQlbPc5UZXU/j0e1wwiJNPtPEax9Y5Uoza0Pnt 10 | Ikzkc2SfvQ+IJrhXo385tI0W5juuqbHnE7UrjUuPjUX6NHevkxcs/flmjan5wnZM 11 | cPsGhH71WDuUEEflvZihf2Se2x+xgZtMhc5XGmVmRuZFYKvkgUhA2/w8/QrK+jPT 12 | n9QRJxZjWNh2RBdC1B7u4jffSmOSUljYFH1I2eTeY+Rdi6YUIYSU9gEoZxsv3Tia 13 | SomfMF5jt2Mouo6MzA+IhLvvFjcrcph1Qxgi9RkfdCMMd+Ipm9YWELkyG1bDRpQy 14 | 0iyHD4gvVsAqz1Y2KdRSdc3Kt+nTqwIDAQABoxkwFzAVBgNVHREEDjAMhwQAAAAA 15 | hwR/AAABMA0GCSqGSIb3DQEBBQUAA4IBAQAhy4J0hML3NgmDRHdL5/iTucBe22Mf 16 | jJjg2aifD1S187dHm+Il4qZNO2plWwAhN0h704f+8wpsaALxUvBIu6nvlvcMP5PH 17 | jGN5JLe2Km3UaPvYOQU2SgacLilu+uBcIo2JSHLV6O7ziqUj5Gior6YxDLCtEZie 18 | Ea8aX5/YjuACtEMJ1JjRqjgkM66XAoUe0E8onOK3FgTIO3tGoTJwRp0zS50pFuP0 19 | PsZtT04ck6mmXEXXknNoAyBCvPypfms9OHqcUIW9fiQnrGbS/Ri4QSQYj0DtFk/1 20 | na4fY1gf3zTHxH8259b/TOOaPfTnCEsOQtjUrWNR4xhmVZ+HJy4yytUW 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/SystemTools.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.platform.OperatingSystem; 20 | 21 | final class SystemTools { 22 | private SystemTools() {} 23 | 24 | static String java(OperatingSystem os) { 25 | if (os == OperatingSystem.WINDOWS) { 26 | return "java.exe"; 27 | } 28 | return "java"; 29 | } 30 | 31 | static String keytool(OperatingSystem os) { 32 | if (os == OperatingSystem.WINDOWS) { 33 | return "keytool.exe"; 34 | } 35 | return "keytool"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/main/java/com/palantir/gradle/jdks/setup/AliasContentCert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup; 18 | 19 | /** 20 | * Helper class to represent a certificate based on the alias and content. 21 | */ 22 | public final class AliasContentCert { 23 | 24 | private final String content; 25 | 26 | private final String alias; 27 | 28 | public AliasContentCert(String alias, String content) { 29 | this.alias = alias; 30 | this.content = content; 31 | } 32 | 33 | public String getAlias() { 34 | return alias; 35 | } 36 | 37 | public String getContent() { 38 | return content; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /gradle-jdks-json/src/main/java/com/palantir/gradle/jdks/json/JdkOsArchInfoJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.json; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 20 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 21 | import org.immutables.value.Value; 22 | 23 | @Value.Immutable 24 | @JsonDeserialize(as = ImmutableJdkOsArchInfoJson.class) 25 | @JsonIgnoreProperties(ignoreUnknown = true) 26 | public abstract class JdkOsArchInfoJson { 27 | public abstract String version(); 28 | 29 | public static final class Builder extends ImmutableJdkOsArchInfoJson.Builder {} 30 | 31 | public static Builder builder() { 32 | return new Builder(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /gradle-jdks-json/src/main/java/com/palantir/gradle/jdks/json/JdksInfoJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.json; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 20 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 21 | import java.util.Map; 22 | import org.immutables.value.Value; 23 | 24 | @Value.Immutable 25 | @JsonDeserialize(as = ImmutableJdksInfoJson.class) 26 | @JsonIgnoreProperties(ignoreUnknown = true) 27 | public abstract class JdksInfoJson { 28 | public abstract Map jdksPerJavaVersion(); 29 | 30 | public static final class Builder extends ImmutableJdksInfoJson.Builder {} 31 | 32 | public static Builder builder() { 33 | return new Builder(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkPath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import org.immutables.value.Value; 20 | 21 | @Value.Immutable 22 | public interface JdkPath { 23 | String filename(); 24 | 25 | Extension extension(); 26 | 27 | enum Extension { 28 | ZIP("zip"), 29 | TARGZ("tar.gz"); 30 | 31 | private final String extension; 32 | 33 | Extension(String extension) { 34 | this.extension = extension; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return extension; 40 | } 41 | } 42 | 43 | class Builder extends ImmutableJdkPath.Builder {} 44 | 45 | static Builder builder() { 46 | return new Builder(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /gradle-jdks-json/src/main/java/com/palantir/gradle/jdks/json/JdkOsInfoJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.json; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 20 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 21 | import com.palantir.gradle.jdks.setup.common.Arch; 22 | import java.util.Map; 23 | import org.immutables.value.Value; 24 | 25 | @Value.Immutable 26 | @JsonDeserialize(as = ImmutableJdkOsInfoJson.class) 27 | @JsonIgnoreProperties(ignoreUnknown = true) 28 | public abstract class JdkOsInfoJson { 29 | public abstract Map arch(); 30 | 31 | public static final class Builder extends ImmutableJdkOsInfoJson.Builder {} 32 | 33 | public static Builder builder() { 34 | return new Builder(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/GradleLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.setup.ILogger; 20 | import org.gradle.api.logging.LogLevel; 21 | import org.gradle.api.logging.Logger; 22 | 23 | public final class GradleLogger implements ILogger { 24 | 25 | private Logger gradleLogger; 26 | private LogLevel logLevel; 27 | 28 | public GradleLogger(Logger gradleLogger, LogLevel logLevel) { 29 | this.gradleLogger = gradleLogger; 30 | this.logLevel = logLevel; 31 | } 32 | 33 | @Override 34 | public void log(String message) { 35 | gradleLogger.log(logLevel, message); 36 | } 37 | 38 | @Override 39 | public void logError(String errorMessage) { 40 | log(errorMessage); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/src/main/java/com/palantir/gradle/jdks/setup/common/CurrentArch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup.common; 18 | 19 | import java.util.Locale; 20 | import java.util.Set; 21 | 22 | public final class CurrentArch { 23 | public static Arch get() { 24 | String osArch = System.getProperty("os.arch").toLowerCase(Locale.ROOT); 25 | 26 | if (Set.of("x86_64", "x64", "amd64").contains(osArch)) { 27 | return Arch.X86_64; 28 | } 29 | 30 | if (Set.of("arm", "arm64", "aarch64").contains(osArch)) { 31 | return Arch.AARCH64; 32 | } 33 | 34 | if (Set.of("x86", "i686").contains(osArch)) { 35 | return Arch.X86; 36 | } 37 | 38 | throw new UnsupportedOperationException("Cannot get architecture for " + osArch); 39 | } 40 | 41 | private CurrentArch() {} 42 | } 43 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/src/main/java/com/palantir/gradle/jdks/setup/common/Arch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup.common; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonValue; 21 | import java.util.Optional; 22 | 23 | public enum Arch { 24 | X86, 25 | X86_64, 26 | AARCH64; 27 | 28 | @Override 29 | public String toString() { 30 | return uiName(); 31 | } 32 | 33 | @JsonValue 34 | public final String uiName() { 35 | return UiNames.uiName(this); 36 | } 37 | 38 | public static Optional fromString(String archUiName) { 39 | return UiNames.fromString(values(), archUiName); 40 | } 41 | 42 | @JsonCreator 43 | public static Arch fromStringThrowing(String archUiName) { 44 | return UiNames.fromStringThrowing(Arch.class, values(), archUiName); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /gradle-jdks-json/src/main/java/com/palantir/gradle/jdks/json/JdkInfoJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.json; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 20 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 21 | import com.palantir.gradle.jdks.JdkDistributionName; 22 | import com.palantir.platform.OperatingSystem; 23 | import java.util.Map; 24 | import org.immutables.value.Value; 25 | 26 | @Value.Immutable 27 | @JsonDeserialize(as = ImmutableJdkInfoJson.class) 28 | @JsonIgnoreProperties(ignoreUnknown = true) 29 | public abstract class JdkInfoJson { 30 | public abstract JdkDistributionName distribution(); 31 | 32 | public abstract Map os(); 33 | 34 | public static final class Builder extends ImmutableJdkInfoJson.Builder {} 35 | 36 | public static Builder builder() { 37 | return new Builder(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /.baseline/eclipse/dynamic/dotfile.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /gradle-jdks-excavator-configurations/src/main/resources/install-jdks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eux 4 | 5 | GRADLE_DIR=$1 6 | 7 | # used by the resolved_symlink below to resolve the path based on the JAVA_VERSION value. e.g. /usr/local/${JAVA_VERSION} 8 | # shellcheck disable=SC2034 9 | SYMLINK_PATTERN=$2 10 | JAVA_SYMLINK_DIR=${3:-/usr/java} 11 | 12 | symlink_dir="${SYMLINK_PATTERN%/*}" 13 | mkdir -p "$symlink_dir" 14 | mkdir -p "$JAVA_SYMLINK_DIR" 15 | 16 | # Loading gradle jdk functions 17 | SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 18 | source "$SCRIPTS_DIR"/gradle-jdks-functions.sh 19 | 20 | # Running the installation setup 21 | install_and_setup_jdks "$GRADLE_DIR" "$SCRIPTS_DIR" 22 | 23 | for dir in "$GRADLE_DIR"/jdks/*/; do 24 | major_version_dir=${dir%*/} 25 | major_version=$(basename "$major_version_dir") 26 | if [ "$major_version" == "8" ]; then 27 | continue 28 | fi 29 | distribution_local_path=$(read_value "$major_version_dir"/"$OS"/"$ARCH"/local-path) 30 | jdk_installation_directory="$GRADLE_JDKS_HOME"/"$distribution_local_path" 31 | resolved_symlink="${SYMLINK_PATTERN//\$\{JAVA_VERSION\}/$major_version}" 32 | # shellcheck disable=SC2154 33 | ln -s "$jdk_installation_directory" "$resolved_symlink" 34 | # Link java installations to /usr/java so that installations are automatically picked up by gradle 35 | ## https://github.com/gradle/gradle/blob/b381099260a04f226ef2412db8ee38fae3e9e753/subprojects/jvm-services/src/main/java/org/gradle/jvm/toolchain/internal/LinuxInstallationSupplier.java#L46 36 | ln -s "$jdk_installation_directory" "$JAVA_SYMLINK_DIR/$major_version" 37 | done 38 | 39 | cleanup 40 | -------------------------------------------------------------------------------- /gradle-jdks-setup/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'com.palantir.external-publish-jar' 3 | apply plugin: 'org.unbroken-dome.test-sets' 4 | 5 | dependencies { 6 | // Avoid adding large compile dependencies here, as they will also be added in the gradle-jdks-setup-all*.jar using the fatJar task 7 | implementation project(':gradle-jdks-setup-common') 8 | implementation 'com.palantir.gradle.utils:platform' 9 | 10 | testImplementation 'org.junit.jupiter:junit-jupiter' 11 | testImplementation 'org.assertj:assertj-core' 12 | testImplementation 'commons-io:commons-io' 13 | } 14 | 15 | tasks.register('fatJar', Jar) { 16 | dependsOn tasks.jar, ':gradle-jdks-setup-common:jar' 17 | manifest { 18 | attributes 'Main-Class': 'com.palantir.gradle.jdks.setup.GradleJdkInstallationSetup' 19 | } 20 | archiveBaseName = 'gradle-jdks-setup-all' 21 | duplicatesStrategy = DuplicatesStrategy.FAIL 22 | from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } 23 | with jar 24 | } 25 | 26 | tasks.withType(JavaCompile) { 27 | options.errorprone.disable 'PreferSafeLoggableExceptions', 'StringSplitter' 28 | 29 | // Disable StreamFlatMapOptional due to Java 11 30 | // Remove when we get to Java 17 31 | options.errorprone.disable 'StreamFlatMapOptional' 32 | } 33 | 34 | // DO NOT UPDATE! This needs to be kept as low as possible, such that it is compatible with all the jdk versions the 35 | // consumers would want to set up with the JDK auto-management workflow (used by ./gradle-jdks-setup.sh and GradleWrapperMain.java classes) 36 | javaVersion { 37 | target = 11 38 | javaCompiler = 21 39 | } 40 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkDistributions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import java.util.Map; 20 | import java.util.Optional; 21 | 22 | final class JdkDistributions { 23 | private static final Map JDK_DISTRIBUTIONS = Map.of( 24 | JdkDistributionName.AZUL_ZULU, 25 | new AzulZuluJdkDistribution(), 26 | JdkDistributionName.AMAZON_CORRETTO, 27 | new AmazonCorrettoJdkDistribution(), 28 | JdkDistributionName.GRAALVM_CE, 29 | new GraalVmCeDistribution()); 30 | 31 | public JdkDistribution get(JdkDistributionName jdkDistributionName) { 32 | return Optional.ofNullable(JDK_DISTRIBUTIONS.get(jdkDistributionName)) 33 | .orElseThrow(() -> new IllegalArgumentException(String.format( 34 | "Could not find JDK distribution %s. Available: %s", 35 | jdkDistributionName, JDK_DISTRIBUTIONS.keySet()))); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /.baseline/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /gradle-jdks-distributions/src/main/java/com/palantir/gradle/jdks/JdkDistributionName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonValue; 21 | import com.palantir.gradle.jdks.setup.common.UiNames; 22 | import java.util.Optional; 23 | 24 | public enum JdkDistributionName { 25 | AZUL_ZULU, 26 | AMAZON_CORRETTO, 27 | GRAALVM_CE; 28 | 29 | JdkDistributionName() {} 30 | 31 | @Override 32 | public String toString() { 33 | return uiName(); 34 | } 35 | 36 | @JsonValue 37 | public final String uiName() { 38 | return UiNames.uiName(this); 39 | } 40 | 41 | public static Optional fromString(String distributionUiName) { 42 | return UiNames.fromString(values(), distributionUiName); 43 | } 44 | 45 | @JsonCreator 46 | public static JdkDistributionName fromStringThrowing(String distributionUiName) { 47 | return UiNames.fromStringThrowing(JdkDistributionName.class, values(), distributionUiName); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/CaCerts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import java.util.Comparator; 20 | import java.util.Map; 21 | import java.util.NavigableMap; 22 | import java.util.TreeMap; 23 | import org.immutables.value.Value; 24 | 25 | @Value.Immutable 26 | public interface CaCerts { 27 | NavigableMap caCerts(); 28 | 29 | default String combinedInSortedOrder() { 30 | StringBuilder stringBuilder = new StringBuilder(); 31 | 32 | caCerts().forEach((alias, caCert) -> { 33 | stringBuilder.append(alias).append(": ").append(caCert).append('\n'); 34 | }); 35 | 36 | return stringBuilder.toString(); 37 | } 38 | 39 | class Builder extends ImmutableCaCerts.Builder {} 40 | 41 | static Builder builder() { 42 | return new Builder(); 43 | } 44 | 45 | static CaCerts from(Map caCerts) { 46 | NavigableMap sortedMap = new TreeMap<>(Comparator.naturalOrder()); 47 | sortedMap.putAll(caCerts); 48 | return builder().caCerts(sortedMap).build(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/src/main/java/com/palantir/gradle/jdks/setup/common/UiNames.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup.common; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import java.util.Arrays; 21 | import java.util.Locale; 22 | import java.util.Optional; 23 | import java.util.stream.Collectors; 24 | 25 | public final class UiNames { 26 | public static String uiName(Enum enumValue) { 27 | return enumValue.name().toLowerCase(Locale.ROOT).replace('_', '-'); 28 | } 29 | 30 | public static > Optional fromString(T[] enumValues, String uiName) { 31 | return Arrays.stream(enumValues) 32 | .filter(jdkDistributionName -> uiName(jdkDistributionName).equals(uiName)) 33 | .findFirst(); 34 | } 35 | 36 | @JsonCreator 37 | public static > T fromStringThrowing(Class clazz, T[] enumValues, String uiName) { 38 | return fromString(enumValues, uiName) 39 | .orElseThrow(() -> new IllegalArgumentException(String.format( 40 | "Cannot convert %s into a %s. Options are: %s.", 41 | uiName, 42 | clazz.getSimpleName(), 43 | Arrays.stream(enumValues).map(UiNames::uiName).collect(Collectors.toList())))); 44 | } 45 | 46 | private UiNames() {} 47 | } 48 | -------------------------------------------------------------------------------- /gradle-jdks-setup-common/src/test/java/com/palantir/gradle/jdks/setup/common/GradleJdkPatchHelperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup.common; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.io.IOException; 22 | import java.nio.file.Files; 23 | import java.nio.file.Path; 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.io.TempDir; 26 | 27 | class GradleJdkPatchHelperTest { 28 | 29 | @TempDir 30 | Path tmpDir; 31 | 32 | @Test 33 | void correctly_adds_patch() throws IOException { 34 | Path expectedFileWithPatch = Path.of("src/test/resources/file_with_patch.txt"); 35 | Path originalFileNoPatch = Path.of("src/test/resources/file_no_patch.txt"); 36 | Path patch = Path.of("src/test/resources/patch.txt"); 37 | Path processedFile = tmpDir.resolve("file_with_patch.txt"); 38 | GradleJdksPatchHelper.writeContentWithPatch( 39 | tmpDir.resolve("file_with_patch.txt"), 40 | GradleJdksPatchHelper.readAllLines(originalFileNoPatch), 41 | GradleJdksPatchHelper.readAllLines(patch), 42 | 4); 43 | assertEqualFiles(processedFile, expectedFileWithPatch); 44 | } 45 | 46 | private void assertEqualFiles(Path actualPath, Path expectedPath) throws IOException { 47 | assertThat(Files.readString(actualPath)).isEqualTo(Files.readString(expectedPath)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/test/java/com/palantir/gradle/jdks/setup/CommandRunnerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 21 | 22 | import com.palantir.gradle.jdks.setup.common.CommandRunner; 23 | import java.io.InputStream; 24 | import org.junit.jupiter.api.Test; 25 | 26 | public class CommandRunnerTest { 27 | 28 | @Test 29 | public void command_runs_successfully() { 30 | assertThat(CommandRunner.runWithOutputCollection(new ProcessBuilder().command("echo", "my message"))) 31 | .contains("my message"); 32 | } 33 | 34 | @Test 35 | public void command_fails() { 36 | assertThatThrownBy( 37 | () -> CommandRunner.runWithOutputCollection(new ProcessBuilder().command("nonexistingcommand"))) 38 | .hasMessageContaining("Failed to run command 'nonexistingcommand'"); 39 | } 40 | 41 | @Test 42 | public void command_runs_with_logger() { 43 | CommandRunner.runWithLogger( 44 | new ProcessBuilder().command("echo", "my message"), CommandRunnerTest::assertOutput, _unused -> {}); 45 | } 46 | 47 | private static void assertOutput(InputStream inputStream) { 48 | CommandRunner.processStream(inputStream, line -> { 49 | assertThat(line).contains("my message"); 50 | }); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/SynchronizedInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import java.lang.reflect.Proxy; 20 | import java.util.Arrays; 21 | import java.util.Optional; 22 | import java.util.Set; 23 | import java.util.stream.Collectors; 24 | import java.util.stream.Stream; 25 | 26 | final class SynchronizedInterface { 27 | public static T synchronizeAllInterfaceMethods(Class returnInterface, T original) { 28 | Object sync = new Object(); 29 | return returnInterface.cast(Proxy.newProxyInstance( 30 | original.getClass().getClassLoader(), 31 | allInterfaces(original.getClass()).distinct().toArray(Class[]::new), 32 | (_proxy, method, args) -> { 33 | synchronized (sync) { 34 | return method.invoke(original, args); 35 | } 36 | })); 37 | } 38 | 39 | private static Stream> allInterfaces(Class clazz) { 40 | Set> superclasses = Stream.concat( 41 | Optional.ofNullable(clazz.getSuperclass()).stream(), Arrays.stream(clazz.getInterfaces())) 42 | .collect(Collectors.toSet()); 43 | 44 | return Stream.concat( 45 | superclasses.stream().filter(Class::isInterface), 46 | superclasses.stream().flatMap(SynchronizedInterface::allInterfaces)); 47 | } 48 | 49 | private SynchronizedInterface() {} 50 | } 51 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import java.nio.file.Path; 20 | import org.gradle.api.Project; 21 | import org.gradle.api.artifacts.Configuration; 22 | import org.gradle.api.artifacts.repositories.IvyArtifactRepository.MetadataSources; 23 | 24 | final class JdkDownloader { 25 | 26 | private final Project project; 27 | private final String jdkGroup; 28 | 29 | JdkDownloader(Project project, JdkDistributionName jdkDistributionName, String jdkBaseUrl) { 30 | this.project = project; 31 | this.jdkGroup = jdkDistributionName.uiName() + "-jdk"; 32 | 33 | project.getRepositories().ivy(ivy -> { 34 | ivy.setName(jdkGroup); 35 | ivy.setUrl(jdkBaseUrl); 36 | ivy.patternLayout(patternLayout -> patternLayout.artifact("[module].[ext]")); 37 | ivy.metadataSources(MetadataSources::artifact); 38 | ivy.content(repositoryContentDescriptor -> { 39 | repositoryContentDescriptor.includeGroup(jdkGroup); 40 | }); 41 | }); 42 | } 43 | 44 | public Path downloadJdkPath(JdkPath jdKPath) { 45 | Configuration configuration = project.getConfigurations() 46 | .detachedConfiguration(project.getDependencies() 47 | .create(String.format("%s:%s:@%s", jdkGroup, jdKPath.filename(), jdKPath.extension()))); 48 | return configuration.resolve().iterator().next().toPath(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkDownloaders.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import java.util.concurrent.ConcurrentHashMap; 20 | import java.util.concurrent.ConcurrentMap; 21 | import org.gradle.api.Project; 22 | import org.immutables.value.Value; 23 | 24 | final class JdkDownloaders { 25 | private final ConcurrentMap jdkDownloaders = new ConcurrentHashMap<>(); 26 | 27 | private final JdksExtension jdksExtension; 28 | 29 | JdkDownloaders(JdksExtension jdksExtension) { 30 | this.jdksExtension = jdksExtension; 31 | } 32 | 33 | public JdkDownloader jdkDownloaderFor(Project project, JdkDistributionName jdkDistributionName) { 34 | return jdkDownloaders.computeIfAbsent( 35 | ImmutableJdkDownloadersCacheKey.builder() 36 | .project(project) 37 | .jdkDistributionName(jdkDistributionName) 38 | .build(), 39 | _ignored -> new JdkDownloader( 40 | project, 41 | jdkDistributionName, 42 | jdksExtension 43 | .jdkDistributionFor(jdkDistributionName) 44 | .getBaseUrl() 45 | .get())); 46 | } 47 | 48 | @Value.Immutable 49 | interface JdkDownloadersCacheKey { 50 | Project project(); 51 | 52 | JdkDistributionName jdkDistributionName(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/test/java/com/palantir/gradle/jdks/setup/CaResourcesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.io.IOException; 22 | import java.nio.charset.StandardCharsets; 23 | import org.junit.jupiter.api.Test; 24 | 25 | public class CaResourcesTest { 26 | 27 | @Test 28 | void handles_just_whitespace_truststore() { 29 | assertThat(CaResources.parseCerts(" \n ".getBytes(StandardCharsets.UTF_8))) 30 | .isEmpty(); 31 | } 32 | 33 | @Test 34 | void handles_whitespace_and_comments_between_certs() throws IOException { 35 | assertThat(CaResources.parseCerts(certsFromResources("amazon-cas-with-whitespace-between.pem"))) 36 | .hasSize(3); 37 | } 38 | 39 | @Test 40 | void does_not_explode_when_given_certs_with_duplicate_extensions() throws IOException { 41 | assertThat(CaResources.parseCerts(certsFromResources("apple-kdc-cert-with-duplicate-extension.pem"))) 42 | .isEmpty(); 43 | } 44 | 45 | @Test 46 | void does_not_explode_when_given_certs_with_incorrect_vesion() throws IOException { 47 | assertThat(CaResources.parseCerts(certsFromResources("strongloop-cert-with-v3-extensions-but-v1-version.pem"))) 48 | .isEmpty(); 49 | } 50 | 51 | private byte[] certsFromResources(String name) throws IOException { 52 | return getClass().getClassLoader().getResourceAsStream(name).readAllBytes(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import java.nio.ByteBuffer; 20 | import java.nio.charset.StandardCharsets; 21 | import java.security.MessageDigest; 22 | import java.security.NoSuchAlgorithmException; 23 | import org.immutables.value.Value; 24 | 25 | @Value.Immutable 26 | public interface JdkSpec { 27 | JdkDistributionName distributionName(); 28 | 29 | JdkRelease release(); 30 | 31 | CaCerts caCerts(); 32 | 33 | default String consistentShortHash() { 34 | @SuppressWarnings("for-rollout:StringConcatToTextBlock") 35 | String infoBlock = String.format( 36 | String.join("\n", "Distribution: %s", "Version: %s", "Os: %s", "Arch: %s", "CaCerts: %s"), 37 | distributionName().uiName(), 38 | release().version(), 39 | release().os(), 40 | release().arch(), 41 | caCerts().combinedInSortedOrder()); 42 | 43 | try { 44 | MessageDigest digest = MessageDigest.getInstance("SHA-256"); 45 | byte[] bytes = digest.digest(infoBlock.getBytes(StandardCharsets.UTF_8)); 46 | // We only want a short hash, so just parse the first part of the digest into a hex string 47 | return Long.toHexString(ByteBuffer.wrap(bytes).getLong()); 48 | } catch (NoSuchAlgorithmException e) { 49 | throw new RuntimeException("Could not find SHA-256 hash algorithm", e); 50 | } 51 | } 52 | 53 | class Builder extends ImmutableJdkSpec.Builder {} 54 | 55 | static Builder builder() { 56 | return new Builder(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /gradle-jdks-enablement/src/main/java/com/palantir/gradle/jdks/enablement/GradleJdksEnablement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.enablement; 18 | 19 | import com.palantir.platform.OperatingSystem; 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.IOException; 23 | import java.io.UncheckedIOException; 24 | import java.nio.file.Path; 25 | import java.util.Optional; 26 | import java.util.Properties; 27 | 28 | public final class GradleJdksEnablement { 29 | 30 | public static final String MINIMUM_SUPPORTED_GRADLE_VERSION = "7.6"; 31 | 32 | public static boolean isGradleJdkSetupEnabled(Path projectDir) { 33 | return isGradleJdkSetupEnabled(OperatingSystem.get(), projectDir); 34 | } 35 | 36 | public static boolean isGradleJdkSetupEnabled(OperatingSystem operatingSystem, Path projectDir) { 37 | return !operatingSystem.equals(OperatingSystem.WINDOWS) && isGradleJdkPropertyEnabled(projectDir); 38 | } 39 | 40 | private static boolean isGradleJdkPropertyEnabled(Path projectDir) { 41 | File gradlePropsFile = projectDir.resolve("gradle.properties").toFile(); 42 | if (!gradlePropsFile.exists()) { 43 | return false; 44 | } 45 | try { 46 | Properties properties = new Properties(); 47 | properties.load(new FileInputStream(gradlePropsFile)); 48 | return Optional.ofNullable(properties.getProperty("palantir.jdk.setup.enabled")) 49 | .map(Boolean::parseBoolean) 50 | .orElse(false); 51 | } catch (IOException e) { 52 | throw new UncheckedIOException("Failed to read gradle.properties file", e); 53 | } 54 | } 55 | 56 | private GradleJdksEnablement() {} 57 | } 58 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkOsExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.json.JdkOsInfoJson; 20 | import com.palantir.gradle.jdks.setup.common.Arch; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | import javax.inject.Inject; 24 | import org.gradle.api.Action; 25 | import org.gradle.api.model.ObjectFactory; 26 | import org.gradle.api.provider.Property; 27 | 28 | public abstract class JdkOsExtension { 29 | public abstract Property getJdkVersion(); 30 | 31 | @Inject 32 | protected abstract ObjectFactory getObjectFactory(); 33 | 34 | private final Map jdkOsArchExtensions = new HashMap<>(); 35 | 36 | public JdkOsExtension() { 37 | for (Arch arch : Arch.values()) { 38 | JdkOsArchExtension jdkOsArchExtension = getObjectFactory().newInstance(JdkOsArchExtension.class); 39 | jdkOsArchExtension.getJdkVersion().set(getJdkVersion()); 40 | jdkOsArchExtensions.put(arch, jdkOsArchExtension); 41 | } 42 | } 43 | 44 | final JdkOsArchExtension jdkFor(Arch arch) { 45 | return jdkOsArchExtensions.get(arch); 46 | } 47 | 48 | public final void arch(Arch arch, Action action) { 49 | action.execute(jdkOsArchExtensions.get(arch)); 50 | } 51 | 52 | public final void arch(String arch, Action action) { 53 | arch(Arch.fromStringThrowing(arch), action); 54 | } 55 | 56 | public final void fromJson(JdkOsInfoJson osInfo) { 57 | osInfo.arch().forEach((arch, archInfo) -> { 58 | arch(arch, archExtension -> { 59 | archExtension.fromJson(archInfo); 60 | }); 61 | }); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/PalantirCaPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.setup.CaResources; 20 | import com.palantir.gradle.jdks.setup.ILogger; 21 | import java.util.Map; 22 | import org.gradle.api.Plugin; 23 | import org.gradle.api.Project; 24 | 25 | public final class PalantirCaPlugin implements Plugin { 26 | 27 | private Project rootProject; 28 | private PalantirCaExtension extension; 29 | 30 | @Override 31 | public void apply(Project possibleRootProject) { 32 | if (possibleRootProject.getRootProject() != possibleRootProject) { 33 | throw new IllegalArgumentException( 34 | "com.palantir.jdks.palantir-ca must be applied to the root project only"); 35 | } 36 | 37 | rootProject = possibleRootProject; 38 | 39 | extension = rootProject.getExtensions().create("palantirCa", PalantirCaExtension.class); 40 | 41 | rootProject.getPluginManager().apply(JdksPlugin.class); 42 | 43 | ILogger logger = new GradleLogger( 44 | rootProject.getLogger(), extension.getLogLevel().get()); 45 | 46 | CaResources caResources = new CaResources(logger); 47 | rootProject 48 | .getExtensions() 49 | .getByType(JdksExtension.class) 50 | .getCaCerts() 51 | .putAll(possibleRootProject.provider(() -> caResources 52 | .readPalantirRootCaFromSystemTruststore() 53 | .map(cert -> Map.of(cert.getAlias(), cert.getContent())) 54 | .orElseGet(() -> { 55 | logger.logError("Could not find Palantir CA in system truststore"); 56 | return Map.of(); 57 | }))); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/GraalVmCeDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.JdkPath.Extension; 20 | import com.palantir.gradle.jdks.setup.common.Arch; 21 | import com.palantir.platform.OperatingSystem; 22 | 23 | public final class GraalVmCeDistribution implements JdkDistribution { 24 | @Override 25 | public String defaultBaseUrl() { 26 | return "https://github.com/graalvm/graalvm-ce-builds/releases/download"; 27 | } 28 | 29 | @Override 30 | public JdkPath path(JdkRelease jdkRelease) { 31 | String filename = String.format( 32 | "jdk-%s/graalvm-community-jdk-%s_%s-%s_bin", 33 | jdkRelease.version(), jdkRelease.version(), os(jdkRelease.os()), arch(jdkRelease.arch())); 34 | 35 | return JdkPath.builder() 36 | .filename(filename) 37 | .extension(extension(jdkRelease.os())) 38 | .build(); 39 | } 40 | 41 | private static String os(OperatingSystem os) { 42 | return switch (os) { 43 | case MACOS -> "macos"; 44 | case LINUX_GLIBC, LINUX_MUSL -> "linux"; 45 | case WINDOWS -> "windows"; 46 | default -> throw new UnsupportedOperationException("Case " + os + " not implemented"); 47 | }; 48 | } 49 | 50 | private static String arch(Arch arch) { 51 | return switch (arch) { 52 | case X86, X86_64 -> "x64"; 53 | case AARCH64 -> "aarch64"; 54 | default -> throw new UnsupportedOperationException("Case " + arch + " not implemented"); 55 | }; 56 | } 57 | 58 | private static Extension extension(OperatingSystem operatingSystem) { 59 | return switch (operatingSystem) { 60 | case LINUX_GLIBC, LINUX_MUSL, MACOS -> Extension.TARGZ; 61 | case WINDOWS -> Extension.ZIP; 62 | default -> throw new UnsupportedOperationException("Unknown OS: " + operatingSystem); 63 | }; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/AmazonCorrettoJdkDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.JdkPath.Extension; 20 | import com.palantir.gradle.jdks.setup.common.Arch; 21 | import com.palantir.platform.OperatingSystem; 22 | 23 | public final class AmazonCorrettoJdkDistribution implements JdkDistribution { 24 | @Override 25 | public String defaultBaseUrl() { 26 | return "https://corretto.aws"; 27 | } 28 | 29 | @Override 30 | public JdkPath path(JdkRelease jdkRelease) { 31 | String filename = String.format( 32 | "downloads/resources/%s/amazon-corretto-%s-%s-%s%s", 33 | jdkRelease.version(), 34 | jdkRelease.version(), 35 | os(jdkRelease.os()), 36 | arch(jdkRelease.arch()), 37 | windowsDashJdk(jdkRelease.os())); 38 | 39 | return JdkPath.builder() 40 | .filename(filename) 41 | .extension(extension(jdkRelease.os())) 42 | .build(); 43 | } 44 | 45 | private static String os(OperatingSystem os) { 46 | return switch (os) { 47 | case MACOS -> "macosx"; 48 | case LINUX_GLIBC -> "linux"; 49 | case LINUX_MUSL -> "alpine-linux"; 50 | case WINDOWS -> "windows"; 51 | }; 52 | } 53 | 54 | private static Extension extension(OperatingSystem os) { 55 | return switch (os) { 56 | case MACOS, LINUX_GLIBC, LINUX_MUSL -> Extension.TARGZ; 57 | case WINDOWS -> Extension.ZIP; 58 | }; 59 | } 60 | 61 | private static String arch(Arch arch) { 62 | return switch (arch) { 63 | case X86 -> "i386"; 64 | case X86_64 -> "x64"; 65 | case AARCH64 -> "aarch64"; 66 | }; 67 | } 68 | 69 | private static String windowsDashJdk(OperatingSystem os) { 70 | if (os == OperatingSystem.WINDOWS) { 71 | return "-jdk"; 72 | } 73 | 74 | return ""; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /gradle-jdks/src/test/groovy/com/palantir/gradle/jdks/GraalVmCeDistributionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import com.palantir.gradle.jdks.JdkPath.Extension; 22 | import com.palantir.gradle.jdks.setup.common.Arch; 23 | import com.palantir.platform.OperatingSystem; 24 | import org.junit.jupiter.api.Test; 25 | 26 | class GraalVmCeDistributionTest { 27 | 28 | @Test 29 | void jdk_path_linux_aarch64() { 30 | GraalVmCeDistribution distribution = new GraalVmCeDistribution(); 31 | JdkPath path = distribution.path(JdkRelease.builder() 32 | .arch(Arch.AARCH64) 33 | .os(OperatingSystem.LINUX_GLIBC) 34 | .version("23.0.2") 35 | .build()); 36 | assertThat(path.filename()).isEqualTo("jdk-23.0.2/graalvm-community-jdk-23.0.2_linux-aarch64_bin"); 37 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 38 | } 39 | 40 | @Test 41 | void jdk_path_macosx() { 42 | GraalVmCeDistribution distribution = new GraalVmCeDistribution(); 43 | JdkPath path = distribution.path(JdkRelease.builder() 44 | .arch(Arch.AARCH64) 45 | .os(OperatingSystem.MACOS) 46 | .version("23.0.2") 47 | .build()); 48 | assertThat(path.filename()).isEqualTo("jdk-23.0.2/graalvm-community-jdk-23.0.2_macos-aarch64_bin"); 49 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 50 | } 51 | 52 | @Test 53 | void jdk_path_windows_x86_64() { 54 | GraalVmCeDistribution distribution = new GraalVmCeDistribution(); 55 | JdkPath path = distribution.path(JdkRelease.builder() 56 | .arch(Arch.X86_64) 57 | .os(OperatingSystem.WINDOWS) 58 | .version("23.0.2") 59 | .build()); 60 | assertThat(path.filename()).isEqualTo("jdk-23.0.2/graalvm-community-jdk-23.0.2_windows-x64_bin"); 61 | assertThat(path.extension()).isEqualTo(Extension.ZIP); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/flow/ToolchainFailureFlowActionsPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2025 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.flow; 18 | 19 | import com.palantir.gradle.jdks.GradleJdksConfigsUtils; 20 | import com.palantir.gradle.jdks.enablement.GradleJdksEnablement; 21 | import com.palantir.platform.GradleOperatingSystem; 22 | import com.palantir.platform.OperatingSystem; 23 | import javax.inject.Inject; 24 | import org.gradle.api.Plugin; 25 | import org.gradle.api.Project; 26 | import org.gradle.api.flow.FlowProviders; 27 | import org.gradle.api.flow.FlowScope; 28 | import org.gradle.api.tasks.Nested; 29 | import org.slf4j.Logger; 30 | import org.slf4j.LoggerFactory; 31 | 32 | public abstract class ToolchainFailureFlowActionsPlugin implements Plugin { 33 | 34 | private static final Logger log = LoggerFactory.getLogger(ToolchainFailureFlowActionsPlugin.class); 35 | 36 | @Inject 37 | protected abstract FlowScope getFlowScope(); 38 | 39 | @Inject 40 | protected abstract FlowProviders getFlowProviders(); 41 | 42 | @Nested 43 | protected abstract GradleOperatingSystem getOperatingSystem(); 44 | 45 | @Override 46 | public final void apply(Project project) { 47 | OperatingSystem os = getOperatingSystem().getOperatingSystem().get(); 48 | if (!GradleJdksEnablement.isGradleJdkSetupEnabled( 49 | os, project.getRootProject().getProjectDir().toPath())) { 50 | throw new RuntimeException( 51 | "Cannot apply `ToolchainFailureFlowActionsPlugin` without enabling palantir.jdk.setup.enabled"); 52 | } 53 | getFlowScope().always(ToolchainFlowAction.class, spec -> { 54 | spec.getParameters().getBuildResult().set(getFlowProviders().getBuildWorkResult()); 55 | spec.getParameters() 56 | .getConfiguredJavaMajorVersions() 57 | .set(project.provider(() -> GradleJdksConfigsUtils.getConfiguredJavaMajorVersions( 58 | project.getRootProject().file("gradle/jdks").toPath(), os))); 59 | }); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /gradle-jdks-settings/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-gradle-plugin' 2 | apply plugin: 'groovy' 3 | apply plugin: 'com.palantir.external-publish-jar' 4 | apply plugin: 'com.palantir.gradle-plugin-testing' 5 | apply plugin: 'com.palantir.external-publish-gradle-plugin' 6 | apply plugin: 'com.palantir.shadow-jar' 7 | 8 | dependencies { 9 | // DO NOT ADD directly implementation/api dependencies here. We need to avoid overlapping dependencies between the 10 | // settings classLoader and the build classLoaders. 11 | shadeTransitively project(':gradle-jdks-setup-common') 12 | shadeTransitively project(':gradle-jdks-enablement') 13 | shadeTransitively 'com.palantir.gradle.utils:platform' 14 | 15 | testImplementation gradleTestKit() 16 | testImplementation 'com.netflix.nebula:nebula-test' 17 | testImplementation 'org.apache.commons:commons-compress' 18 | testImplementation project(':gradle-jdks-test-common') 19 | } 20 | 21 | gradlePlugin { 22 | plugins { 23 | patchJdks { 24 | id = 'com.palantir.jdks.settings' 25 | displayName = 'Palantir Gradle JDK Settings Plugin' 26 | description = 'Sets the Gradle properties for the Gradle JDK setup' 27 | implementationClass = 'com.palantir.gradle.jdks.settings.ToolchainJdksSettingsPlugin' 28 | tags.addAll("java", "jdks") 29 | } 30 | } 31 | website = 'https://github.com/palantir/gradle-jdks' 32 | vcsUrl = 'https://github.com/palantir/gradle-jdks' 33 | description = 'Gradle JDK settings plugins' 34 | } 35 | 36 | // When adding the shadeTransitively dependency, the pom file includes `gradle-jdks-root` as a dependency. 37 | // This is broken and it will lead to classpath configuration failures when the settings plugin is applied. As a 38 | // workaround, we are removing the artifact from the pom file. 39 | publishing.publications { 40 | withType(MavenPublication) { 41 | pom.withXml { 42 | var projectDependencyNodes = [] 43 | asNode().depthFirst { node -> 44 | if (node.name().localPart == 'dependency' && node.get("groupId").text() == "com.palantir.gradle.jdks" && node.get("artifactId").text() == "gradle-jdks-root") { 45 | projectDependencyNodes << node 46 | } 47 | } 48 | projectDependencyNodes.each { node -> 49 | node.parent().remove(node) 50 | } 51 | } 52 | } 53 | } 54 | 55 | // Changing the location where the gradle jdks are installed such that the settings plugin can run the 56 | // gradle-jdks-setup.sh configuration script to install the missing jdks. 57 | tasks.withType(Test) { 58 | environment("HOME", "/tmp/gradleJdksSettingsTest") 59 | systemProperty 'user.home', '/tmp/gradleJdksSettingsTest' 60 | dependsOn project(':gradle-jdks').tasks.withType(PluginUnderTestMetadata.class) 61 | } 62 | 63 | gradleTestUtils { 64 | gradleVersions = ['8.14.3'] 65 | configurationCacheEnabled = true 66 | } 67 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdkExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.json.JdkInfoJson; 20 | import com.palantir.platform.OperatingSystem; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | import javax.inject.Inject; 24 | import org.gradle.api.Action; 25 | import org.gradle.api.model.ObjectFactory; 26 | import org.gradle.api.provider.Property; 27 | 28 | public abstract class JdkExtension { 29 | // Not called `version` to avoid being interfered with by `Project#setVersion`! 30 | public abstract Property getJdkVersion(); 31 | 32 | public abstract Property getDistributionName(); 33 | 34 | private final Map jdkOsExtensions = new HashMap<>(); 35 | 36 | @Inject 37 | protected abstract ObjectFactory getObjectFactory(); 38 | 39 | public JdkExtension() { 40 | for (OperatingSystem os : OperatingSystem.values()) { 41 | JdkOsExtension jdkOsExtension = getObjectFactory().newInstance(JdkOsExtension.class); 42 | jdkOsExtension.getJdkVersion().set(getJdkVersion()); 43 | jdkOsExtensions.put(os, jdkOsExtension); 44 | } 45 | } 46 | 47 | final JdkOsExtension jdkFor(OperatingSystem os) { 48 | return jdkOsExtensions.get(os); 49 | } 50 | 51 | public final void setDistribution(JdkDistributionName jdkDistributionName) { 52 | getDistributionName().set(jdkDistributionName); 53 | } 54 | 55 | public final void setDistribution(String distributionName) { 56 | setDistribution(JdkDistributionName.fromStringThrowing(distributionName)); 57 | } 58 | 59 | public final void os(OperatingSystem os, Action action) { 60 | action.execute(jdkOsExtensions.get(os)); 61 | } 62 | 63 | public final void os(String os, Action action) { 64 | os(OperatingSystem.fromStringThrowing(os), action); 65 | } 66 | 67 | public final void fromJson(JdkInfoJson jdkInfo) { 68 | getDistributionName().set(jdkInfo.distribution()); 69 | 70 | jdkInfo.os().forEach((os, osInfo) -> { 71 | os(os, osExtension -> { 72 | osExtension.fromJson(osInfo); 73 | }); 74 | }); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/GradleJdksJavaInstallationMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import java.lang.reflect.Proxy; 20 | import org.gradle.api.file.Directory; 21 | import org.gradle.api.provider.Provider; 22 | import org.gradle.jvm.toolchain.JavaInstallationMetadata; 23 | import org.gradle.jvm.toolchain.JavaLanguageVersion; 24 | 25 | final class GradleJdksJavaInstallationMetadata { 26 | public static JavaInstallationMetadata create( 27 | JavaLanguageVersion javaLanguageVersion, 28 | String javaRuntimeVersion, 29 | String jvmVersion, 30 | String vendor, 31 | Provider installationPath) { 32 | return (JavaInstallationMetadata) Proxy.newProxyInstance( 33 | GradleJdksJavaInstallationMetadata.class.getClassLoader(), 34 | new Class[] {JavaInstallationMetadata.class}, 35 | (_proxy, method, args) -> { 36 | if (args != null && args.length != 0) { 37 | throw new UnsupportedOperationException( 38 | "Unsupported method: " + method + " with " + args.length + " args"); 39 | } 40 | 41 | switch (method.getName()) { 42 | case "getLanguageVersion" -> { 43 | return javaLanguageVersion; 44 | } 45 | case "getJavaRuntimeVersion" -> { 46 | return javaRuntimeVersion; 47 | } 48 | case "getJvmVersion" -> { 49 | return jvmVersion; 50 | } 51 | case "getVendor" -> { 52 | return vendor; 53 | } 54 | case "getInstallationPath" -> { 55 | return installationPath.get(); 56 | } 57 | case "isCurrentJvm" -> { 58 | return false; 59 | } 60 | } 61 | 62 | throw new UnsupportedOperationException("Unsupported method: " + method); 63 | }); 64 | } 65 | 66 | private GradleJdksJavaInstallationMetadata() {} 67 | } 68 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/GenerateGradleJdksConfigsTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.setup.FileUtils; 20 | import java.io.File; 21 | import java.nio.file.Path; 22 | import java.util.List; 23 | import org.gradle.api.file.Directory; 24 | import org.gradle.api.file.DirectoryProperty; 25 | import org.gradle.api.logging.Logger; 26 | import org.gradle.api.logging.Logging; 27 | import org.gradle.api.tasks.OutputDirectory; 28 | 29 | public abstract class GenerateGradleJdksConfigsTask extends GradleJdksConfigs { 30 | 31 | private static final Logger log = Logging.getLogger(GenerateGradleJdksConfigsTask.class); 32 | 33 | @OutputDirectory 34 | public abstract DirectoryProperty getOutputGradleDirectory(); 35 | 36 | @Override 37 | protected final Directory gradleDirectory() { 38 | return getOutputGradleDirectory().get(); 39 | } 40 | 41 | @Override 42 | protected final void maybePrepareForAction(List targetPaths) { 43 | targetPaths.forEach(FileUtils::delete); 44 | } 45 | 46 | @Override 47 | protected final void applyGradleJdkFileAction( 48 | Path downloadUrlPath, Path localUrlPath, JdkDistributionConfig jdkDistribution) { 49 | GradleJdksConfigsUtils.createDirectories(downloadUrlPath.getParent()); 50 | GradleJdksConfigsUtils.writeConfigurationFile( 51 | downloadUrlPath, jdkDistribution.getDownloadUrl().get()); 52 | GradleJdksConfigsUtils.writeConfigurationFile( 53 | localUrlPath, jdkDistribution.getLocalPath().get()); 54 | } 55 | 56 | @Override 57 | protected final void applyGradleJdkDaemonVersionAction(Path gradleJdkDaemonVersion) { 58 | GradleJdksConfigsUtils.writeConfigurationFile( 59 | gradleJdkDaemonVersion, getDaemonJavaVersion().get().toString()); 60 | } 61 | 62 | @Override 63 | protected final void applyGradleJdkJarAction(File gradleJdkJarFile, String resourceName) { 64 | GradleJdksConfigsUtils.writeResourceAsStreamToFile(resourceName, gradleJdkJarFile); 65 | } 66 | 67 | @Override 68 | protected final void applyGradleJdkScriptAction(File gradleJdkScriptFile, String resourceName) { 69 | GradleJdksConfigsUtils.writeResourceAsStreamToFile(resourceName, gradleJdkScriptFile); 70 | GradleJdksConfigsUtils.setExecuteFilePermissions(gradleJdkScriptFile.toPath()); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JdksPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.enablement.GradleJdksEnablement; 20 | import com.palantir.platform.GradleOperatingSystem; 21 | import com.palantir.platform.OperatingSystem; 22 | import java.io.File; 23 | import java.util.Arrays; 24 | import org.gradle.api.Plugin; 25 | import org.gradle.api.Project; 26 | import org.gradle.api.tasks.Nested; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | 30 | public abstract class JdksPlugin implements Plugin { 31 | 32 | private static final Logger log = LoggerFactory.getLogger(JdksPlugin.class); 33 | 34 | @Nested 35 | protected abstract GradleOperatingSystem getOperatingSystem(); 36 | 37 | @Override 38 | public final void apply(Project rootProject) { 39 | if (rootProject.getRootProject() != rootProject) { 40 | throw new IllegalArgumentException("com.palantir.jdks must be applied to the root project only"); 41 | } 42 | 43 | OperatingSystem os = getOperatingSystem().getOperatingSystem().get(); 44 | if (GradleJdksEnablement.isGradleJdkSetupEnabled( 45 | os, rootProject.getProjectDir().toPath())) { 46 | rootProject.getPluginManager().apply(ToolchainsPlugin.class); 47 | } else { 48 | rootProject.getPluginManager().apply(BaselineJavaJdksPlugin.class); 49 | } 50 | } 51 | 52 | public static JdksExtension extension(Project rootProject, JdkDistributions jdkDistributions) { 53 | @SuppressWarnings("for-rollout:GradleTypesAsFields") 54 | JdksExtension jdksExtension = rootProject.getExtensions().create("jdks", JdksExtension.class); 55 | jdksExtension 56 | .getJdkStorageLocation() 57 | .set(rootProject 58 | .getLayout() 59 | .dir(rootProject.provider( 60 | () -> new File(System.getProperty("user.home"), ".gradle/gradle-jdks")))); 61 | 62 | Arrays.stream(JdkDistributionName.values()).forEach(jdkDistributionName -> { 63 | jdksExtension.jdkDistribution(jdkDistributionName, jdkDistributionExtension -> { 64 | jdkDistributionExtension 65 | .getBaseUrl() 66 | .set(jdkDistributions.get(jdkDistributionName).defaultBaseUrl()); 67 | }); 68 | }); 69 | 70 | return jdksExtension; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/test/resources/amazon-cas-with-whitespace-between.pem: -------------------------------------------------------------------------------- 1 | https://www.amazontrust.com/repository/SFSRootCAG2.pem 2 | -----BEGIN CERTIFICATE----- 3 | MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx 4 | EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT 5 | HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVs 6 | ZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5 7 | MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNVBAYTAlVTMRAwDgYD 8 | VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy 9 | ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2Vy 10 | dmljZXMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI 11 | hvcNAQEBBQADggEPADCCAQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20p 12 | OsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm2 13 | 8xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4PahHQUw2eeBGg6345AWh1K 14 | Ts9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLPLJGmpufe 15 | hRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk 16 | 6mFBrMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAw 17 | DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+q 18 | AdcwKziIorhtSpzyEZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI 19 | bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB 20 | ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z 21 | qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd 22 | iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn 23 | 0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN 24 | sSi6 25 | -----END CERTIFICATE----- 26 | 27 | -----BEGIN CERTIFICATE----- 28 | MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5 29 | MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g 30 | Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG 31 | A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg 32 | Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl 33 | ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j 34 | QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr 35 | ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr 36 | BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM 37 | YyRIHN8wfdVoOw== 38 | -----END CERTIFICATE----- 39 | 40 | 41 | 42 | https://www.amazontrust.com/repository/AmazonRootCA4.pem 43 | -----BEGIN CERTIFICATE----- 44 | MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5 45 | MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g 46 | Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG 47 | A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg 48 | Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi 49 | 9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk 50 | M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB 51 | /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB 52 | MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw 53 | CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW 54 | 1KyLa2tJElMzrdfkviT8tQp21KW8EA== 55 | -----END CERTIFICATE----- 56 | 57 | 58 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/test/java/com/palantir/gradle/jdks/setup/GradleJdkInstallationSetupTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import com.palantir.gradle.jdks.setup.GradleJdkInstallationSetup.Command; 22 | import java.io.IOException; 23 | import java.nio.charset.StandardCharsets; 24 | import java.nio.file.Files; 25 | import java.nio.file.Path; 26 | import java.nio.file.StandardOpenOption; 27 | import org.junit.jupiter.api.Test; 28 | import org.junit.jupiter.api.io.TempDir; 29 | 30 | public final class GradleJdkInstallationSetupTest { 31 | 32 | @TempDir 33 | Path tempDir; 34 | 35 | @Test 36 | public void can_copy_jdk_installation_with_no_certs() throws IOException { 37 | String distribution = 38 | Path.of(System.getProperty("java.home")).getFileName().toString(); 39 | GradleJdkInstallationSetup.main(new String[] { 40 | Command.JDK_SETUP.toString(), 41 | tempDir.resolve(distribution).toAbsolutePath().toString(), 42 | }); 43 | Path destDistribution = tempDir.resolve(distribution); 44 | Path destJavaHome = destDistribution.resolve("bin/java"); 45 | assertThat(destDistribution).exists(); 46 | assertThat(destJavaHome).exists(); 47 | } 48 | 49 | @Test 50 | public void can_write_gradle_config_file() throws IOException { 51 | Path gradleConfig = tempDir.resolve(".gradle/config.properties"); 52 | GradleJdkInstallationSetup.main( 53 | new String[] {Command.DAEMON_SETUP.toString(), tempDir.toString(), "my_directory"}); 54 | assertThat(Files.readString(gradleConfig)).contains("java.home=my_directory"); 55 | } 56 | 57 | @Test 58 | public void can_update_gradle_config_file() throws IOException { 59 | Files.createDirectories(tempDir.resolve(".gradle")); 60 | Path gradleConfig = tempDir.resolve(".gradle/config.properties"); 61 | Files.write( 62 | gradleConfig, 63 | "# comment\njava.home=initial_value\nkey1=value1".getBytes(StandardCharsets.UTF_8), 64 | StandardOpenOption.CREATE); 65 | GradleJdkInstallationSetup.main( 66 | new String[] {Command.DAEMON_SETUP.toString(), tempDir.toString(), "my_directory"}); 67 | assertThat(Files.readString(gradleConfig)) 68 | .contains("java.home=my_directory") 69 | .contains("key1=value1") 70 | .doesNotContain("java.home=initial_value"); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH= 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /gradle-jdks/src/test/groovy/com/palantir/gradle/jdks/JdksExtensionProjectSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks 18 | 19 | import com.palantir.gradle.plugintesting.GradleTestVersions 20 | import nebula.test.IntegrationSpec 21 | import spock.lang.Unroll 22 | 23 | @Unroll 24 | final class JdksExtensionProjectSpec extends IntegrationSpec { 25 | def setup() { 26 | // language=Gradle 27 | buildFile << ''' 28 | import com.palantir.gradle.jdks.* 29 | 30 | buildscript { 31 | repositories { 32 | mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } 33 | gradlePluginPortal() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } 34 | } 35 | 36 | dependencies { 37 | classpath "com.palantir.gradle.utils:platform:0.13.0" 38 | } 39 | } 40 | 41 | extensions.create('jdks', JdksExtension) 42 | '''.stripIndent(true) 43 | } 44 | 45 | def '#gradleVersionNumber: correctly handles multi level version overrides'() { 46 | gradleVersion = gradleVersionNumber 47 | // language=Gradle 48 | buildFile << ''' 49 | import com.palantir.gradle.jdks.setup.common.Arch 50 | import com.palantir.platform.OperatingSystem 51 | 52 | jdks { 53 | jdk(11) { 54 | distribution = 'amazon-corretto' 55 | jdkVersion = '11.1' 56 | 57 | os('linux-glibc') { 58 | jdkVersion = '11.2' 59 | 60 | arch('x86-64') { 61 | jdkVersion = '11.3' 62 | } 63 | } 64 | } 65 | } 66 | 67 | def jdkVersionFor = { os, arch -> 68 | jdks.jdkFor(JavaLanguageVersion.of(11), project).get().jdkFor(os).jdkFor(arch).jdkVersion.get() 69 | } 70 | 71 | println('jdkVersion macos aarch64: ' + jdkVersionFor(OperatingSystem.MACOS, Arch.AARCH64)) 72 | println('jdkVersion linux-glibc aarch64: ' + jdkVersionFor(OperatingSystem.LINUX_GLIBC, Arch.AARCH64)) 73 | println('jdkVersion linux-glibc x64: ' + jdkVersionFor(OperatingSystem.LINUX_GLIBC, Arch.X86_64)) 74 | '''.stripIndent(true) 75 | 76 | when: 77 | def stdout = runTasksSuccessfully('help').standardOutput 78 | 79 | then: 80 | stdout.contains('jdkVersion macos aarch64: 11.1') 81 | stdout.contains('jdkVersion linux-glibc aarch64: 11.2') 82 | stdout.contains('jdkVersion linux-glibc x64: 11.3') 83 | 84 | where: 85 | gradleVersionNumber << GradleTestVersions.getGradleVersionsForTests() 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/JarResources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.jdks.setup.FileUtils; 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | import java.io.UncheckedIOException; 26 | import java.nio.file.Path; 27 | import java.util.jar.JarEntry; 28 | import java.util.jar.JarInputStream; 29 | import java.util.jar.JarOutputStream; 30 | 31 | public final class JarResources { 32 | 33 | public static void extractJar(File jarFile, Path sourceDirectory) { 34 | FileUtils.createDirectories(sourceDirectory); 35 | try (JarInputStream jarInputStream = new JarInputStream(new FileInputStream(jarFile))) { 36 | JarEntry jarEntry; 37 | while ((jarEntry = jarInputStream.getNextJarEntry()) != null) { 38 | File outputFile = new File(sourceDirectory.toFile(), jarEntry.getName()); 39 | if (jarEntry.isDirectory()) { 40 | outputFile.mkdirs(); 41 | } else { 42 | outputFile.getParentFile().mkdirs(); 43 | try (FileOutputStream outputStream = new FileOutputStream(outputFile)) { 44 | jarInputStream.transferTo(outputStream); 45 | } 46 | } 47 | } 48 | } catch (IOException e) { 49 | throw new UncheckedIOException("Could not extract jar", e); 50 | } 51 | } 52 | 53 | public static void createJarFromDirectory(File sourceDir, File outputFile) { 54 | try (FileOutputStream fos = new FileOutputStream(outputFile); 55 | JarOutputStream jos = new JarOutputStream(fos)) { 56 | addDirectoryToJar(jos, sourceDir, ""); 57 | } catch (IOException e) { 58 | throw new UncheckedIOException("Failed to create Jar from dir", e); 59 | } 60 | } 61 | 62 | private static void addDirectoryToJar(JarOutputStream jarOutputStream, File dir, String relativePath) 63 | throws IOException { 64 | File[] files = dir.listFiles(); 65 | if (files == null) { 66 | return; 67 | } 68 | for (File file : files) { 69 | if (file.isDirectory()) { 70 | String newRelativePath = relativePath + file.getName() + "/"; 71 | addDirectoryToJar(jarOutputStream, file, newRelativePath); 72 | } else { 73 | String entryName = relativePath + file.getName(); 74 | JarEntry entry = new JarEntry(entryName); 75 | jarOutputStream.putNextEntry(entry); 76 | try (InputStream in = new FileInputStream(file)) { 77 | in.transferTo(jarOutputStream); 78 | } 79 | jarOutputStream.closeEntry(); 80 | } 81 | } 82 | } 83 | 84 | private JarResources() {} 85 | } 86 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/SetupJdksTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.platform.GradleOperatingSystem; 20 | import com.palantir.platform.OperatingSystem; 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.OutputStream; 23 | import java.nio.charset.StandardCharsets; 24 | import javax.inject.Inject; 25 | import org.apache.tools.ant.util.TeeOutputStream; 26 | import org.gradle.api.DefaultTask; 27 | import org.gradle.api.file.RegularFileProperty; 28 | import org.gradle.api.logging.Logger; 29 | import org.gradle.api.logging.Logging; 30 | import org.gradle.api.tasks.InputFile; 31 | import org.gradle.api.tasks.Nested; 32 | import org.gradle.api.tasks.TaskAction; 33 | import org.gradle.process.ExecOperations; 34 | import org.gradle.process.ExecResult; 35 | 36 | /** 37 | * Actually triggering the patched `./gradlew` script (that configures and installs the JDKs) and runs `javaToolchains` 38 | * to output the JDKs that Gradle will use. 39 | */ 40 | public abstract class SetupJdksTask extends DefaultTask { 41 | 42 | private static final Logger logger = Logging.getLogger(SetupJdksTask.class); 43 | 44 | @InputFile 45 | public abstract RegularFileProperty getGradlewScript(); 46 | 47 | @Inject 48 | protected abstract ExecOperations getExecOperations(); 49 | 50 | @Nested 51 | protected abstract GradleOperatingSystem getOperatingSystem(); 52 | 53 | @TaskAction 54 | public final void exec() { 55 | if (getOperatingSystem().getOperatingSystem().get().equals(OperatingSystem.WINDOWS)) { 56 | logger.debug("Windows gradleJdk setup is not yet supported."); 57 | return; 58 | } 59 | ByteArrayOutputStream inMemoryOutput = new ByteArrayOutputStream(); 60 | OutputStream logOutput = new TeeOutputStream(System.out, inMemoryOutput); 61 | 62 | ExecResult execResult = getExecOperations().exec(execSpec -> { 63 | execSpec.setIgnoreExitValue(true); 64 | execSpec.setStandardOutput(logOutput); 65 | execSpec.setErrorOutput(logOutput); 66 | execSpec.commandLine(getGradlewScript().get().getAsFile().toPath(), "-q", "javaToolchains", "--stacktrace"); 67 | }); 68 | 69 | if (execResult.getExitValue() != 0) { 70 | String output = inMemoryOutput.toString(StandardCharsets.UTF_8); 71 | if (output.contains("UnsupportedClassVersionError")) { 72 | throw new RuntimeException( 73 | "The Gradle JDK setup has failed. The Gradle Daemon major version might be incorrectly set." 74 | + " Update the Gradle JDK major version using `jdks.daemonTargetVersion` in your" 75 | + " `build.gradle` and the `gradle/gradle-daemon-jdk-version` entry"); 76 | } 77 | throw new RuntimeException(String.format("The Gradle JDK setup has failed. Error: %s", output)); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /gradle-jdks/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-gradle-plugin' 2 | apply plugin: 'groovy' 3 | apply plugin: 'com.palantir.external-publish-jar' 4 | apply plugin: 'com.palantir.gradle-plugin-testing' 5 | apply plugin: 'com.palantir.external-publish-gradle-plugin' 6 | apply plugin: 'org.unbroken-dome.test-sets' 7 | 8 | testSets { 9 | integTest 10 | } 11 | 12 | tasks.build.dependsOn tasks.integTest 13 | 14 | dependencies { 15 | api project(':gradle-jdks-distributions') 16 | api project(':gradle-jdks-json') 17 | api project(':gradle-jdks-setup') 18 | api project(':gradle-jdks-enablement') 19 | 20 | implementation('com.palantir.baseline:gradle-baseline-java') { 21 | exclude group: 'com.diffplug.spotless', module: 'spotless-plugin-gradle' 22 | } 23 | implementation 'com.palantir.gradle.failure-reports:gradle-failure-reports-exceptions' 24 | implementation 'com.palantir.gradle.utils:lazily-configured-mapping' 25 | implementation 'com.google.guava:guava' 26 | implementation 'commons-io:commons-io' 27 | implementation 'org.apache.commons:commons-compress' 28 | implementation 'org.ow2.asm:asm' 29 | implementation 'com.palantir.gradle.idea-configuration:gradle-idea-configuration' 30 | implementation 'com.palantir.gradle.utils:platform' 31 | 32 | compileOnly 'com.palantir.gradle.auto-parallelizable:auto-parallelizable-annotations' 33 | compileOnly 'org.immutables:value::annotations' 34 | annotationProcessor 'com.palantir.gradle.auto-parallelizable:auto-parallelizable' 35 | annotationProcessor 'org.immutables:value' 36 | 37 | testImplementation gradleTestKit() 38 | testImplementation project(':gradle-jdks-settings') 39 | testImplementation project(':gradle-jdks-test-common') 40 | testImplementation 'com.netflix.nebula:nebula-test' 41 | testImplementation 'org.junit.jupiter:junit-jupiter' 42 | testImplementation 'org.assertj:assertj-core' 43 | testImplementation 'org.mockito:mockito-core' 44 | testImplementation 'org.mockito:mockito-junit-jupiter' 45 | } 46 | 47 | gradlePlugin { 48 | plugins { 49 | jdks { 50 | id = 'com.palantir.jdks' 51 | displayName = 'Palantir JDK Auto-provisioning Plugin' 52 | description = 'Auto-provisions specific versions of JDKs' 53 | implementationClass = 'com.palantir.gradle.jdks.JdksPlugin' 54 | tags.addAll("java", "jdks") 55 | } 56 | palantirCa { 57 | id = 'com.palantir.jdks.palantir-ca' 58 | displayName = 'Palantir CA for gradle-jdks' 59 | description = 'Includes the Palantir CA from the system truststore' 60 | implementationClass = 'com.palantir.gradle.jdks.PalantirCaPlugin' 61 | tags.addAll("java", "jdks", "palantir ca") 62 | } 63 | } 64 | website = 'https://github.com/palantir/gradle-jdks' 65 | vcsUrl = 'https://github.com/palantir/gradle-jdks' 66 | description = 'Download specific JDKs versions automatically' 67 | } 68 | 69 | tasks.withType(JavaCompile).configureEach { 70 | it.options.errorprone.disable 'JavaxInjectOnAbstractMethod' 71 | it.options.errorprone.disable 'StrictUnusedVariable' 72 | } 73 | 74 | tasks.withType(Test) { 75 | environment(Map.of("PROJECT_VERSION", project.version)) 76 | systemProperty 'ignoreDeprecations', 'true' 77 | dependsOn project(':gradle-jdks-settings').tasks.withType(PluginUnderTestMetadata.class) 78 | } 79 | 80 | tasks.withType(ProcessResources.class).configureEach { 81 | from(project(':gradle-jdks-setup').tasks.named('fatJar')) { 82 | rename { 'gradle-jdks-setup.jar' } 83 | } 84 | } 85 | 86 | gradleTestUtils { 87 | gradleVersions = ['8.14.3'] 88 | configurationCacheEnabled = true 89 | } 90 | -------------------------------------------------------------------------------- /gradle/gradle-jdks-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | ############################################################################## 19 | # 20 | # Gradle jdk set up script for POSIX generated by gradle-jdks. 21 | # 22 | # This script does the following: 23 | # (1) Downloads all the JDK distributions that are present in `gradle/jdks` 24 | # (2) Installs the distributions in a temporary directory 25 | # (3) Calls the java class `GradleJdkInstallationSetup` that will move each distribution to 26 | # `$GRADLE_USER_HOME/${local_path}` based on the local_path=`gradle/jdks/${majorVersion}/${os}/${arch}/local_path` 27 | # and it will set up the certificates based on `gradle/certs` entries for the locally installed distribution 28 | # (4) Sets `org.gradle.java.home` to the JDK distribution that is used by the Gradle Daemon 29 | # 30 | # 31 | # Important for running: 32 | # This script requires all of these POSIX shell features: 33 | # * functions; 34 | # * expansions «$var», «${var}», «${var%suffix}», and «$( cmd )»; 35 | # * compound commands having a testable exit status, especially «case»; 36 | # * various built-in commands including «command» and «set». 37 | # 38 | ############################################################################## 39 | 40 | set -e 41 | # Set pipefail if it works in a subshell, disregard if unsupported 42 | # shellcheck disable=SC3040 43 | if (set -o pipefail 2>/dev/null); then 44 | set -o pipefail 45 | fi 46 | 47 | # Resolve links: $0 may be a link 48 | app_path=$0 49 | 50 | # Need this for daisy-chained symlinks. 51 | while 52 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 53 | [ -h "$app_path" ] 54 | do 55 | ls=$( ls -ld "$app_path" ) 56 | link=${ls#*' -> '} 57 | case $link in #( 58 | /*) app_path=$link ;; #( 59 | *) app_path=$APP_HOME$link ;; 60 | esac 61 | done 62 | 63 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 64 | APP_HOME=${APP_HOME%/gradle} 65 | APP_GRADLE_DIR="$APP_HOME"/gradle 66 | 67 | # Loading gradle jdk functions 68 | . "$APP_GRADLE_DIR"/gradle-jdks-functions.sh 69 | 70 | if ! is_arch_os_supported; then 71 | echo "Skipping Gradle JDKs Setup, Unsupported OS/Arch..." 72 | cleanup 73 | return 74 | fi 75 | 76 | install_and_setup_jdks "$APP_GRADLE_DIR" 77 | 78 | gradle_daemon_jdk_version=$(read_value "$APP_GRADLE_DIR"/gradle-daemon-jdk-version) 79 | gradle_daemon_jdk_distribution_local_path=$(read_value "$APP_GRADLE_DIR"/jdks/"$gradle_daemon_jdk_version"/"$OS"/"$ARCH"/local-path) 80 | "$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" 81 | 82 | # [Used by ./gradlew only] Setting the Gradle Daemon Java Home to the JDK distribution 83 | export GRADLE_DAEMON_JDK="$GRADLE_JDKS_HOME/$gradle_daemon_jdk_distribution_local_path" 84 | set -- "-Dorg.gradle.java.home=$GRADLE_DAEMON_JDK" "$@" 85 | 86 | cleanup 87 | -------------------------------------------------------------------------------- /gradle-jdks/src/test/groovy/com/palantir/gradle/jdks/AmazonCorrettoJdkDistributionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import com.palantir.gradle.jdks.JdkPath.Extension; 22 | import com.palantir.gradle.jdks.setup.common.Arch; 23 | import com.palantir.platform.OperatingSystem; 24 | import org.junit.jupiter.api.Test; 25 | 26 | class AmazonCorrettoJdkDistributionTest { 27 | private final AmazonCorrettoJdkDistribution distribution = new AmazonCorrettoJdkDistribution(); 28 | 29 | @Test 30 | void jdk_path_linux_x86_64() { 31 | JdkPath path = distribution.path(JdkRelease.builder() 32 | .arch(Arch.X86_64) 33 | .os(OperatingSystem.LINUX_GLIBC) 34 | .version("11.0.16.9.1") 35 | .build()); 36 | assertThat(path.filename()).isEqualTo("downloads/resources/11.0.16.9.1/amazon-corretto-11.0.16.9.1-linux-x64"); 37 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 38 | } 39 | 40 | @Test 41 | void jdk_path_macosx_aarch64() { 42 | JdkPath path = distribution.path(JdkRelease.builder() 43 | .arch(Arch.AARCH64) 44 | .os(OperatingSystem.MACOS) 45 | .version("17.0.4.9.1") 46 | .build()); 47 | assertThat(path.filename()) 48 | .isEqualTo("downloads/resources/17.0.4.9.1/amazon-corretto-17.0.4.9.1-macosx-aarch64"); 49 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 50 | } 51 | 52 | @Test 53 | void jdk_path_macosx_x64() { 54 | JdkPath path = distribution.path(JdkRelease.builder() 55 | .arch(Arch.X86_64) 56 | .os(OperatingSystem.MACOS) 57 | .version("11.0.16.9.1") 58 | .build()); 59 | assertThat(path.filename()).isEqualTo("downloads/resources/11.0.16.9.1/amazon-corretto-11.0.16.9.1-macosx-x64"); 60 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 61 | } 62 | 63 | @Test 64 | void jdk_path_musl_linux_x64_64() { 65 | JdkPath path = distribution.path(JdkRelease.builder() 66 | .arch(Arch.X86_64) 67 | .os(OperatingSystem.LINUX_MUSL) 68 | .version("11.0.16.9.1") 69 | .build()); 70 | assertThat(path.filename()) 71 | .isEqualTo("downloads/resources/11.0.16.9.1/amazon-corretto-11.0.16.9.1-alpine-linux-x64"); 72 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 73 | } 74 | 75 | @Test 76 | void jdk_path_windows_x86_64() { 77 | JdkPath path = distribution.path(JdkRelease.builder() 78 | .arch(Arch.X86_64) 79 | .os(OperatingSystem.WINDOWS) 80 | .version("17.0.4.9.1") 81 | .build()); 82 | assertThat(path.filename()) 83 | .isEqualTo("downloads/resources/17.0.4.9.1/amazon-corretto-17.0.4.9.1-windows-x64-jdk"); 84 | assertThat(path.extension()).isEqualTo(Extension.ZIP); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/main/resources/gradle-jdks-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | ############################################################################## 19 | # 20 | # Gradle jdk set up script for POSIX generated by gradle-jdks. 21 | # 22 | # This script does the following: 23 | # (1) Downloads all the JDK distributions that are present in `gradle/jdks` 24 | # (2) Installs the distributions in a temporary directory 25 | # (3) Calls the java class `GradleJdkInstallationSetup` that will move each distribution to 26 | # `$GRADLE_USER_HOME/${local_path}` based on the local_path=`gradle/jdks/${majorVersion}/${os}/${arch}/local_path` 27 | # and it will set up the certificates based on `gradle/certs` entries for the locally installed distribution 28 | # (4) Sets `org.gradle.java.home` to the JDK distribution that is used by the Gradle Daemon 29 | # 30 | # 31 | # Important for running: 32 | # This script requires all of these POSIX shell features: 33 | # * functions; 34 | # * expansions «$var», «${var}», «${var%suffix}», and «$( cmd )»; 35 | # * compound commands having a testable exit status, especially «case»; 36 | # * various built-in commands including «command» and «set». 37 | # 38 | ############################################################################## 39 | 40 | set -e 41 | # Set pipefail if it works in a subshell, disregard if unsupported 42 | # shellcheck disable=SC3040 43 | if (set -o pipefail 2>/dev/null); then 44 | set -o pipefail 45 | fi 46 | 47 | # Resolve links: $0 may be a link 48 | app_path=$0 49 | 50 | # Need this for daisy-chained symlinks. 51 | while 52 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 53 | [ -h "$app_path" ] 54 | do 55 | ls=$( ls -ld "$app_path" ) 56 | link=${ls#*' -> '} 57 | case $link in #( 58 | /*) app_path=$link ;; #( 59 | *) app_path=$APP_HOME$link ;; 60 | esac 61 | done 62 | 63 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 64 | APP_HOME=${APP_HOME%/gradle} 65 | APP_GRADLE_DIR="$APP_HOME"/gradle 66 | 67 | # Loading gradle jdk functions 68 | . "$APP_GRADLE_DIR"/gradle-jdks-functions.sh 69 | 70 | if ! is_arch_os_supported; then 71 | echo "Skipping Gradle JDKs Setup, Unsupported OS/Arch..." 72 | cleanup 73 | return 74 | fi 75 | 76 | install_and_setup_jdks "$APP_GRADLE_DIR" 77 | 78 | gradle_daemon_jdk_version=$(read_value "$APP_GRADLE_DIR"/gradle-daemon-jdk-version) 79 | gradle_daemon_jdk_distribution_local_path=$(read_value "$APP_GRADLE_DIR"/jdks/"$gradle_daemon_jdk_version"/"$OS"/"$ARCH"/local-path) 80 | "$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" 81 | 82 | # [Used by ./gradlew only] Setting the Gradle Daemon Java Home to the JDK distribution 83 | export GRADLE_DAEMON_JDK="$GRADLE_JDKS_HOME/$gradle_daemon_jdk_distribution_local_path" 84 | set -- "-Dorg.gradle.java.home=$GRADLE_DAEMON_JDK" "$@" 85 | 86 | cleanup 87 | -------------------------------------------------------------------------------- /gradle-jdks-setup/src/main/java/com/palantir/gradle/jdks/setup/FileUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks.setup; 18 | 19 | import java.io.IOException; 20 | import java.io.UncheckedIOException; 21 | import java.nio.file.FileVisitResult; 22 | import java.nio.file.FileVisitor; 23 | import java.nio.file.Files; 24 | import java.nio.file.Path; 25 | import java.nio.file.StandardCopyOption; 26 | import java.nio.file.attribute.BasicFileAttributes; 27 | import java.util.Comparator; 28 | import java.util.Optional; 29 | import java.util.stream.Stream; 30 | 31 | public final class FileUtils { 32 | 33 | public static void delete(Path path) { 34 | if (!Files.exists(path)) { 35 | return; 36 | } 37 | if (Files.isDirectory(path)) { 38 | deleteDirectory(path); 39 | } else { 40 | deleteFile(path); 41 | } 42 | } 43 | 44 | private static void deleteDirectory(Path dir) { 45 | try (Stream paths = Files.walk(dir)) { 46 | paths.sorted(Comparator.reverseOrder()).forEach(FileUtils::deleteFile); 47 | } catch (IOException e) { 48 | throw new UncheckedIOException("Failed to delete directory", e); 49 | } 50 | } 51 | 52 | private static void deleteFile(Path targetPath) { 53 | try { 54 | Files.delete(targetPath); 55 | } catch (IOException e) { 56 | throw new UncheckedIOException(String.format("Failed to delete path %s", targetPath), e); 57 | } 58 | } 59 | 60 | public static void copyDirectory(Path source, Path destination) throws IOException { 61 | Files.walkFileTree(source, new FileVisitor() { 62 | @Override 63 | public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes _attrs) throws IOException { 64 | Files.createDirectories(destination.resolve(source.relativize(dir))); 65 | return FileVisitResult.CONTINUE; 66 | } 67 | 68 | @Override 69 | public FileVisitResult visitFile(Path file, BasicFileAttributes _attrs) throws IOException { 70 | Files.copy(file, destination.resolve(source.relativize(file)), StandardCopyOption.REPLACE_EXISTING); 71 | return FileVisitResult.CONTINUE; 72 | } 73 | 74 | @Override 75 | public FileVisitResult visitFileFailed(Path _file, IOException exc) throws IOException { 76 | throw new IOException("Failed to copy file", exc); 77 | } 78 | 79 | @Override 80 | public FileVisitResult postVisitDirectory(Path _dir, IOException exc) throws IOException { 81 | if (Optional.ofNullable(exc).isPresent()) { 82 | throw new UncheckedIOException("Failed to copy directory", exc); 83 | } 84 | return FileVisitResult.CONTINUE; 85 | } 86 | }); 87 | } 88 | 89 | public static void createDirectories(Path directoryPath) { 90 | try { 91 | Files.createDirectories(directoryPath); 92 | } catch (IOException e) { 93 | throw new UncheckedIOException(String.format("Could not create directory %s", directoryPath), e); 94 | } 95 | } 96 | 97 | private FileUtils() {} 98 | } 99 | -------------------------------------------------------------------------------- /gradle-jdks/src/test/groovy/com/palantir/gradle/jdks/GradleJdkIntegrationSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks 18 | 19 | import com.palantir.gradle.jdks.setup.common.CommandRunner 20 | import com.palantir.gradle.plugintesting.GradleTestVersions 21 | import nebula.test.IntegrationSpec 22 | import org.apache.commons.lang3.tuple.Pair 23 | 24 | import java.nio.file.Path 25 | 26 | abstract class GradleJdkIntegrationSpec extends IntegrationSpec { 27 | 28 | static final List GRADLE_TEST_VERSIONS = GradleTestVersions.getGradleVersionsForTests() 29 | 30 | abstract Path workingDir(); 31 | 32 | def setupJdksHardcodedVersions() { 33 | GradleJdkTestUtils.setupJdksHardcodedVersions(settingsFile, buildFile) 34 | } 35 | 36 | def setupJdksHardcodedVersions(String daemonTarget) { 37 | GradleJdkTestUtils.setupJdksHardcodedVersions(settingsFile, buildFile, daemonTarget) 38 | } 39 | 40 | def applyApplicationPlugin() { 41 | GradleJdkTestUtils.applyApplicationPlugin(buildFile) 42 | } 43 | 44 | def applyBaselineJavaVersions() { 45 | GradleJdkTestUtils.applyBaselineJavaVersions(buildFile) 46 | } 47 | 48 | def applyJdksPlugins() { 49 | GradleJdkTestUtils.applyJdksPlugins(settingsFile, buildFile) 50 | } 51 | 52 | String runGradlewTasksSuccessfully(String... tasks) { 53 | String output = runGradlewTasks(tasks) 54 | assert output.contains("BUILD SUCCESSFUL") 55 | return output 56 | } 57 | 58 | String runGradlewTasksWithFailure(String... tasks) { 59 | String output = runGradlewTasks(tasks) 60 | assert output.contains("BUILD FAILED") 61 | return output 62 | } 63 | 64 | private String runGradlewTasks(String... tasks) { 65 | ProcessBuilder processBuilder = getProcessBuilder(tasks) 66 | Process process = processBuilder.start() 67 | String output = CommandRunner.readAllInput(process.getInputStream()) 68 | return output 69 | } 70 | 71 | private ProcessBuilder getProcessBuilder(String... tasks) { 72 | List arguments = ["./gradlew"] 73 | Arrays.asList(tasks).forEach(arguments::add) 74 | ProcessBuilder processBuilder = new ProcessBuilder() 75 | .command(arguments) 76 | .directory(projectDir).redirectErrorStream(true) 77 | processBuilder.environment().put("GRADLE_USER_HOME", workingDir().toAbsolutePath().toString()) 78 | return processBuilder 79 | } 80 | 81 | private static final int BYTECODE_IDENTIFIER = (int) 0xCAFEBABE 82 | 83 | // See http://illegalargumentexception.blogspot.com/2009/07/java-finding-class-versions.html 84 | static Pair readBytecodeVersion(File file) { 85 | try (InputStream stream = new FileInputStream(file) 86 | DataInputStream dis = new DataInputStream(stream)) { 87 | int magic = dis.readInt() 88 | if (magic != BYTECODE_IDENTIFIER) { 89 | throw new IllegalArgumentException("File " + file + " does not appear to be java bytecode") 90 | } 91 | int minorBytecodeVersion = dis.readUnsignedShort() 92 | int majorBytecodeVersion = dis.readUnsignedShort() 93 | return Pair.of(minorBytecodeVersion, majorBytecodeVersion) 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /gradle-jdks/src/test/groovy/com/palantir/gradle/jdks/PalantirCaPluginIntegrationSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks 18 | 19 | import com.palantir.gradle.plugintesting.GradleTestVersions 20 | import nebula.test.IntegrationSpec 21 | import nebula.test.functional.ExecutionResult 22 | import spock.lang.Unroll 23 | 24 | @Unroll 25 | class PalantirCaPluginIntegrationSpec extends IntegrationSpec { 26 | 27 | def '#gradleVersionNumber: can add ca certs to a JDK'() { 28 | gradleVersion = gradleVersionNumber 29 | // language=gradle 30 | buildFile << ''' 31 | // Can't do strict as open source CI does not have the Palantir CA 32 | apply plugin: 'com.palantir.jdks.palantir-ca' 33 | 34 | jdks { 35 | jdk(11) { 36 | distribution = 'azul-zulu' 37 | jdkVersion = '11.54.25-11.0.14.1' 38 | } 39 | 40 | jdkStorageLocation = layout.buildDirectory.dir('jdks') 41 | } 42 | 43 | javaVersions { 44 | libraryTarget = 11 45 | } 46 | 47 | apply plugin: 'java-library' 48 | 49 | task printCaTruststoreAliases(type: JavaExec) { 50 | classpath = sourceSets.main.runtimeClasspath 51 | mainClass = 'foo.OutputCaCerts' 52 | logging.captureStandardOutput LogLevel.LIFECYCLE 53 | logging.captureStandardError LogLevel.LIFECYCLE 54 | } 55 | '''.stripIndent(true) 56 | 57 | // language=java 58 | writeJavaSourceFile ''' 59 | package foo; 60 | 61 | import java.io.File; 62 | import java.security.KeyStore; 63 | import java.security.cert.X509Certificate; 64 | 65 | public final class OutputCaCerts { 66 | public static void main(String... args) throws Exception { 67 | KeyStore keyStore = KeyStore.getInstance( 68 | new File(System.getProperty("java.home"), "lib/security/cacerts"), 69 | "changeit".toCharArray()); 70 | X509Certificate palantirCert = ((X509Certificate) keyStore.getCertificate("Palantir3rdGenRootCa")); 71 | 72 | if (palantirCert != null) { 73 | System.out.println(palantirCert.getSerialNumber()); 74 | } 75 | } 76 | } 77 | '''.stripIndent(true) 78 | 79 | when: 80 | 81 | def stdout = runTasksSuccessfully('printCaTruststoreAliases').standardOutput 82 | 83 | def palantir3rdGenCaSerial = '18126334688741185161' 84 | 85 | then: 86 | // Open source CI does not have the Palantir CA 87 | if (System.getenv("CI") == null) { 88 | assert stdout.contains(palantir3rdGenCaSerial) 89 | } 90 | 91 | where: 92 | gradleVersionNumber << GradleTestVersions.getGradleVersionsForTests() 93 | } 94 | 95 | @Override 96 | ExecutionResult runTasksSuccessfully(String... tasks) { 97 | def result = super.runTasks(tasks) 98 | 99 | if (result.failure) { 100 | println result.standardOutput 101 | println result.standardError 102 | result.rethrowFailure() 103 | } 104 | 105 | return result 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /gradle-jdks/src/test/groovy/com/palantir/gradle/jdks/AzulZuluJdkDistributionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import com.palantir.gradle.jdks.AzulZuluJdkDistribution.ZuluVersionSplit; 22 | import com.palantir.gradle.jdks.JdkPath.Extension; 23 | import com.palantir.gradle.jdks.setup.common.Arch; 24 | import com.palantir.platform.OperatingSystem; 25 | import org.junit.jupiter.api.Test; 26 | 27 | class AzulZuluJdkDistributionTest { 28 | @Test 29 | void zulu_version_combination_survives_roundtrip() { 30 | ZuluVersionSplit versionSplit = AzulZuluJdkDistribution.splitCombinedVersion( 31 | ZuluVersionUtils.combineZuluVersions("11.22.33", "11.0.1")); 32 | assertThat(versionSplit.javaVersion()).isEqualTo("11.0.1"); 33 | assertThat(versionSplit.zuluVersion()).isEqualTo("11.22.33"); 34 | } 35 | 36 | @Test 37 | void zulu_version_combination_supports_bundle_flags() { 38 | ZuluVersionSplit versionSplit = AzulZuluJdkDistribution.splitCombinedVersion( 39 | ZuluVersionUtils.combineZuluVersions("19.0.21-cp1-ea", "19.0.0-ea.6")); 40 | assertThat(versionSplit.zuluVersion()).isEqualTo("19.0.21-cp1-ea"); 41 | assertThat(versionSplit.javaVersion()).isEqualTo("19.0.0-ea.6"); 42 | } 43 | 44 | @Test 45 | void jdk_path_linux_x86_64() { 46 | AzulZuluJdkDistribution distribution = new AzulZuluJdkDistribution(); 47 | String version = ZuluVersionUtils.combineZuluVersions("11.56.19", "11.0.15"); 48 | JdkPath path = distribution.path(JdkRelease.builder() 49 | .arch(Arch.X86_64) 50 | .os(OperatingSystem.LINUX_GLIBC) 51 | .version(version) 52 | .build()); 53 | assertThat(path.filename()).isEqualTo("zulu11.56.19-ca-jdk11.0.15-linux_x64"); 54 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 55 | } 56 | 57 | @Test 58 | void jdk_path_linux_x86_64_early_access() { 59 | AzulZuluJdkDistribution distribution = new AzulZuluJdkDistribution(); 60 | String version = ZuluVersionUtils.combineZuluVersions("19.0.21-ea", "19.0.0-ea.6"); 61 | JdkPath path = distribution.path(JdkRelease.builder() 62 | .arch(Arch.X86_64) 63 | .os(OperatingSystem.LINUX_GLIBC) 64 | .version(version) 65 | .build()); 66 | assertThat(path.filename()).isEqualTo("zulu19.0.21-ea-jdk19.0.0-ea.6-linux_x64"); 67 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 68 | } 69 | 70 | @Test 71 | void jdk_path_macosx() { 72 | AzulZuluJdkDistribution distribution = new AzulZuluJdkDistribution(); 73 | String version = ZuluVersionUtils.combineZuluVersions("19.0.21", "19.0.0.6"); 74 | JdkPath path = distribution.path(JdkRelease.builder() 75 | .arch(Arch.AARCH64) 76 | .os(OperatingSystem.MACOS) 77 | .version(version) 78 | .build()); 79 | assertThat(path.extension()).isEqualTo(Extension.ZIP); 80 | } 81 | 82 | @Test 83 | void jdk_path_musl_linux_x64_64() { 84 | AzulZuluJdkDistribution distribution = new AzulZuluJdkDistribution(); 85 | String version = ZuluVersionUtils.combineZuluVersions("11.56.19", "11.0.15"); 86 | JdkPath path = distribution.path(JdkRelease.builder() 87 | .arch(Arch.X86_64) 88 | .os(OperatingSystem.LINUX_MUSL) 89 | .version(version) 90 | .build()); 91 | assertThat(path.filename()).isEqualTo("zulu11.56.19-ca-jdk11.0.15-linux_musl_x64"); 92 | assertThat(path.extension()).isEqualTo(Extension.TARGZ); 93 | } 94 | 95 | @Test 96 | void jdk_path_windows_x86_64() { 97 | AzulZuluJdkDistribution distribution = new AzulZuluJdkDistribution(); 98 | String version = ZuluVersionUtils.combineZuluVersions("11.56.19", "11.0.15"); 99 | JdkPath path = distribution.path(JdkRelease.builder() 100 | .arch(Arch.X86_64) 101 | .os(OperatingSystem.WINDOWS) 102 | .version(version) 103 | .build()); 104 | assertThat(path.filename()).isEqualTo("zulu11.56.19-ca-jdk11.0.15-win_x64"); 105 | assertThat(path.extension()).isEqualTo(Extension.ZIP); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /gradle-jdks-settings/src/test/groovy/com/palantir/gradle/jdks/settings/ToolchainJdksSettingsPluginTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.palantir.gradle.jdks.settings 17 | 18 | import com.palantir.gradle.jdks.GradleJdkTestUtils 19 | import com.palantir.gradle.jdks.setup.common.CurrentArch 20 | import com.palantir.platform.OperatingSystem 21 | import nebula.test.IntegrationSpec 22 | import nebula.test.functional.ExecutionResult 23 | 24 | import java.nio.file.Files 25 | import java.nio.file.Path 26 | 27 | class ToolchainJdksSettingsPluginTest extends IntegrationSpec { 28 | 29 | private final Path USER_HOME_PATH = Path.of(System.getProperty("user.home")) 30 | 31 | def '#gradleVersionNumber: non-existing jdks are installed by the settings plugin'() { 32 | setup: 33 | gradleVersion = gradleVersionNumber 34 | Files.createDirectories(USER_HOME_PATH) 35 | GradleJdkTestUtils.applyJdksPlugins(settingsFile, buildFile) 36 | 37 | // language=groovy 38 | buildFile << """ 39 | jdks { 40 | jdk(17) { 41 | distribution = JDK_17_DISTRO 42 | jdkVersion = JDK_17_VERSION 43 | } 44 | 45 | daemonTarget = '17' 46 | } 47 | """.replace("JDK_17_DISTRO", GradleJdkTestUtils.quoted(GradleJdkTestUtils.JDK_17.getLeft())) 48 | .replace("JDK_17_VERSION", GradleJdkTestUtils.quoted(GradleJdkTestUtils.JDK_17.getRight())) 49 | .stripIndent(true) 50 | 51 | when: 52 | file('gradle.properties') << 'palantir.jdk.setup.enabled=true' 53 | runTasksSuccessfully("generateGradleJdkConfigs") 54 | 55 | then: 'only gradle configuration files are generated, no jdks are installed' 56 | String os = OperatingSystem.get().uiName() 57 | String arch = CurrentArch.get().uiName() 58 | Path jdk17LocalPath = projectDir.toPath().resolve("gradle/jdks/17/${os}/${arch}/local-path") 59 | String originalJdk17LocalPath = jdk17LocalPath.text.trim() 60 | Path originalJdkPath = Path.of(System.getProperty("user.home")).resolve(".gradle/gradle-jdks") 61 | .resolve(originalJdk17LocalPath).toAbsolutePath() 62 | !Files.exists(originalJdkPath) 63 | 64 | when: 'trigger a task' 65 | jdk17LocalPath.text = "amazon-corretto-${gradleVersion}-test1\n" 66 | ExecutionResult executionResult = runTasksSuccessfully("javaToolchains") 67 | 68 | then: 'the jdks are installed by the settings plugin' 69 | executionResult.standardError.contains("Gradle JDK setup is enabled (palantir.jdk.setup.enabled is true)" + 70 | " but some jdks were not installed") 71 | executionResult.standardOutput.contains("Auto-detection: Disabled") 72 | executionResult.standardOutput.contains("Auto-download: Disabled") 73 | executionResult.standardOutput.contains("JDK ${GradleJdkTestUtils.SIMPLIFIED_JDK_17_VERSION}") 74 | Path expectedJdkPath = USER_HOME_PATH.resolve(".gradle/gradle-jdks") 75 | .resolve("amazon-corretto-${gradleVersion}-test1").toAbsolutePath() 76 | Files.exists(expectedJdkPath) 77 | 78 | when: 'if the jdk configured path is changed' 79 | jdk17LocalPath.text = "amazon-corretto-${gradleVersion}-test2\n" 80 | ExecutionResult resultAfterJdkChange = runTasksSuccessfully("javaToolchains") 81 | 82 | then: 83 | resultAfterJdkChange.standardError.contains("Gradle JDK setup is enabled (palantir.jdk.setup.enabled is true)" + 84 | " but some jdks were not installed") 85 | Path newInstalledJdkPath = USER_HOME_PATH.resolve(".gradle/gradle-jdks") 86 | .resolve("amazon-corretto-${gradleVersion}-test2").toAbsolutePath() 87 | Files.exists(newInstalledJdkPath) 88 | 89 | cleanup: 90 | Files.walk(expectedJdkPath) 91 | .sorted(Comparator.reverseOrder()) 92 | .forEach(Files::delete) 93 | 94 | Files.walk(newInstalledJdkPath) 95 | .sorted(Comparator.reverseOrder()) 96 | .forEach(Files::delete) 97 | 98 | where: 99 | // testing for the different gradle versions to make sure the reflection in the settings plugin works 100 | gradleVersionNumber << [ 101 | GradleJdkTestUtils.GRADLE_7_6_4_VERSION, 102 | GradleJdkTestUtils.GRADLE_8_5_VERSION, 103 | GradleJdkTestUtils.GRADLE_8_8_VERSION 104 | ] 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/BaselineJavaJdksPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.baseline.plugins.javaversions.BaselineJavaVersions; 20 | import com.palantir.baseline.plugins.javaversions.BaselineJavaVersionsExtension; 21 | import com.palantir.gradle.jdks.enablement.GradleJdksEnablement; 22 | import com.palantir.gradle.jdks.setup.common.Arch; 23 | import com.palantir.gradle.jdks.setup.common.CurrentArch; 24 | import com.palantir.platform.GradleOperatingSystem; 25 | import com.palantir.platform.OperatingSystem; 26 | import java.util.Optional; 27 | import org.gradle.api.Plugin; 28 | import org.gradle.api.Project; 29 | import org.gradle.api.file.Directory; 30 | import org.gradle.api.provider.Provider; 31 | import org.gradle.api.tasks.Nested; 32 | import org.gradle.jvm.toolchain.JavaInstallationMetadata; 33 | import org.gradle.jvm.toolchain.JavaLanguageVersion; 34 | 35 | public abstract class BaselineJavaJdksPlugin implements Plugin { 36 | 37 | @Nested 38 | protected abstract GradleOperatingSystem getOperatingSystem(); 39 | 40 | @Override 41 | public final void apply(Project rootProject) { 42 | OperatingSystem os = getOperatingSystem().getOperatingSystem().get(); 43 | if (GradleJdksEnablement.isGradleJdkSetupEnabled( 44 | os, rootProject.getProjectDir().toPath())) { 45 | throw new RuntimeException("Cannot apply BaselineJavaJdksPlugin with palantir.jdk.setup.enabled"); 46 | } 47 | 48 | rootProject.getPluginManager().apply(BaselineJavaVersions.class); 49 | 50 | JdkDistributions jdkDistributions = new JdkDistributions(); 51 | 52 | JdksExtension jdksExtension = JdksPlugin.extension(rootProject, jdkDistributions); 53 | JdkManager jdkManager = new JdkManager( 54 | jdksExtension.getJdkStorageLocation(), jdkDistributions, new JdkDownloaders(jdksExtension), os); 55 | 56 | rootProject 57 | .getExtensions() 58 | .getByType(BaselineJavaVersionsExtension.class) 59 | .jdks((javaLanguageVersion, project) -> { 60 | JdkExtension jdkExtension = jdksExtension 61 | .jdkFor(javaLanguageVersion, project) 62 | .orElseThrow(() -> new RuntimeException(String.format( 63 | "Could not find a JDK with major version %s in project '%s'. " 64 | + "Please ensure that you have configured JDKs properly for " 65 | + "gradle-jdks as per the readme: " 66 | + "https://github.com/palantir/gradle-jdks#usage", 67 | javaLanguageVersion.toString(), project.getPath()))); 68 | 69 | return Optional.of(javaInstallationForLanguageVersion( 70 | project, jdksExtension, jdkExtension, jdkManager, javaLanguageVersion, os)); 71 | }); 72 | } 73 | 74 | private JavaInstallationMetadata javaInstallationForLanguageVersion( 75 | Project project, 76 | JdksExtension jdksExtension, 77 | JdkExtension jdkExtension, 78 | JdkManager jdkManager, 79 | JavaLanguageVersion javaLanguageVersion, 80 | OperatingSystem os) { 81 | 82 | Arch currentArch = CurrentArch.get(); 83 | 84 | String version = 85 | jdkExtension.jdkFor(os).jdkFor(currentArch).getJdkVersion().get(); 86 | 87 | JdkDistributionName jdkDistributionName = 88 | jdkExtension.getDistributionName().get(); 89 | 90 | Provider installationPath = project.getLayout().dir(project.provider(() -> jdkManager 91 | .jdk( 92 | project, 93 | JdkSpec.builder() 94 | .distributionName(jdkDistributionName) 95 | .release(JdkRelease.builder() 96 | .version(version) 97 | .os(os) 98 | .arch(currentArch) 99 | .build()) 100 | .caCerts(CaCerts.from(jdksExtension.getCaCerts().get())) 101 | .build()) 102 | .toFile())); 103 | 104 | return GradleJdksJavaInstallationMetadata.create( 105 | javaLanguageVersion, version, version, jdkDistributionName.uiName(), installationPath); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/CheckGradleJdksConfigsTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion; 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.io.UncheckedIOException; 24 | import java.nio.charset.StandardCharsets; 25 | import java.nio.file.Files; 26 | import java.nio.file.Path; 27 | import java.util.Arrays; 28 | import java.util.List; 29 | import org.gradle.api.file.Directory; 30 | import org.gradle.api.file.DirectoryProperty; 31 | import org.gradle.api.file.RegularFileProperty; 32 | import org.gradle.api.tasks.InputDirectory; 33 | import org.gradle.api.tasks.OutputFile; 34 | 35 | public abstract class CheckGradleJdksConfigsTask extends GradleJdksConfigs { 36 | 37 | @InputDirectory 38 | public abstract DirectoryProperty getInputGradleDirectory(); 39 | 40 | @OutputFile 41 | public abstract RegularFileProperty getDummyOutputFile(); 42 | 43 | @Override 44 | protected final Directory gradleDirectory() { 45 | return getInputGradleDirectory().get(); 46 | } 47 | 48 | @Override 49 | protected void maybePrepareForAction(List targetPaths) {} 50 | 51 | @Override 52 | protected final void applyGradleJdkFileAction( 53 | Path downloadUrlPath, Path localUrlPath, JdkDistributionConfig jdkDistribution) { 54 | assertFileContent(downloadUrlPath, jdkDistribution.getDownloadUrl().get()); 55 | assertFileContent(localUrlPath, jdkDistribution.getLocalPath().get()); 56 | } 57 | 58 | @Override 59 | protected final void applyGradleJdkDaemonVersionAction(Path gradleJdkDaemonVersion) { 60 | assertFileContent(gradleJdkDaemonVersion, getDaemonJavaVersion().get().toString()); 61 | } 62 | 63 | @Override 64 | protected final void applyGradleJdkJarAction(File gradleJdkJarFile, String resourceName) { 65 | try { 66 | byte[] expectedBytes = getResourceContent(resourceName); 67 | byte[] actualBytes = Files.readAllBytes(gradleJdkJarFile.toPath()); 68 | checkOrThrow(Arrays.equals(expectedBytes, actualBytes), gradleJdkJarFile.toPath()); 69 | } catch (IOException e) { 70 | throw new UncheckedIOException("An error occurred while checking the gradle jdk setup jar", e); 71 | } 72 | } 73 | 74 | @Override 75 | protected final void applyGradleJdkScriptAction(File gradleJdkScriptFile, String resourceName) { 76 | assertFileContent( 77 | gradleJdkScriptFile.toPath(), new String(getResourceContent(resourceName), StandardCharsets.UTF_8)); 78 | } 79 | 80 | private static void assertFileContent(Path filePath, String expectedContent) { 81 | checkOrThrow( 82 | filePath.toFile().exists() && readConfigurationFile(filePath).equals(expectedContent.trim()), filePath); 83 | } 84 | 85 | private static String readConfigurationFile(Path filePath) { 86 | try { 87 | return Files.readString(filePath).trim(); 88 | } catch (IOException e) { 89 | throw new UncheckedIOException(String.format("Unable to read file %s", filePath), e); 90 | } 91 | } 92 | 93 | private static void checkOrThrow(boolean result, Path outOfDateFile) { 94 | if (!result) { 95 | throw new ExceptionWithSuggestion( 96 | String.format( 97 | "Gradle JDK configuration file `%s` is out of date, please run `./gradlew setupJdks`", 98 | getRelativeToGradleFile(outOfDateFile)), 99 | "./gradlew setupJdks"); 100 | } 101 | } 102 | 103 | private static String getRelativeToGradleFile(Path file) { 104 | Path gradlePath = file; 105 | while (gradlePath != null && !gradlePath.getFileName().toString().equals("gradle")) { 106 | gradlePath = gradlePath.getParent(); 107 | } 108 | return gradlePath != null ? gradlePath.getParent().relativize(file).toString() : file.toString(); 109 | } 110 | 111 | public static byte[] getResourceContent(String resource) { 112 | try (InputStream inputStream = 113 | GenerateGradleJdksConfigsTask.class.getClassLoader().getResourceAsStream(resource)) { 114 | if (inputStream == null) { 115 | throw new RuntimeException(String.format("Resource not found: %s:", resource)); 116 | } 117 | return inputStream.readAllBytes(); 118 | } catch (IOException e) { 119 | throw new UncheckedIOException(String.format("Failed to retrieve resource %s", resource), e); 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /gradle-jdks/src/main/java/com/palantir/gradle/jdks/AzulZuluJdkDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) Copyright 2022 Palantir Technologies Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.palantir.gradle.jdks; 18 | 19 | import com.google.common.collect.ImmutableSet; 20 | import com.palantir.gradle.jdks.JdkPath.Extension; 21 | import com.palantir.gradle.jdks.setup.common.Arch; 22 | import com.palantir.platform.OperatingSystem; 23 | import java.util.Arrays; 24 | import java.util.List; 25 | import org.immutables.value.Value; 26 | 27 | final class AzulZuluJdkDistribution implements JdkDistribution { 28 | // See https://docs.azul.com/core/zulu-openjdk/versioning-and-naming for flag details. 29 | private static final ImmutableSet BUNDLE_FLAGS = 30 | ImmutableSet.of("embvm", "cp1", "cp2", "cp3", "c2", "criu", "cr", "crac"); 31 | /** 32 | * According to the Zulu version documentation, the -ea bundle flag is separate from the license availability flag. 33 | * Empirically release contain one, or the other. 34 | */ 35 | private static final ImmutableSet AVAILABILITY_FLAGS = ImmutableSet.of("ea", "ca", "sa"); 36 | 37 | private static final ImmutableSet ALL_FLAGS = ImmutableSet.builder() 38 | .addAll(BUNDLE_FLAGS) 39 | .addAll(AVAILABILITY_FLAGS) 40 | .build(); 41 | 42 | @Override 43 | public String defaultBaseUrl() { 44 | return "https://cdn.azul.com/zulu/bin"; 45 | } 46 | 47 | @Override 48 | public JdkPath path(JdkRelease jdkRelease) { 49 | ZuluVersionSplit zuluVersionSplit = splitCombinedVersion(jdkRelease.version()); 50 | 51 | String filename = String.format( 52 | "zulu%s-jdk%s-%s_%s", 53 | maybeAddAvailabilitySuffix(zuluVersionSplit.zuluVersion()), 54 | zuluVersionSplit.javaVersion(), 55 | os(jdkRelease.os()), 56 | arch(jdkRelease.arch())); 57 | 58 | return JdkPath.builder() 59 | .filename(filename) 60 | .extension(extension(jdkRelease.os())) 61 | .build(); 62 | } 63 | 64 | /** 65 | * In general, we prefer to use the community availability release of Zulu. If the user specifies a subscriber 66 | * release or early access release flag, we will attempt to download that. 67 | */ 68 | private static String maybeAddAvailabilitySuffix(String zuluVersion) { 69 | if (AVAILABILITY_FLAGS.stream().map(flag -> "-" + flag).anyMatch(zuluVersion::contains)) { 70 | return zuluVersion; 71 | } else { 72 | return zuluVersion + "-ca"; 73 | } 74 | } 75 | 76 | private static String os(OperatingSystem os) { 77 | return switch (os) { 78 | case MACOS -> "macosx"; 79 | case LINUX_GLIBC -> "linux"; 80 | case LINUX_MUSL -> "linux_musl"; 81 | case WINDOWS -> "win"; 82 | }; 83 | } 84 | 85 | private static String arch(Arch arch) { 86 | return switch (arch) { 87 | case X86 -> "i686"; 88 | case X86_64 -> "x64"; 89 | case AARCH64 -> "aarch64"; 90 | }; 91 | } 92 | 93 | private static Extension extension(OperatingSystem operatingSystem) { 94 | return switch (operatingSystem) { 95 | case LINUX_GLIBC, LINUX_MUSL -> Extension.TARGZ; 96 | case MACOS, WINDOWS -> Extension.ZIP; 97 | }; 98 | } 99 | 100 | static ZuluVersionSplit splitCombinedVersion(String combinedVersion) { 101 | List split = Arrays.asList(combinedVersion.split("-", -1)); 102 | 103 | if (split.size() < 2) { 104 | throw new IllegalArgumentException(String.format( 105 | "Expected %s to split into at least two parts, split into %d", combinedVersion, split.size())); 106 | } 107 | 108 | int endOfFlags = 1; 109 | while (endOfFlags < split.size() && ALL_FLAGS.contains(split.get(endOfFlags))) { 110 | endOfFlags++; 111 | } 112 | 113 | if (endOfFlags == split.size()) { 114 | throw new IllegalArgumentException( 115 | String.format("Expected %s to split into two versions, split into one.", combinedVersion)); 116 | } 117 | 118 | return ZuluVersionSplit.builder() 119 | .zuluVersion(String.join("-", split.subList(0, endOfFlags))) 120 | .javaVersion(String.join("-", split.subList(endOfFlags, split.size()))) 121 | .build(); 122 | } 123 | 124 | @Value.Immutable 125 | interface ZuluVersionSplit { 126 | String zuluVersion(); 127 | 128 | String javaVersion(); 129 | 130 | class Builder extends ImmutableZuluVersionSplit.Builder {} 131 | 132 | static Builder builder() { 133 | return new Builder(); 134 | } 135 | } 136 | } 137 | --------------------------------------------------------------------------------