Skip to content

Commit

Permalink
Update gradle configuration to use task configuration avoidance
Browse files Browse the repository at this point in the history
Properly use gradle task configuration avoidance.
  • Loading branch information
piazzesiNiccolo-GS authored and JorenHannes committed Jan 13, 2025
1 parent 71ef057 commit afa4d0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 10 additions & 12 deletions base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,25 @@ test {
useJUnitPlatform()
}

task testAllJavaVersions() { testAllTask ->
dependsOn(test) // the usual test runs on Java 8
def testAllJavaVersions = tasks.register("testAllJavaVersions") { dependsOn(test) }

javaVersionsForTest.each {version ->
javaVersionsForTest.each {version ->

task("testJava$version", type: Test) {
def testVersion = tasks.register("testJava$version",Test) {
// The version of bytebuddy used by mockk only supports Java 20 experimentally so far
if (version == 20) systemProperty 'net.bytebuddy.experimental', true

// The version of bytebuddy used by mockk only supports Java 20 experimentally so far
if (version == 20) systemProperty 'net.bytebuddy.experimental', true
useJUnitPlatform()

useJUnitPlatform()

testAllTask.dependsOn(it)

javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(version)
}
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(version)
}
}
testAllJavaVersions.configure { dependsOn(testVersion) }
}


jacocoTestReport {
// Define which classes need to be monitored
def sources = files(sourceSets.main.allSource.srcDirs)
Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'distribution'
Expand Down Expand Up @@ -51,15 +53,15 @@ allprojects {
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs = [
"-opt-in=kotlin.RequiresOptIn"
]
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask.class)
tasks.withType(KotlinCompilationTask.class)
.configureEach {
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_7
}
Expand Down Expand Up @@ -89,7 +91,7 @@ javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}

task buildDocumentation(type: Exec) {
def buildDocumentation = tasks.register("buildDocumentation", Exec) {
dependsOn javadoc
inputs.dir 'docs/md'
inputs.file 'docs/mkdocs.yml'
Expand Down

0 comments on commit afa4d0c

Please sign in to comment.