Skip to content

Commit

Permalink
Require JDK17+ for development
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbaker committed Dec 13, 2024
1 parent 1fdb522 commit 1605a3a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Java ${{ matrix.java }} ${{ matrix.os }}
strategy:
matrix:
java: [8, 11, 17, 21]
java: [17, 21]
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
Expand All @@ -33,8 +33,7 @@ jobs:
run: git config --system core.longpaths true

- name: Integration tests
if: matrix.java == 17
run: ./gradlew integ -Plog-tests --stacktrace
run: ./gradlew integ -PresolveImageJre -Plog-tests --stacktrace

- uses: actions/upload-artifact@v4
if: failure()
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Please read through this document before submitting any issues or pull requests
information to effectively respond to your bug report or contribution.


## Building the Project

Building this project **requires having a JDK17+ installation**. However, for the time being, most modules will still
produce artifacts targeting JDK8, unless explicitly noted otherwise.

## Reporting Bugs/Feature Requests

We welcome you to use the GitHub issue tracker to report bugs or suggest features.
Expand Down
13 changes: 8 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ plugins {
val libraryVersion = project.file("VERSION").readText().trim()
println("Smithy version: '$libraryVersion'")

// Verify Java version is 17+
// Since most plugins are not toolchain-aware, we can't rely on gradle toolchains, which means we'll have to enforce
// that the global java version (i.e. whatever JAVA_HOME is set to and what Gradle uses) is set to 17+
val javaVersion = JavaVersion.current()
check(javaVersion.isCompatibleWith(JavaVersion.VERSION_17)) {
"Building this project requires Java 17 or later. You are currently running Java ${javaVersion.majorVersion}."
}

allprojects {
group = "software.amazon.smithy"
version = libraryVersion
Expand All @@ -40,11 +48,6 @@ afterEvaluate {
classpath = files(subprojects.map { project(it.path).sourceSets.main.get().compileClasspath })
(options as StandardJavadocDocletOptions).apply {
addStringOption("Xdoclint:-html", "-quiet")
// Fixed in JDK 12: https://bugs.openjdk.java.net/browse/JDK-8215291
// --no-module-directories does not exist in JDK 8 and is removed in 13
if (JavaVersion.current().run { isJava9 || isJava10 || isJava11 }) {
addBooleanOption("-no-module-directories", true)
}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions smithy-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ description = "This module implements the Smithy command line interface."
extra["displayName"] = "Smithy :: CLI"
extra["moduleName"] = "software.amazon.smithy.cli"

val imageJreVersion = "17"
// If `resolveImageJre` is set, detect the current JVM version and use the same version for generating the runtime
// This is mainly used in CI to generate a valid runtime image for integration tests
val imageJreVersion = if (project.hasProperty("resolveImageJre")) {
JavaVersion.current().majorVersion
} else {
// Otherwise, just use 17
"17"
}
val correttoRoot = "https://corretto.aws/downloads/latest/amazon-corretto-$imageJreVersion"

dependencies {
Expand Down Expand Up @@ -139,13 +146,6 @@ runtime {

// Because we're using target-platforms, it will use this property as a prefix for each target zip
imageZip = layout.buildDirectory.file("image/smithy-cli.zip")

// This is needed to ensure that jlink is available (jlink is Java 9+), we should use the JDK that
// is configured for the runtime
// NOTE: For the runtime task, you *must* have the right JDK set up in your environment (17 at the time of writing)
javaHome = javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(imageJreVersion))
}.map { it.metadata.installationPath.asFile.path }
}

tasks {
Expand Down

0 comments on commit 1605a3a

Please sign in to comment.