What is your build?

- Add build numbers in mod version strings
- Remove default process resources from SubprojectExtension
This commit is contained in:
Jozufozu 2025-03-01 16:44:57 -08:00
parent ef32aab272
commit 73341320ac
5 changed files with 116 additions and 43 deletions

View file

@ -13,7 +13,6 @@ import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.jvm.tasks.Jar
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.*
import org.gradle.language.jvm.tasks.ProcessResources
import java.io.File
import java.net.URI
import java.util.*
@ -31,11 +30,18 @@ open class SubprojectExtension(val project: Project) {
setupPublishing()
}
private fun setBaseProperties(archiveBase: String, group: String, version: String) {
val buildNumber: String? by lazy {
val dev = System.getenv("RELEASE")?.contentEquals("false", true) ?: true
val buildNumber = System.getenv("BUILD_NUMBER")
val versionSuffix = if (dev && buildNumber != null) "-${buildNumber}" else ""
if (dev) {
System.getenv("BUILD_NUMBER")
} else {
null
}
}
private fun setBaseProperties(archiveBase: String, group: String, version: String) {
val versionSuffix = if (buildNumber != null) "-${buildNumber}" else ""
project.group = project.property(group) as String
project.version = "${project.property(version)}${versionSuffix}"
@ -139,16 +145,6 @@ open class SubprojectExtension(val project: Project) {
options.optionFiles(project.rootProject.file("javadoc-options.txt"))
options.encoding = "UTF-8"
}
val replaceProperties = processResourcesExpandProperties.associateWith { project.property(it) as String }
withType<ProcessResources>().configureEach {
inputs.properties(replaceProperties)
filesMatching(processResourcesExpandFiles) {
expand(replaceProperties)
}
}
}
}
@ -207,26 +203,3 @@ open class SubprojectExtension(val project: Project) {
}
}
}
val processResourcesExpandFiles = listOf("pack.mcmeta", "fabric.mod.json", "META-INF/mods.toml")
val processResourcesExpandProperties = listOf(
"mod_license",
"mod_sources",
"mod_issues",
"mod_homepage",
"flywheel_id",
"flywheel_name",
"flywheel_description",
"flywheel_version",
"vanillin_id",
"vanillin_name",
"vanillin_version",
"vanillin_description",
"flywheel_maven_version_range",
"flywheel_semver_version_range",
"minecraft_semver_version_range",
"minecraft_maven_version_range",
"fabric_api_version_range",
"forge_version_range",
)

View file

@ -66,16 +66,43 @@ platform {
setupTestMod(testMod)
}
var flywheelVersion = "${property("flywheel_version")}+${property("minecraft_version")}"
if (subproject.buildNumber != null) {
flywheelVersion += ".build.${subproject.buildNumber}"
}
val replaceProperties = listOf(
"mod_license",
"mod_sources",
"mod_issues",
"mod_homepage",
"flywheel_id",
"flywheel_name",
"flywheel_description",
"minecraft_semver_version_range",
"fabric_api_version_range",
).associateWith { property(it) as String }
.plus("flywheel_version" to flywheelVersion)
tasks.withType<ProcessResources>().configureEach {
inputs.properties(replaceProperties)
filesMatching(listOf("fabric.mod.json")) {
expand(replaceProperties)
}
}
jarSets {
mainSet.publishWithRemappedSources {
artifactId = "flywheel-fabric-${project.property("artifact_minecraft_version")}"
artifactId = "flywheel-fabric-${property("artifact_minecraft_version")}"
}
mainSet.outgoing("flywheel")
create("api", api, lib).apply {
addToAssemble()
publishWithRemappedSources {
artifactId = "flywheel-fabric-api-${project.property("artifact_minecraft_version")}"
artifactId = "flywheel-fabric-api-${property("artifact_minecraft_version")}"
}
configureJar {

View file

@ -64,16 +64,37 @@ platform {
setupTestMod(testMod)
}
val replaceProperties = listOf(
"mod_license",
"mod_sources",
"mod_issues",
"mod_homepage",
"flywheel_id",
"flywheel_name",
"flywheel_description",
"minecraft_maven_version_range",
"forge_version_range",
).associateWith { property(it) as String }
.plus("flywheel_version" to "${property("flywheel_version")}${if (subproject.buildNumber != null) "-${subproject.buildNumber}" else ""}")
tasks.withType<ProcessResources>().configureEach {
inputs.properties(replaceProperties)
filesMatching(listOf("pack.mcmeta", "META-INF/mods.toml")) {
expand(replaceProperties)
}
}
jarSets {
mainSet.publishWithRawSources {
artifactId = "flywheel-forge-${project.property("artifact_minecraft_version")}"
artifactId = "flywheel-forge-${property("artifact_minecraft_version")}"
}
mainSet.outgoing("flywheel")
create("api", api, lib).apply {
addToAssemble()
publishWithRawSources {
artifactId = "flywheel-forge-api-${project.property("artifact_minecraft_version")}"
artifactId = "flywheel-forge-api-${property("artifact_minecraft_version")}"
}
configureJar {

View file

@ -26,9 +26,38 @@ transitiveSourceSets {
}
}
var vanillinVersion = "${property("vanillin_version")}+${property("minecraft_version")}"
if (subproject.buildNumber != null) {
vanillinVersion += ".build.${subproject.buildNumber}"
}
val replaceProperties = listOf(
"mod_license",
"mod_sources",
"mod_issues",
"mod_homepage",
"flywheel_id",
"vanillin_id",
"vanillin_name",
"vanillin_description",
"minecraft_semver_version_range",
"flywheel_semver_version_range",
"fabric_api_version_range",
).associateWith { property(it) as String }
.plus("vanillin_version" to vanillinVersion)
tasks.withType<ProcessResources>().configureEach {
inputs.properties(replaceProperties)
filesMatching(listOf("fabric.mod.json")) {
expand(replaceProperties)
}
}
jarSets {
mainSet.publishWithRemappedSources {
artifactId = "vanillin-fabric-${project.property("artifact_minecraft_version")}"
artifactId = "vanillin-fabric-${property("artifact_minecraft_version")}"
}
}

View file

@ -26,9 +26,32 @@ transitiveSourceSets {
}
}
val replaceProperties = listOf(
"mod_license",
"mod_sources",
"mod_issues",
"mod_homepage",
"flywheel_id",
"vanillin_id",
"vanillin_name",
"vanillin_description",
"flywheel_maven_version_range",
"minecraft_maven_version_range",
"forge_version_range",
).associateWith { property(it) as String }
.plus("vanillin_version" to "${property("vanillin_version")}${if (subproject.buildNumber != null) "-${subproject.buildNumber}" else ""}")
tasks.withType<ProcessResources>().configureEach {
inputs.properties(replaceProperties)
filesMatching(listOf("pack.mcmeta", "META-INF/mods.toml")) {
expand(replaceProperties)
}
}
jarSets {
mainSet.publishWithRawSources {
artifactId = "vanillin-forge-${project.property("artifact_minecraft_version")}"
artifactId = "vanillin-forge-${property("artifact_minecraft_version")}"
}
}