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
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
val fullVersion = "2.4.5"
|
||||||
|
val snapshot = true
|
||||||
|
|
||||||
group = "me.tofaa.entitylib"
|
group = "me.tofaa.entitylib"
|
||||||
description = rootProject.name
|
description = rootProject.name
|
||||||
val fullVersion = "2.4.1"
|
|
||||||
val snapshot = true
|
|
||||||
|
|
||||||
fun getVersionMeta(): String {
|
fun getVersionMeta(includeHash: Boolean): String {
|
||||||
if (!snapshot) {
|
if (!snapshot) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var commitHash = ""
|
var commitHash = ""
|
||||||
if (file(".git").isDirectory) {
|
if (includeHash && file(".git").isDirectory) {
|
||||||
val stdout = ByteArrayOutputStream()
|
val stdout = ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||||
|
@ -20,7 +21,8 @@ fun getVersionMeta(): String {
|
||||||
}
|
}
|
||||||
return "$commitHash-SNAPSHOT"
|
return "$commitHash-SNAPSHOT"
|
||||||
}
|
}
|
||||||
version = "$fullVersion${getVersionMeta()}"
|
version = "$fullVersion${getVersionMeta(true)}"
|
||||||
|
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
wrapper {
|
wrapper {
|
||||||
|
@ -28,12 +30,14 @@ tasks {
|
||||||
distributionType = Wrapper.DistributionType.ALL
|
distributionType = Wrapper.DistributionType.ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
register("build") {
|
fun subModuleTasks(taskName: String): List<Task> {
|
||||||
// Filter out the 'platforms' directory itself, but include its subprojects
|
return subprojects
|
||||||
val subModuleBuildTasks = subprojects
|
|
||||||
.filter { it.name != "platforms" }
|
.filter { it.name != "platforms" }
|
||||||
.mapNotNull { it.tasks.findByName("build") }
|
.mapNotNull { it.tasks.findByName(taskName) }
|
||||||
|
}
|
||||||
|
|
||||||
|
register("build") {
|
||||||
|
val subModuleBuildTasks = subModuleTasks("build")
|
||||||
dependsOn(subModuleBuildTasks)
|
dependsOn(subModuleBuildTasks)
|
||||||
group = "build"
|
group = "build"
|
||||||
|
|
||||||
|
@ -58,10 +62,7 @@ tasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
register<Delete>("clean") {
|
register<Delete>("clean") {
|
||||||
val cleanTasks = subprojects
|
val cleanTasks = subModuleTasks("clean")
|
||||||
.filter { it.name != "platforms" }
|
|
||||||
.mapNotNull { it.tasks.findByName("clean") }
|
|
||||||
|
|
||||||
dependsOn(cleanTasks)
|
dependsOn(cleanTasks)
|
||||||
group = "build"
|
group = "build"
|
||||||
delete(rootProject.layout.buildDirectory)
|
delete(rootProject.layout.buildDirectory)
|
||||||
|
|
|
@ -52,7 +52,7 @@ publishing {
|
||||||
create<MavenPublication>("shadow") {
|
create<MavenPublication>("shadow") {
|
||||||
groupId = project.group as String
|
groupId = project.group as String
|
||||||
artifactId = project.name
|
artifactId = project.name
|
||||||
version = project.version as String
|
version = rootProject.ext["versionNoHash"] as String
|
||||||
|
|
||||||
if (isShadow) {
|
if (isShadow) {
|
||||||
artifact(project.tasks.withType<ShadowJar>().getByName("shadowJar").archiveFile)
|
artifact(project.tasks.withType<ShadowJar>().getByName("shadowJar").archiveFile)
|
||||||
|
@ -101,6 +101,12 @@ publishing {
|
||||||
url = "https://www.gnu.org/licenses/gpl-3.0.html"
|
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 {
|
tasks {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
archiveFileName = "EntityLib-${project.name}-${project.version}.jar"
|
archiveFileName = "EntityLib-${project.name}-${rootProject.ext["versionNoHash"]}.jar"
|
||||||
archiveClassifier = null
|
archiveClassifier = null
|
||||||
|
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
Loading…
Reference in a new issue