Skip to content

Commit a6719ad

Browse files
authored
Use Gradle plugins { } instead of buildscript { } (#503)
1 parent 306dd3f commit a6719ad

File tree

6 files changed

+22
-35
lines changed

6 files changed

+22
-35
lines changed

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ jobs:
6767
- name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }}
6868
run: |
6969
ops/mockMakerInline.sh
70-
./gradlew build
70+
./gradlew build -PtestKotlinVersion=${{ matrix.kotlin }}
7171
env:
72-
KOTLIN_VERSION: ${{ matrix.kotlin }}
7372
MOCK_MAKER: ${{ matrix.mock-maker }}
7473

7574
#

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ keeping the base module at a recent version.
5858

5959
Usually it is enough to test only using the default Kotlin versions;
6060
CI will test against multiple versions.
61-
If you want to test using a different Kotlin version locally, set
62-
an environment variable `KOTLIN_VERSION` and run the tests.
61+
If you want to test using a different Kotlin version locally,
62+
add the `-PtestKotlinVersion=1.2.3` argument to the Gradle invocation while running the tests.
6363

6464
### Acknowledgements
6565

build.gradle

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
buildscript {
2-
repositories {
3-
mavenLocal() // for local testing
4-
maven { url "https://plugins.gradle.org/m2/" }
5-
}
6-
dependencies {
7-
classpath "org.shipkit:shipkit-changelog:1.2.0"
8-
classpath "org.shipkit:shipkit-auto-version:1.2.2"
9-
classpath "io.github.gradle-nexus:publish-plugin:1.3.0"
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20"
11-
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.9.10"
12-
}
1+
plugins {
2+
id "org.gradle.base"
3+
id "org.shipkit.shipkit-changelog" version "1.2.0"
4+
id "org.shipkit.shipkit-github-release" version "1.2.0"
5+
id "org.shipkit.shipkit-auto-version" version "1.2.2"
6+
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
7+
id "org.jetbrains.kotlin.jvm" version "1.9.20" apply false
8+
id "org.jetbrains.dokka" version "1.9.10" apply false
139
}
1410

15-
apply plugin: 'org.gradle.base'
16-
apply plugin: "io.github.gradle-nexus.publish-plugin"
17-
apply plugin: 'org.shipkit.shipkit-auto-version'
18-
apply plugin: "org.shipkit.shipkit-changelog"
19-
apply plugin: "org.shipkit.shipkit-github-release"
20-
2111
def test = tasks.register("test") {
2212
dependsOn gradle.includedBuild("tests").task(":test")
2313
}

mockito-kotlin/build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33

4-
apply plugin: 'kotlin'
4+
plugins {
5+
id "org.jetbrains.kotlin.jvm"
6+
id "org.jetbrains.dokka"
7+
}
58
apply from: '../gradle/publishing.gradle'
6-
apply plugin: 'org.jetbrains.dokka'
79

810
group = 'org.mockito.kotlin'
911

tests/build.gradle

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33

4-
buildscript {
5-
repositories {
6-
mavenCentral()
7-
}
8-
dependencies {
9-
def kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.9.20'
10-
println "$project uses Kotlin $kotlin_version"
11-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12-
}
4+
plugins {
5+
id "org.gradle.java"
6+
id "org.jetbrains.kotlin.jvm" version "${testKotlinVersion}"
137
}
148

15-
apply plugin: 'java'
16-
apply plugin: 'kotlin'
9+
logger.lifecycle "${project} uses Kotlin ${testKotlinVersion}"
1710

1811
repositories {
1912
mavenCentral()

tests/gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Default version for the :tests module for Kotlin StdLib / KGP.
2+
# See https://github.com/mockito/mockito-kotlin#testing for more.
3+
testKotlinVersion=1.9.20

0 commit comments

Comments
 (0)