From a6719aded3901312f96bb189df56fac468c45286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp?= Date: Sun, 3 Dec 2023 11:13:20 +0000 Subject: [PATCH] Use Gradle `plugins { }` instead of `buildscript { }` (#503) --- .github/workflows/ci.yml | 3 +-- README.md | 4 ++-- build.gradle | 26 ++++++++------------------ mockito-kotlin/build.gradle | 6 ++++-- tests/build.gradle | 15 ++++----------- tests/gradle.properties | 3 +++ 6 files changed, 22 insertions(+), 35 deletions(-) create mode 100644 tests/gradle.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 809cad1e..d0398ce0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,9 +67,8 @@ jobs: - name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }} run: | ops/mockMakerInline.sh - ./gradlew build + ./gradlew build -PtestKotlinVersion=${{ matrix.kotlin }} env: - KOTLIN_VERSION: ${{ matrix.kotlin }} MOCK_MAKER: ${{ matrix.mock-maker }} # diff --git a/README.md b/README.md index 32678c7a..c777ba1a 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ keeping the base module at a recent version. Usually it is enough to test only using the default Kotlin versions; CI will test against multiple versions. -If you want to test using a different Kotlin version locally, set -an environment variable `KOTLIN_VERSION` and run the tests. +If you want to test using a different Kotlin version locally, +add the `-PtestKotlinVersion=1.2.3` argument to the Gradle invocation while running the tests. ### Acknowledgements diff --git a/build.gradle b/build.gradle index 14320510..333afb7e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,23 +1,13 @@ -buildscript { - repositories { - mavenLocal() // for local testing - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath "org.shipkit:shipkit-changelog:1.2.0" - classpath "org.shipkit:shipkit-auto-version:1.2.2" - classpath "io.github.gradle-nexus:publish-plugin:1.3.0" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.9.10" - } +plugins { + id "org.gradle.base" + id "org.shipkit.shipkit-changelog" version "1.2.0" + id "org.shipkit.shipkit-github-release" version "1.2.0" + id "org.shipkit.shipkit-auto-version" version "1.2.2" + id "io.github.gradle-nexus.publish-plugin" version "1.3.0" + id "org.jetbrains.kotlin.jvm" version "1.9.20" apply false + id "org.jetbrains.dokka" version "1.9.10" apply false } -apply plugin: 'org.gradle.base' -apply plugin: "io.github.gradle-nexus.publish-plugin" -apply plugin: 'org.shipkit.shipkit-auto-version' -apply plugin: "org.shipkit.shipkit-changelog" -apply plugin: "org.shipkit.shipkit-github-release" - def test = tasks.register("test") { dependsOn gradle.includedBuild("tests").task(":test") } diff --git a/mockito-kotlin/build.gradle b/mockito-kotlin/build.gradle index b2b547c8..7cc02b88 100644 --- a/mockito-kotlin/build.gradle +++ b/mockito-kotlin/build.gradle @@ -1,9 +1,11 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -apply plugin: 'kotlin' +plugins { + id "org.jetbrains.kotlin.jvm" + id "org.jetbrains.dokka" +} apply from: '../gradle/publishing.gradle' -apply plugin: 'org.jetbrains.dokka' group = 'org.mockito.kotlin' diff --git a/tests/build.gradle b/tests/build.gradle index a2ace7e6..4137013a 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -1,19 +1,12 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -buildscript { - repositories { - mavenCentral() - } - dependencies { - def kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.9.20' - println "$project uses Kotlin $kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } +plugins { + id "org.gradle.java" + id "org.jetbrains.kotlin.jvm" version "${testKotlinVersion}" } -apply plugin: 'java' -apply plugin: 'kotlin' +logger.lifecycle "${project} uses Kotlin ${testKotlinVersion}" repositories { mavenCentral() diff --git a/tests/gradle.properties b/tests/gradle.properties new file mode 100644 index 00000000..90f4b07f --- /dev/null +++ b/tests/gradle.properties @@ -0,0 +1,3 @@ +# Default version for the :tests module for Kotlin StdLib / KGP. +# See https://github.com/mockito/mockito-kotlin#testing for more. +testKotlinVersion=1.9.20