diff --git a/build.gradle.kts b/build.gradle.kts index 7409af2..3dc306e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION as KOTLIN_VERSION @Suppress("DSL_SCOPE_VIOLATION") @@ -67,16 +69,18 @@ configurations.all { } kotlin { - // Configures Java toolchain both for Kotlin JVM and Java tasks jvmToolchain(11) - target { - compilations.all { - kotlinOptions { - freeCompilerArgs = - freeCompilerArgs + listOf("-version", "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn") - verbose = true - } - } +} + +tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_11) + freeCompilerArgs.addAll( + "-version", + "-Xjsr305=strict", + "-opt-in=kotlin.RequiresOptIn" + ) + verbose.set(true) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 18d00c1..4709635 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ kotlin = "1.8.10" # Library versions detekt = "1.22.0" gradle-plugin-publish = "1.1.0" -jgit = "6.4.0.202211300538-r" +jgit = "6.5.0.202303070854-r" kotest = "5.5.5" ktlint-gradle = "11.3.1" swiftzer-semver = "1.2.0" diff --git a/src/main/kotlin/com/figure/gradle/semver/SemverPlugin.kt b/src/main/kotlin/com/figure/gradle/semver/SemverPlugin.kt index d003fb5..b39ae51 100644 --- a/src/main/kotlin/com/figure/gradle/semver/SemverPlugin.kt +++ b/src/main/kotlin/com/figure/gradle/semver/SemverPlugin.kt @@ -8,9 +8,10 @@ package com.figure.gradle.semver import com.figure.gradle.semver.internal.git.git -import com.figure.gradle.semver.internal.tasks.CreateAndPushVersionTag +import com.figure.gradle.semver.internal.semverLifecycle import com.figure.gradle.semver.internal.tasks.CurrentSemverTask import com.figure.gradle.semver.internal.tasks.GenerateVersionFileTask +import org.gradle.api.DefaultTask import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.create @@ -40,9 +41,13 @@ class SemverPlugin : Plugin { versionTagName.set(semver.versionTagName) } - project.tasks.register("createAndPushVersionTag") { - versionTagName.set(semver.versionTagName) - git.set(project.git(semver.gitDir.get())) + // Just run this task. This avoids a whole headache with configuration caching. + // This task should never be cached so there is no reason to involve caching mechanisms + project.tasks.register("createAndPushVersionTag") { + val git = project.git(semver.gitDir.get()) + git.tag().setName(semver.versionTagName).call() + git.push().setPushTags().call() + logger.semverLifecycle("Created and pushed version tag: ${semver.versionTagName}") } } } diff --git a/src/main/kotlin/com/figure/gradle/semver/internal/tasks/CreateAndPushVersionTag.kt b/src/main/kotlin/com/figure/gradle/semver/internal/tasks/CreateAndPushVersionTag.kt deleted file mode 100644 index 6b626d4..0000000 --- a/src/main/kotlin/com/figure/gradle/semver/internal/tasks/CreateAndPushVersionTag.kt +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2023 Figure Technologies and its affiliates. - * - * This source code is licensed under the Apache 2.0 license found in the - * LICENSE.md file in the root directory of this source tree. - */ - -package com.figure.gradle.semver.internal.tasks - -import com.figure.gradle.semver.internal.semverLifecycle -import org.eclipse.jgit.api.Git -import org.gradle.api.DefaultTask -import org.gradle.api.provider.Property -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.TaskAction -import org.gradle.work.DisableCachingByDefault - -@DisableCachingByDefault(because = "Not worth caching, and Git library is incompatible") -internal abstract class CreateAndPushVersionTag : DefaultTask() { - @get:Input - internal abstract val versionTagName: Property - - @get:Input - internal abstract val git: Property - - @TaskAction - internal fun createAndPushTag() { - git.get().tag().setName(versionTagName.get()).call() - git.get().push().setPushTags().call() - logger.semverLifecycle("Created and pushed version tag: ${versionTagName.get()}") - } -}