Skip to content

Commit

Permalink
build: merged migration to java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
ennioVisco committed Nov 29, 2023
2 parents 3855e84 + bbabfed commit 063753d
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 73 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: adopt
cache: gradle
- name: build with Gradle
run: ./gradlew --no-daemon build
Expand All @@ -37,11 +39,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: adopt
cache: gradle
- name: Restore build cache
uses: actions/cache/restore@v3
Expand All @@ -54,7 +56,7 @@ jobs:
uses: actions/cache/save@v3
with:
path: ./build
key: ${{ github.sha }}-${{ github.workflow_id }}-${{ runner.os }}-tests
key: ${{ github.sha }}-${{ github.workflow_id }}-${{ runner.os }}

analyze:
name: Static code analysis
Expand All @@ -64,18 +66,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
fetch-depth: 0 # Shallow clones
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: adopt
cache: gradle
- name: Restore tests cache
uses: actions/cache/restore@v3
with:
path: ./build
key: ${{ github.sha }}-${{ github.workflow_id }}-${{ runner.os }}-tests
key: ${{ github.sha }}-${{ github.workflow_id }}-${{ runner.os }}

- name: Cache SonarCloud packages
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt
cache: gradle
- name: Build documentation
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt
cache: gradle
- name: Run gradle publish
Expand Down Expand Up @@ -77,11 +77,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: adopt
cache: gradle

- name: Find and Replace
Expand Down
2 changes: 1 addition & 1 deletion build-logic/code-info/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// regardless of the specific projects and languages
plugins {
`kotlin-dsl` // To compile the plugin code
id("org.sonarqube") version "4.3.0.3225"
id("org.sonarqube") version "4.4.1.3373"
}

dependencies {
Expand Down
6 changes: 3 additions & 3 deletions build-logic/generate-docs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

dependencies {
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.20")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
dokkaPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.8.20")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.10")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21")
dokkaPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.9.10")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
}

dependencies {
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.20")
dokkaPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.8.20")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.10")
dokkaPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.9.10")
}

tasks.register("docs") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,15 @@ description = "MoonLight: a light-weight framework for runtime monitoring"

// == General Java settings ==
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
// withJavadocJar()
// withSourcesJar()
}

tasks.withType<JavaCompile> {
// Needed by pattern matching on switches:
options.compilerArgs.add("--enable-preview")
}

tasks.withType<Javadoc> {
// Needed by pattern matching on switches:
val javadocOptions = options as CoreJavadocOptions
javadocOptions.addStringOption("source", "17")
javadocOptions.addBooleanOption("-enable-preview", true)
}

tasks {
// to allow UTF-8 characters in comments
compileJava { options.encoding = "UTF-8" }
Expand All @@ -41,8 +32,6 @@ dependencies {

tasks.test {
useJUnitPlatform()
// Needed by pattern matching on switches:
jvmArgs("--enable-preview")
}


Expand All @@ -52,9 +41,9 @@ tasks.jacocoTestReport.configure {
}

tasks.register<Copy>("copyDependencies") {
from(configurations.runtimeClasspath).into("$buildDir/jmods")
from(configurations.runtimeClasspath).into(layout.buildDirectory.dir("jmods"))
}

tasks.register<Copy>("copyJar") {
from(tasks.jar).into("$buildDir/jmods")
from(tasks.jar).into(layout.buildDirectory.dir("jmods"))
}
6 changes: 4 additions & 2 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pluginManagement {
}

plugins {
kotlin("jvm") version "1.9.0" apply false // for compiling the docs
id("org.jetbrains.dokka") version "1.8.20" apply false
kotlin("jvm") version "1.9.21" apply false // for compiling the docs
id("org.jetbrains.dokka") version "1.9.10" apply false
}
}

Expand All @@ -25,6 +25,8 @@ dependencyResolutionManagement {
// Required to remove annoying warning in subprojects
plugins {
`kotlin-dsl` apply false

kotlin("jvm") version "1.9.20-RC2" apply false // TODO: remove when 1.9.20 is released
}

// We aggregate all the build logic in a single project
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ fun Copy.copyModulesUpwards() {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
subprojects.filter { it.name in listOf("engine", "script") }.forEach { project ->
dependsOn(":${project.name}:$name")
from("${project.buildDir}/jmods")
into("$buildDir/jmods")
from(project.layout.buildDirectory.dir("jmods"))
into(layout.buildDirectory.dir("jmods"))
}
}

Expand Down
18 changes: 11 additions & 7 deletions console/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ application {

fun copyAuxiliaryFiles(source: String, destination: String) {
copy {
from("$buildDir/resources/main/$source")
into(rootProject.file("$rootDir/release/$destination"))
from(layout.buildDirectory.file("resources/main/$source"))
into(rootProject.layout.buildDirectory.file("$rootDir/release/$destination"))
}
}

fun copyFromTo(source: String, destination: String) =
fun copyFromTo(source: Provider<Directory>, destination: Provider<Directory>) =
copy {
println("Copying: ${file(source).listFiles()?.map{ it.name }} to $destination")
from(file(source))
Expand All @@ -34,8 +34,11 @@ tasks.register("distribution") {
dependsOn("installDist")

doLast {
copyFromTo("$buildDir/libs/", "$rootDir/distribution_files/matlab/moonlight/jar/")
copyFromTo("$buildDir/libs/", "$rootDir/distribution_files/console/")
val libs = layout.buildDirectory.dir("libs")
val moonlightJar = rootProject.layout.buildDirectory.dir("distribution_files/matlab/moonlight/jar")
val console = rootProject.layout.buildDirectory.dir("distribution_files/console")
copyFromTo(libs, moonlightJar)
copyFromTo(libs, console)
}
}

Expand All @@ -44,8 +47,9 @@ tasks.register("release") {
dependsOn("distribution")

doLast {
val source = rootProject.file("$rootDir/distribution_files/").path
copyFromTo(source, "$rootDir/distribution/")
val distributionFiles = rootProject.layout.buildDirectory.dir("distribution_files")
val distribution = rootProject.layout.buildDirectory.dir("distribution_files")
copyFromTo(distributionFiles, distribution)
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
5 changes: 0 additions & 5 deletions matlab/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ java {
withSourcesJar()
}

tasks.withType<JavaCompile> {
// Needed by pattern matching on switches:
options.compilerArgs.remove("--enable-preview")
}

dependencies {
//implementation fileTree(dir: "lib", include: "engine.jar")
//implementation fileTree(dir: "lib", include: "engine2019.jar")
Expand Down
14 changes: 8 additions & 6 deletions python/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ dependencies {

fun updateExecutableJar() {
copy {
println("From: $buildDir/libs/${project.name}-all.jar")
println("To: $projectDir/src/moonlight/jar")
from("$buildDir/libs/${project.name}-all.jar")
into("$projectDir/src/moonlight/jar")
val buildJar = layout.buildDirectory.file("libs/${project.name}-all.jar")
val projectJarDir = layout.projectDirectory.dir("src/moonlight/jar")
println("From: $buildJar")
println("To: $projectJarDir")
from(buildJar)
into(projectJarDir)
}
}

tasks.create<Delete>("clearArtifacts") {
project.delete("$projectDir/src/moonlight/jar")
project.delete("$buildDir/libs/")
project.delete(layout.projectDirectory.dir("src/moonlight/jar"))
project.delete(layout.buildDirectory.dir("libs"))
project.delete("dist")
}

Expand Down

0 comments on commit 063753d

Please sign in to comment.