build: auto increment jar build names
This commit is contained in:
parent
91d881392e
commit
82c40c3047
@ -1,4 +1,5 @@
|
|||||||
import org.apache.commons.lang3.SystemUtils
|
import org.apache.commons.lang3.SystemUtils
|
||||||
|
import java.util.Properties
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
idea
|
idea
|
||||||
@ -9,25 +10,24 @@ plugins {
|
|||||||
kotlin("jvm") version "2.0.0"
|
kotlin("jvm") version "2.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
//Constants:
|
|
||||||
|
|
||||||
val baseGroup: String by project
|
val baseGroup: String by project
|
||||||
val mcVersion: String by project
|
val mcVersion: String by project
|
||||||
val version: String by project
|
val versionBase: String by project
|
||||||
val mixinGroup = "$baseGroup.mixin"
|
val buildNumber: String by project
|
||||||
val modid: String by project
|
val modid: String by project
|
||||||
|
val mixinGroup = "$baseGroup.mixin"
|
||||||
|
|
||||||
|
group = baseGroup
|
||||||
|
version = "$versionBase-b$buildNumber"
|
||||||
|
|
||||||
// Toolchains:
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minecraft configuration:
|
|
||||||
loom {
|
loom {
|
||||||
log4jConfigs.from(file("log4j2.xml"))
|
log4jConfigs.from(file("log4j2.xml"))
|
||||||
launchConfigs {
|
launchConfigs {
|
||||||
"client" {
|
"client" {
|
||||||
// If you don't want mixins, remove these lines
|
|
||||||
property("mixin.debug", "true")
|
property("mixin.debug", "true")
|
||||||
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
|
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
|
||||||
}
|
}
|
||||||
@ -35,7 +35,6 @@ loom {
|
|||||||
runConfigs {
|
runConfigs {
|
||||||
"client" {
|
"client" {
|
||||||
if (SystemUtils.IS_OS_MAC_OSX) {
|
if (SystemUtils.IS_OS_MAC_OSX) {
|
||||||
// This argument causes a crash on macOS
|
|
||||||
vmArgs.remove("-XstartOnFirstThread")
|
vmArgs.remove("-XstartOnFirstThread")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,10 +42,8 @@ loom {
|
|||||||
}
|
}
|
||||||
forge {
|
forge {
|
||||||
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
|
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
|
||||||
// If you don't want mixins, remove this lines
|
|
||||||
mixinConfig("mixins.$modid.json")
|
mixinConfig("mixins.$modid.json")
|
||||||
}
|
}
|
||||||
// If you don't want mixins, remove these lines
|
|
||||||
mixin {
|
mixin {
|
||||||
defaultRefmapName.set("mixins.$modid.refmap.json")
|
defaultRefmapName.set("mixins.$modid.refmap.json")
|
||||||
}
|
}
|
||||||
@ -62,12 +59,9 @@ sourceSets.main {
|
|||||||
kotlin.destinationDirectory.set(java.destinationDirectory)
|
kotlin.destinationDirectory.set(java.destinationDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dependencies:
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven("https://repo.spongepowered.org/maven/")
|
maven("https://repo.spongepowered.org/maven/")
|
||||||
// If you don't want to log in with your real minecraft account, remove this line
|
|
||||||
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
|
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,30 +76,24 @@ dependencies {
|
|||||||
|
|
||||||
shadowImpl(kotlin("stdlib-jdk8"))
|
shadowImpl(kotlin("stdlib-jdk8"))
|
||||||
|
|
||||||
// If you don't want mixins, remove these lines
|
|
||||||
shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
|
shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
}
|
}
|
||||||
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
|
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
|
||||||
|
|
||||||
// If you don't want to log in with your real minecraft account, remove this line
|
|
||||||
runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.1")
|
runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.1")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tasks:
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile::class) {
|
tasks.withType(JavaCompile::class) {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.gradle.jvm.tasks.Jar::class) {
|
tasks.withType(org.gradle.jvm.tasks.Jar::class) {
|
||||||
archiveBaseName.set(modid)
|
archiveBaseName.set(modid)
|
||||||
|
archiveVersion.set("$version")
|
||||||
manifest.attributes.run {
|
manifest.attributes.run {
|
||||||
this["FMLCorePluginContainsFMLMod"] = "true"
|
this["FMLCorePluginContainsFMLMod"] = "true"
|
||||||
this["ForceLoadAsMod"] = "true"
|
this["ForceLoadAsMod"] = "true"
|
||||||
|
|
||||||
// If you don't want mixins, remove these lines
|
|
||||||
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
|
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
|
||||||
this["MixinConfigs"] = "mixins.$modid.json"
|
this["MixinConfigs"] = "mixins.$modid.json"
|
||||||
}
|
}
|
||||||
@ -124,7 +112,6 @@ tasks.processResources {
|
|||||||
rename("(.+_at.cfg)", "META-INF/$1")
|
rename("(.+_at.cfg)", "META-INF/$1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
|
val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
|
||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
from(tasks.shadowJar)
|
from(tasks.shadowJar)
|
||||||
@ -145,12 +132,13 @@ tasks.shadowJar {
|
|||||||
println("Copying dependencies into mod: ${it.files}")
|
println("Copying dependencies into mod: ${it.files}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you want to include other dependencies and shadow them, you can relocate them in here
|
|
||||||
fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name")
|
fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.assemble.get().dependsOn(tasks.remapJar)
|
tasks.assemble {
|
||||||
|
dependsOn(tasks.remapJar)
|
||||||
|
dependsOn("incrementBuildNumber")
|
||||||
|
}
|
||||||
|
|
||||||
tasks.register<Copy>("illyExtractMappings") {
|
tasks.register<Copy>("illyExtractMappings") {
|
||||||
from("O:/.gradle")
|
from("O:/.gradle")
|
||||||
@ -160,7 +148,6 @@ tasks.register<Copy>("illyExtractMappings") {
|
|||||||
tasks.register("illyApplyMappings") {
|
tasks.register("illyApplyMappings") {
|
||||||
dependsOn("illyExtractMappings")
|
dependsOn("illyExtractMappings")
|
||||||
doLast {
|
doLast {
|
||||||
// throw GradleException("${layout.buildDirectory.d}/mcp_mappings")
|
|
||||||
val mappingsDir = file("O:/Kotlin Programming/sbt/build/mcp_mappings")
|
val mappingsDir = file("O:/Kotlin Programming/sbt/build/mcp_mappings")
|
||||||
if (mappingsDir.exists()) {
|
if (mappingsDir.exists()) {
|
||||||
project.ext.set("mappingsPath", mappingsDir.absolutePath)
|
project.ext.set("mappingsPath", mappingsDir.absolutePath)
|
||||||
@ -176,3 +163,19 @@ tasks.withType<JavaCompile> {
|
|||||||
options.compilerArgs.add("-Amap=O:/Kotlin Programming/sbt/build/mcp_mappings")
|
options.compilerArgs.add("-Amap=O:/Kotlin Programming/sbt/build/mcp_mappings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔁 Auto-increment build number each assemble
|
||||||
|
tasks.register("incrementBuildNumber") {
|
||||||
|
doLast {
|
||||||
|
val propsFile = file("gradle.properties")
|
||||||
|
val props = Properties()
|
||||||
|
props.load(propsFile.inputStream())
|
||||||
|
|
||||||
|
val current = props.getProperty("buildNumber")?.toIntOrNull() ?: 1
|
||||||
|
val next = current + 1
|
||||||
|
props.setProperty("buildNumber", next.toString())
|
||||||
|
props.store(propsFile.outputStream(), null)
|
||||||
|
|
||||||
|
println("🔢 Build number incremented to $next")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user