mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
build.gradle: load git just once, just fetch 1 commit
This improves reloading/testing performance a lot
This commit is contained in:
parent
9d54e48b32
commit
0eec3e496c
@ -14,7 +14,9 @@
|
|||||||
import de.bixilon.kutil.os.Architectures
|
import de.bixilon.kutil.os.Architectures
|
||||||
import de.bixilon.kutil.os.OSTypes
|
import de.bixilon.kutil.os.OSTypes
|
||||||
import de.bixilon.kutil.os.PlatformInfo
|
import de.bixilon.kutil.os.PlatformInfo
|
||||||
|
import org.ajoberstar.grgit.Commit
|
||||||
import org.ajoberstar.grgit.Grgit
|
import org.ajoberstar.grgit.Grgit
|
||||||
|
import org.ajoberstar.grgit.operation.LogOp
|
||||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
import org.gradle.configurationcache.extensions.capitalized
|
import org.gradle.configurationcache.extensions.capitalized
|
||||||
@ -26,7 +28,7 @@ plugins {
|
|||||||
kotlin("jvm") version "1.7.21"
|
kotlin("jvm") version "1.7.21"
|
||||||
`jvm-test-suite`
|
`jvm-test-suite`
|
||||||
application
|
application
|
||||||
id("org.ajoberstar.grgit") version "5.0.0"
|
id("org.ajoberstar.grgit.service") version "5.0.0"
|
||||||
id("com.github.ben-manes.versions") version "0.44.0"
|
id("com.github.ben-manes.versions") version "0.44.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,10 +390,11 @@ tasks.test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lateinit var git: Grgit
|
lateinit var git: Grgit
|
||||||
|
lateinit var commit: Commit
|
||||||
|
|
||||||
fun loadGit() {
|
fun loadGit() {
|
||||||
git = Grgit.open(mapOf("currentDir" to project.rootDir))
|
git = Grgit.open(mapOf("currentDir" to project.rootDir))
|
||||||
val commit = git.log().first()
|
commit = git.log { LogOp(git.repository).apply { maxCommits = 1 } }.first()
|
||||||
val tag = git.tag.list().find { it.commit == commit }
|
val tag = git.tag.list().find { it.commit == commit }
|
||||||
var nextVersion = if (tag != null) {
|
var nextVersion = if (tag != null) {
|
||||||
stable = true
|
stable = true
|
||||||
@ -414,10 +417,7 @@ val versionJsonTask = tasks.register("versionJson") {
|
|||||||
outputs.upToDateWhen { false }
|
outputs.upToDateWhen { false }
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
loadGit()
|
|
||||||
|
|
||||||
fun generateGit(): Map<String, Any> {
|
fun generateGit(): Map<String, Any> {
|
||||||
val commit = git.log().first()
|
|
||||||
return mapOf(
|
return mapOf(
|
||||||
"branch" to git.branch.current().name,
|
"branch" to git.branch.current().name,
|
||||||
"commit" to commit.id,
|
"commit" to commit.id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user