Skip to content

Commit

Permalink
Build on latest JDK, but run tests on several
Browse files Browse the repository at this point in the history
  • Loading branch information
jrodbx authored and John Rodriguez committed May 20, 2023
1 parent 797b492 commit 1d8f00d
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
windows-latest,
ubuntu-latest
]
java-version: [17, 18]

runs-on: ${{matrix.os}}

Expand All @@ -27,7 +26,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
java-version: 18

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down Expand Up @@ -62,7 +61,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
java-version: 18

- name: Publish Artifacts
run: ./gradlew -p paparazzi publishMavenPublicationToMavenCentralRepository paparazzi-gradle-plugin:publishPluginMavenPublicationToMavenCentralRepository paparazzi-gradle-plugin:publishPaparazziPluginMarkerMavenPublicationToMavenCentralRepository --no-parallel
Expand Down
36 changes: 36 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinCommonPluginWrapper

apply plugin: 'com.github.ben-manes.versions'

project.gradle.settingsEvaluated { settings ->
settings.apply("plugin" to "org.gradle.toolchains.foojay-resolver-convention")
}

buildscript {
repositories {
mavenCentral()
Expand Down Expand Up @@ -48,6 +55,14 @@ subprojects {
}
}

plugins.withType(KotlinCommonPluginWrapper).configureEach {
def kotlinExtension = project.extensions.getByType(KotlinProjectExtension)
kotlinExtension.jvmToolchain {
it.languageVersion.set(JavaLanguageVersion.of(libs.versions.javaTarget.get()))
it.vendor.set(JvmVendorSpec.AZUL)
}
}

apply plugin: 'com.diffplug.spotless'
spotless {
kotlin {
Expand All @@ -63,6 +78,27 @@ subprojects {
])
}
}

// Create a test task for each supported JDK.
[17, 18].each { majorVersion ->
def jdkTest = tasks.register("testJdk$majorVersion", Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(majorVersion)
vendor = JvmVendorSpec.AZUL
}

description = "Runs the test suite on JDK $majorVersion"
group = LifecycleBasePlugin.VERIFICATION_GROUP

// Copy inputs from normal Test task.
def testTask = tasks.getByName("test")
classpath = testTask.classpath
testClassesDirs = testTask.testClassesDirs
}
tasks.named("check").configure {
dependsOn(jdkTest)
}
}
}

tasks.register("clean", Delete).configure {
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.
plugin-ksp = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version = "1.8.21-1.0.11" }
plugin-mavenPublish = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.2" }
plugin-spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.18.0" }
plugin-toolchains = { module = "org.gradle.toolchains:foojay-resolver", version = "0.5.0" }
plugin-versions = { module = "com.github.ben-manes:gradle-versions-plugin", version = "0.46.0" }
39 changes: 39 additions & 0 deletions paparazzi/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinCommonPluginWrapper

apply plugin: 'com.github.ben-manes.versions'

project.gradle.settingsEvaluated { settings ->
settings.apply("plugin" to "org.gradle.toolchains.foojay-resolver-convention")
}

buildscript {
repositories {
mavenCentral()
Expand Down Expand Up @@ -51,6 +58,14 @@ subprojects {
}
}

plugins.withType(KotlinCommonPluginWrapper).configureEach {
def kotlinExtension = project.extensions.getByType(KotlinProjectExtension)
kotlinExtension.jvmToolchain {
it.languageVersion.set(JavaLanguageVersion.of(libs.versions.javaTarget.get()))
it.vendor.set(JvmVendorSpec.AZUL)
}
}

plugins.withId('com.vanniktech.maven.publish') {
publishing {
repositories {
Expand Down Expand Up @@ -99,6 +114,30 @@ subprojects {
])
}
}

// Avoid the native projects in 'libs'
plugins.withId('org.jetbrains.kotlin.jvm') {
// Create a test task for each supported JDK.
[17, 18].each { majorVersion ->
def jdkTest = tasks.register("testJdk$majorVersion", Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(majorVersion)
vendor = JvmVendorSpec.AZUL
}

description = "Runs the test suite on JDK $majorVersion"
group = LifecycleBasePlugin.VERIFICATION_GROUP

// Copy inputs from normal Test task.
def testTask = tasks.getByName("test")
classpath = testTask.classpath
testClassesDirs = testTask.testClassesDirs
}
tasks.named("check").configure {
dependsOn(jdkTest)
}
}
}
}

tasks.register("clean", Delete).configure {
Expand Down

0 comments on commit 1d8f00d

Please sign in to comment.