Skip to content

Commit ed9bae6

Browse files
committed
Improve build file
1 parent cd74c89 commit ed9bae6

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

build.gradle.kts

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
1+
import org.ajoberstar.grgit.Grgit
2+
import java.util.*
3+
14
plugins {
25
kotlin("jvm") version "1.8.20"
6+
id("org.ajoberstar.grgit") version "5.2.0"
37
`java-library`
48
}
59

10+
if (!File("$rootDir/.git").exists()) {
11+
logger.lifecycle(
12+
"""
13+
**************************************************************************************
14+
You need to fork and clone this repository! Don't download a .zip file.
15+
If you need assistance, consult the GitHub docs: https://docs.github.com/get-started/quickstart/fork-a-repo
16+
**************************************************************************************
17+
""".trimIndent()
18+
).also { System.exit(1) }
19+
}
20+
621
group = "net.onelitefeather"
7-
version = "1.0.0-SNAPSHOT"
22+
var baseVersion by extra("1.0.0")
23+
var extension by extra("")
24+
var snapshot by extra("-SNAPSHOT")
25+
26+
ext {
27+
val git: Grgit = Grgit.open {
28+
dir = File("$rootDir/.git")
29+
}
30+
val revision = git.head().abbreviatedId
31+
extension = "%s+%s".format(Locale.ROOT, snapshot, revision)
32+
}
33+
34+
35+
version = "%s%s".format(Locale.ROOT, baseVersion, extension)
836

937
repositories {
1038
mavenCentral()
@@ -14,10 +42,17 @@ dependencies {
1442
testImplementation(kotlin("test"))
1543
}
1644

17-
tasks.test {
18-
useJUnitPlatform()
45+
tasks {
46+
test {
47+
useJUnitPlatform()
48+
}
1949
}
2050

2151
kotlin {
22-
jvmToolchain(11)
52+
jvmToolchain(17)
53+
sourceSets.all {
54+
languageSettings {
55+
languageVersion = "2.0"
56+
}
57+
}
2358
}

0 commit comments

Comments
 (0)