Skip to content

Commit

Permalink
Remove configuration caching from createAndPushVersionTag task (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrawford-figure authored Mar 23, 2023
1 parent e74863f commit 416f195
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 46 deletions.
22 changes: 13 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.addAll(
"-version",
"-Xjsr305=strict",
"-opt-in=kotlin.RequiresOptIn"
)
verbose.set(true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 9 additions & 4 deletions src/main/kotlin/com/figure/gradle/semver/SemverPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,9 +41,13 @@ class SemverPlugin : Plugin<Project> {
versionTagName.set(semver.versionTagName)
}

project.tasks.register<CreateAndPushVersionTag>("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<DefaultTask>("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}")
}
}
}

This file was deleted.

0 comments on commit 416f195

Please sign in to comment.