Skip to content

Commit

Permalink
Use Gradle plugins { } instead of buildscript { } (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob authored Dec 3, 2023
1 parent 306dd3f commit a6719ad
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

#
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 8 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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")
}
Expand Down
6 changes: 4 additions & 2 deletions mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
15 changes: 4 additions & 11 deletions tests/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
3 changes: 3 additions & 0 deletions tests/gradle.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a6719ad

Please sign in to comment.