Skip to content

Commit

Permalink
Don't include snapshot commit hash in file name
Browse files Browse the repository at this point in the history
  • Loading branch information
booky10 committed Jul 8, 2024
1 parent f81730c commit b0fa4eb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
13 changes: 10 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ val snapshot = true
group = "com.github.retrooper"
description = rootProject.name

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")
Expand All @@ -22,7 +22,8 @@ fun getVersionMeta(): String {
}
return "$commitHash-SNAPSHOT"
}
version = "$fullVersion${getVersionMeta()}"
version = "$fullVersion${getVersionMeta(true)}"
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"

tasks {
wrapper {
Expand Down Expand Up @@ -63,3 +64,9 @@ tasks {

defaultTasks("build")
}

allprojects {
tasks.withType<Jar> {
archiveVersion = rootProject.ext["versionNoHash"] as String
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ publishing {
create<MavenPublication>("shadow") {
groupId = project.group as String
artifactId = "packetevents-" + project.name
version = project.version as String
version = rootProject.ext["versionNoHash"] as String

if (isShadow) {
artifact(project.tasks.withType<ShadowJar>().getByName("shadowJar").archiveFile)
Expand Down Expand Up @@ -149,4 +149,4 @@ val taskNames = gradle.startParameter.taskNames
if (taskNames.any { it.contains("build") }
&& taskNames.any { it.contains("publish") }) {
throw IllegalStateException("Cannot build and publish at the same time.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

tasks {
shadowJar {
archiveFileName = "packetevents-${project.name}-${project.version}.jar"
archiveFileName = "packetevents-${project.name}-${rootProject.ext["versionNoHash"]}.jar"
archiveClassifier = null

relocate("net.kyori.adventure.text.serializer", "io.github.retrooper.packetevents.adventure.serializer")
Expand Down Expand Up @@ -45,4 +45,4 @@ fun DependencyFilter.exclude(dependency: ResolvedDependency) {
dependency.children.forEach {
exclude(it)
}
}
}
9 changes: 6 additions & 3 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ tasks {
}
}

remapJar {
archiveBaseName.set("${rootProject.name}-fabric")
sequenceOf(remapJar, remapSourcesJar).forEach {
it {
archiveBaseName = "${rootProject.name}-fabric"
archiveVersion = rootProject.ext["versionNoHash"] as String
}
}
}
}

0 comments on commit b0fa4eb

Please sign in to comment.