diff --git a/build.gradle.kts b/build.gradle.kts index 40811c0..646d9e5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { + 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("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) diff --git a/buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts b/buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts index 284a4c2..3463477 100644 --- a/buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts @@ -52,7 +52,7 @@ publishing { create("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().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" + } } } } diff --git a/buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts b/buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts index 00d91ac..fe648ed 100644 --- a/buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts @@ -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()