Fix: File naming containing the commit hash as well
This commit is contained in:
parent
0fdf1667b1
commit
0101e88f24
3 changed files with 22 additions and 15 deletions
|
@ -1,16 +1,17 @@
|
|||
import java.io.ByteArrayOutputStream
|
||||
|
||||
val fullVersion = "2.4.5"
|
||||
val snapshot = true
|
||||
|
||||
group = "me.tofaa.entitylib"
|
||||
description = rootProject.name
|
||||
val fullVersion = "2.4.1"
|
||||
val snapshot = true
|
||||
|
||||
fun getVersionMeta(): String {
|
||||
fun getVersionMeta(includeHash: Boolean): String {
|
||||
if (!snapshot) {
|
||||
return ""
|
||||
}
|
||||
var commitHash = ""
|
||||
if (file(".git").isDirectory) {
|
||||
if (includeHash && file(".git").isDirectory) {
|
||||
val stdout = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||
|
@ -20,7 +21,8 @@ fun getVersionMeta(): String {
|
|||
}
|
||||
return "$commitHash-SNAPSHOT"
|
||||
}
|
||||
version = "$fullVersion${getVersionMeta()}"
|
||||
version = "$fullVersion${getVersionMeta(true)}"
|
||||
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
||||
|
||||
tasks {
|
||||
wrapper {
|
||||
|
@ -28,12 +30,14 @@ tasks {
|
|||
distributionType = Wrapper.DistributionType.ALL
|
||||
}
|
||||
|
||||
register("build") {
|
||||
// Filter out the 'platforms' directory itself, but include its subprojects
|
||||
val subModuleBuildTasks = subprojects
|
||||
fun subModuleTasks(taskName: String): List<Task> {
|
||||
return subprojects
|
||||
.filter { it.name != "platforms" }
|
||||
.mapNotNull { it.tasks.findByName("build") }
|
||||
.mapNotNull { it.tasks.findByName(taskName) }
|
||||
}
|
||||
|
||||
register("build") {
|
||||
val subModuleBuildTasks = subModuleTasks("build")
|
||||
dependsOn(subModuleBuildTasks)
|
||||
group = "build"
|
||||
|
||||
|
@ -58,10 +62,7 @@ tasks {
|
|||
}
|
||||
|
||||
register<Delete>("clean") {
|
||||
val cleanTasks = subprojects
|
||||
.filter { it.name != "platforms" }
|
||||
.mapNotNull { it.tasks.findByName("clean") }
|
||||
|
||||
val cleanTasks = subModuleTasks("clean")
|
||||
dependsOn(cleanTasks)
|
||||
group = "build"
|
||||
delete(rootProject.layout.buildDirectory)
|
||||
|
|
|
@ -52,7 +52,7 @@ publishing {
|
|||
create<MavenPublication>("shadow") {
|
||||
groupId = project.group as String
|
||||
artifactId = project.name
|
||||
version = project.version as String
|
||||
version = rootProject.ext["versionNoHash"] as String
|
||||
|
||||
if (isShadow) {
|
||||
artifact(project.tasks.withType<ShadowJar>().getByName("shadowJar").archiveFile)
|
||||
|
@ -101,6 +101,12 @@ publishing {
|
|||
url = "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
connection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
|
||||
developerConnection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
|
||||
url = "https://github.com/Tofaa2/EntityLib"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ plugins {
|
|||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName = "EntityLib-${project.name}-${project.version}.jar"
|
||||
archiveFileName = "EntityLib-${project.name}-${rootProject.ext["versionNoHash"]}.jar"
|
||||
archiveClassifier = null
|
||||
|
||||
mergeServiceFiles()
|
||||
|
|
Loading…
Reference in a new issue