diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64d8b2ef..919a3dbb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a1f8ae4c..9e7a7e99 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 69faceaf..4530d998 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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 diff --git a/build-logic/code-info/build.gradle.kts b/build-logic/code-info/build.gradle.kts index 7c2864e2..6e336a7c 100644 --- a/build-logic/code-info/build.gradle.kts +++ b/build-logic/code-info/build.gradle.kts @@ -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 { diff --git a/build-logic/generate-docs/build.gradle.kts b/build-logic/generate-docs/build.gradle.kts index 159e548d..24babf71 100644 --- a/build-logic/generate-docs/build.gradle.kts +++ b/build-logic/generate-docs/build.gradle.kts @@ -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") } diff --git a/build-logic/generate-docs/src/main/kotlin/io.github.moonlightsuite.generate-docs.gradle.kts b/build-logic/generate-docs/src/main/kotlin/io.github.moonlightsuite.generate-docs.gradle.kts index 339a5355..9d008012 100644 --- a/build-logic/generate-docs/src/main/kotlin/io.github.moonlightsuite.generate-docs.gradle.kts +++ b/build-logic/generate-docs/src/main/kotlin/io.github.moonlightsuite.generate-docs.gradle.kts @@ -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") { diff --git a/build-logic/java-library/src/main/kotlin/io.github.moonlightsuite.java-library.gradle.kts b/build-logic/java-library/src/main/kotlin/io.github.moonlightsuite.java-library.gradle.kts index 25d57def..03908f51 100644 --- a/build-logic/java-library/src/main/kotlin/io.github.moonlightsuite.java-library.gradle.kts +++ b/build-logic/java-library/src/main/kotlin/io.github.moonlightsuite.java-library.gradle.kts @@ -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 { - // Needed by pattern matching on switches: - options.compilerArgs.add("--enable-preview") -} - -tasks.withType { - // 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" } @@ -41,8 +32,6 @@ dependencies { tasks.test { useJUnitPlatform() - // Needed by pattern matching on switches: - jvmArgs("--enable-preview") } @@ -52,9 +41,9 @@ tasks.jacocoTestReport.configure { } tasks.register("copyDependencies") { - from(configurations.runtimeClasspath).into("$buildDir/jmods") + from(configurations.runtimeClasspath).into(layout.buildDirectory.dir("jmods")) } tasks.register("copyJar") { - from(tasks.jar).into("$buildDir/jmods") + from(tasks.jar).into(layout.buildDirectory.dir("jmods")) } diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index 17c0bb09..d5aa219c 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -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 } } @@ -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 diff --git a/build.gradle.kts b/build.gradle.kts index f3ca2db8..000433d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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")) } } diff --git a/console/build.gradle.kts b/console/build.gradle.kts index c6705a93..9cc90baf 100644 --- a/console/build.gradle.kts +++ b/console/build.gradle.kts @@ -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, destination: Provider) = copy { println("Copying: ${file(source).listFiles()?.map{ it.name }} to $destination") from(file(source)) @@ -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) } } @@ -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) } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 033e24c4..7f93135c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9f4197d5..1af9e093 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index fcb6fca1..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -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 @@ -144,7 +145,7 @@ 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 @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | 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 @@ -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" \ diff --git a/matlab/build.gradle.kts b/matlab/build.gradle.kts index b2937aba..4219179d 100644 --- a/matlab/build.gradle.kts +++ b/matlab/build.gradle.kts @@ -11,11 +11,6 @@ java { withSourcesJar() } -tasks.withType { - // 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") diff --git a/python/build.gradle.kts b/python/build.gradle.kts index e74cfa26..9c43ca37 100644 --- a/python/build.gradle.kts +++ b/python/build.gradle.kts @@ -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("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") }