Skip to content

Commit

Permalink
style!: update plugin kotlin-qa to v0.78.0
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored and DanySK committed Jan 27, 2025
1 parent 14834ee commit 9eea30c
Show file tree
Hide file tree
Showing 8 changed files with 481 additions and 408 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins {
}

group = "org.danilopianini"

class ProjectInfo {
val projectId = "$group.$name"
val fullName = "Gradle Git-Sensitive Semantic Versioning Plugin"
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
gitSemVer = { id = "org.danilopianini.git-sensitive-semantic-versioning-gradle-plugin", version = "3.1.10" }
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version = "1.3.0" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-qa = { id = "org.danilopianini.gradle-kotlin-qa", version = "0.66.1" }
kotlin-qa = { id = "org.danilopianini.gradle-kotlin-qa", version = "0.78.0" }
multiJvmTesting = { id = "org.danilopianini.multi-jvm-test-plugin", version = "1.3.2" }
publishOnCentral = { id = "org.danilopianini.publish-on-central", version = "5.1.11" }
taskTree = { id = "com.dorongold.task-tree", version = "4.0.0" }
79 changes: 42 additions & 37 deletions src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,52 @@ import javax.inject.Inject
/**
* A Plugin for comuting the project version based on the status of the local git repository.
*/
class GitSemVer @Inject constructor(
private val providerFactory: ProviderFactory,
private val objectFactory: ObjectFactory,
) : Plugin<Project> {

override fun apply(project: Project): Unit = with(project) {
class GitSemVer
@Inject

Check warning on line 13 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L13

Added line #L13 was not covered by tests
constructor(
private val providerFactory: ProviderFactory,
private val objectFactory: ObjectFactory,

Check warning on line 16 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L15-L16

Added lines #L15 - L16 were not covered by tests
) : Plugin<Project> {
override fun apply(project: Project): Unit =
with(project) {

Check warning on line 19 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L19

Added line #L19 was not covered by tests
/*
* Recursively scan project directory. If git repo is found, rely on GitSemVerExtension to inspect it.
*/
val extension = createExtension<GitSemVerExtension>(
GitSemVerExtension.EXTENSION_NAME,
providerFactory,
objectFactory,
projectDir,
version,
logger,
)
afterEvaluate {
properties[extension.forceVersionPropertyName.get()]?.let { forceVersion ->
require(SemanticVersion.semVerRegex.matches(forceVersion.toString())) {
"The version '$forceVersion. is not a valid semantic versioning format"
val extension =
createExtension<GitSemVerExtension>(
GitSemVerExtension.EXTENSION_NAME,
providerFactory,
objectFactory,
projectDir,
version,
logger,

Check warning on line 30 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L23-L30

Added lines #L23 - L30 were not covered by tests
)
afterEvaluate {

Check warning on line 32 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L32

Added line #L32 was not covered by tests
properties[extension.forceVersionPropertyName.get()]?.let { forceVersion ->
require(SemanticVersion.semVerRegex.matches(forceVersion.toString())) {
"The version '$forceVersion. is not a valid semantic versioning format"

Check warning on line 35 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L35

Added line #L35 was not covered by tests
}
logger.lifecycle(
"Forcing version to $forceVersion as per property '${extension.forceVersionPropertyName}'",

Check warning on line 38 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L37-L38

Added lines #L37 - L38 were not covered by tests
)
version = forceVersion
} ?: run { version = extension.assignGitSemanticVersion() }
}
tasks.register("printGitSemVer") {
val forceVersion = properties[extension.forceVersionPropertyName.get()]
it.doLast {
println(
"Version computed by ${GitSemVer::class.java.simpleName}: " +

Check warning on line 47 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L40-L47

Added lines #L40 - L47 were not covered by tests
"${forceVersion ?: extension.computeVersion()}",
)
}

Check warning on line 50 in src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/gitsemver/GitSemVer.kt#L50

Added line #L50 was not covered by tests
}
logger.lifecycle(
"Forcing version to $forceVersion. mandated by property '$extension.forceVersionPropertyName'",
)
version = forceVersion
} ?: run { version = extension.assignGitSemanticVersion() }
}
tasks.register("printGitSemVer") {
val forceVersion = properties[extension.forceVersionPropertyName.get()]
it.doLast {
println(
"Version computed by ${GitSemVer::class.java.simpleName}: " +
"${forceVersion ?: extension.computeVersion()}",
)
}
}
}

companion object {
private inline fun <reified T> Project.createExtension(name: String, vararg args: Any?): T =
project.extensions.create(name, T::class.java, *args)
private companion object {
private inline fun <reified T> Project.createExtension(
name: String,
vararg args: Any?,
): T = project.extensions.create(name, T::class.java, *args)
}
}
}
Loading

0 comments on commit 9eea30c

Please sign in to comment.