Skip to content

Commit

Permalink
Build changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Blad3Mak3r committed Nov 30, 2022
1 parent 615b7d5 commit 673746b
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream

plugins {
kotlin("jvm") version "1.6.0"
Expand All @@ -10,8 +11,34 @@ plugins {
}

group = "tv.blademaker"
val versionObj = Version(0, 11, 0)
version = versionObj.toString()

val gitTag: String? by lazy {
try {
val stdout = ByteArrayOutputStream()
rootProject.exec {
commandLine("git", "describe", "--tags", "--abbrev=0")
standardOutput = stdout
}

stdout.toString().trim()
} catch(e: Throwable) {
null
}
}

val gitHash: String by lazy {
val stdout = ByteArrayOutputStream()
rootProject.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}

stdout.toString().trim()
}

val isSnapshot = System.getenv("OSSRH_SNAPSHOT") != null

version = (gitTag ?: gitHash).plus(if (isSnapshot) "-SNAPSHOT" else "")

val jdaVersion = "5.0.0-beta.1"
val coroutinesVersion = "1.6.4"
Expand Down Expand Up @@ -70,7 +97,7 @@ java {
withSourcesJar()
}

val mavenCentralRepository = if (versionObj.isSnapshot)
val mavenCentralRepository = if (isSnapshot)
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
else
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
Expand Down Expand Up @@ -127,18 +154,6 @@ publishing {
}
}

class Version(
private val major: Int,
private val minor: Int,
private val revision: Int
) {
val isSnapshot = System.getenv("OSSRH_SNAPSHOT") != null

override fun toString(): String {
return "$major.$minor.$revision" + if (isSnapshot) "-SNAPSHOT" else ""
}
}

val canSign = System.getenv("SIGNING_KEY_ID") != null
if (canSign) {
signing {
Expand Down

0 comments on commit 673746b

Please sign in to comment.