diff --git a/.github/workflows/branches-and-prs.main.kts b/.github/workflows/branches-and-prs.main.kts index 95c3f247f5..f7ed18fb39 100755 --- a/.github/workflows/branches-and-prs.main.kts +++ b/.github/workflows/branches-and-prs.main.kts @@ -17,7 +17,10 @@ */ @file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("org.codehaus.groovy:groovy:3.0.15") +import groovy.lang.Binding +import groovy.lang.GroovyShell import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.actions.GithubScriptV6 import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3 @@ -74,8 +77,7 @@ workflow( ) } - val variants = listOf("2.5", "3.0", "4.0") - val javaVersions = listOf("8", "11", "17") + val (javaVersions, variants) = getMatrixAxes() val matrixExcludes = javaVersions .filter { it.toInt() >= 17 } .map { javaVersion -> @@ -168,3 +170,19 @@ data class SetupBuildEnv( override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) } + +fun getMatrixAxes(): Pair, List> { + val binding = object : Binding() { + lateinit var javaVersions: List + lateinit var variants: List + + override fun setVariable(name: String?, value: Any?) { + when (name) { + "javaVersions" -> javaVersions = (value as List).map { it.toString() } + "variants" -> variants = value as List + } + } + } + GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy")) + return binding.javaVersions to binding.variants +} diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts index 47005aaff9..577a605a0e 100755 --- a/.github/workflows/release.main.kts +++ b/.github/workflows/release.main.kts @@ -17,7 +17,10 @@ */ @file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0") +@file:DependsOn("org.codehaus.groovy:groovy:3.0.15") +import groovy.lang.Binding +import groovy.lang.GroovyShell import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 import io.github.typesafegithub.workflows.actions.actions.CheckoutV3.FetchDepth import io.github.typesafegithub.workflows.actions.actions.GithubScriptV6 @@ -52,8 +55,7 @@ workflow( val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets - val variants = listOf("2.5", "3.0", "4.0") - val javaVersions = listOf("8", "11", "17") + val (javaVersions, variants) = getMatrixAxes() val matrixExcludes = javaVersions .filter { it.toInt() >= 17 } .map { javaVersion -> @@ -241,3 +243,19 @@ data class SetupBuildEnv( override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) } + +fun getMatrixAxes(): Pair, List> { + val binding = object : Binding() { + lateinit var javaVersions: List + lateinit var variants: List + + override fun setVariable(name: String?, value: Any?) { + when (name) { + "javaVersions" -> javaVersions = (value as List).map { it.toString() } + "variants" -> variants = value as List + } + } + } + GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy")) + return binding.javaVersions to binding.variants +} diff --git a/build.gradle b/build.gradle index 6100905d26..42f954cbc0 100644 --- a/build.gradle +++ b/build.gradle @@ -13,13 +13,16 @@ plugins { description = "Spock Framework" +ext.javaVersions = null +ext.variants = null +apply from: 'matrix.groovy' +variants = variants.collect { it as BigDecimal } + ext { baseVersion = "2.4" snapshotVersion = true milestone = 0 - javaVersions = [8, 11, 17] // ensure that latest version is actually build on travis, otherwise no docs get published javaVersion = (System.getProperty("javaVersion") ?: 8) as int - variants = [2.5, 3.0, 4.0] variant = System.getProperty("variant") as BigDecimal ?: variants.first() buildScan.tag "groovy-$variant" if (variant == 2.5) { diff --git a/matrix.groovy b/matrix.groovy new file mode 100644 index 0000000000..202bd3dda7 --- /dev/null +++ b/matrix.groovy @@ -0,0 +1,2 @@ +javaVersions = [8, 11, 17] // ensure that latest version is actually built on GitHub Actions, otherwise no docs get published +variants = ['2.5', '3.0', '4.0']