Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move reckon configuration to settings.gradle.kts #113

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import com.saveourtool.buildutils.*


plugins {
kotlin("multiplatform") apply false
id("com.saveourtool.buildutils.publishing-configuration")
Expand All @@ -9,8 +8,6 @@ plugins {

group = "com.saveourtool.okio-extras"

configureVersioning()

allprojects {
repositories {
mavenCentral()
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:4.3.0")
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.5")
implementation("org.ajoberstar.reckon:reckon-gradle:0.18.3")
implementation("org.ajoberstar.grgit:grgit-core:5.2.2")
}

This file was deleted.

48 changes: 48 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,52 @@
import org.ajoberstar.reckon.core.Reckoner
import org.ajoberstar.reckon.core.ScopeCalculator
import org.ajoberstar.reckon.core.VersionTagParser
import org.ajoberstar.reckon.gradle.ReckonExtension

rootProject.name = "okio-extras"

plugins {
id("org.ajoberstar.reckon.settings") version "0.18.3"
}

includeBuild("gradle/plugins")
include("okio-extras")

extensions.configure<ReckonExtension> {
setDefaultInferredScope("patch")
// to activate release, provide `-Prelease` or `-Prelease=true`. To deactivate, either omit the property, or set `-Prelease=false`.
val isRelease = extra.has("release") && extra["release"] != "false"
if (isRelease) {
val scopeCalculator = ScopeCalculator { inventory ->
if (inventory.isClean) {
calcScopeFromProp().calculate(inventory)
} else {
throw GradleException(
"Release build will be performed with not clean git tree; aborting."
)
}
}
setScopeCalc(scopeCalculator)
} else {
setScopeCalc(calcScopeFromProp())
}
val isSnapshot = extra.has("reckon.stage") && extra["reckon.stage"] == "snapshot"
if (isSnapshot) {
// we should build snapshots only for snapshot publishing, so it requires explicit parameter
snapshots()
} else {
stages("beta", "rc", Reckoner.FINAL_STAGE)
}
setStageCalc(calcStageFromProp())

// A terrible hack to remove all pre-release tags. Because in semver `0.1.0-SNAPSHOT` < `0.1.0-alpha`, in snapshot mode
// we remove tags like `0.1.0-alpha`, and then reckoned version will still be `0.1.0-SNAPSHOT` and it will be compliant.
val tagParser = VersionTagParser { tag: String ->
if (tag.matches(Regex("""^v\d+\.\d+\.\d+$"""))) {
VersionTagParser.getDefault().parse(tag)
} else {
java.util.Optional.empty()
}
}
setTagParser(tagParser)
}