Skip to content

Commit

Permalink
fix properties expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Sep 6, 2024
1 parent 6f2562a commit b3d6dfb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 61 deletions.
15 changes: 0 additions & 15 deletions Common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ val minecraftVersion: String by extra
val neoformTimestamp: String by extra
val modId: String by extra
val modJavaVersion: String by extra
//val modName: String by extra

val baseArchivesName = "${modId}-${minecraftVersion}-common"
base {
Expand Down Expand Up @@ -89,20 +88,6 @@ tasks.withType<JavaCompile> {
}
}

val modName = providers.gradleProperty("modName")

tasks.withType<ProcessResources> {
// val resourceProperties = mapOf("modName" to modName)
// val modName = providers.gradleProperty("modName")
//
// // this will ensure that this task is redone when the properties change.
// inputs.property("modName", modName)

filesMatching("pack.mcmeta") {
expand(mapOf("modName" to modName))
}
}

publishing {
publications {
register<MavenPublication>("commonJar") {
Expand Down
31 changes: 0 additions & 31 deletions Fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,6 @@ tasks.withType<JavaCompile> {
}
}

val resourceProperties: Map<String, String> = rootProject.ext.get("resourceProperties") as Map<String, String>

val githubUrl = providers.gradleProperty("githubUrl")
val modAuthor = providers.gradleProperty("modAuthor")
val modDescription = providers.gradleProperty("modDescription")
val modName = providers.gradleProperty("modName")
val versionProvider = provider {
version
}

tasks.withType<ProcessResources> {

// // this will ensure that this task is redone when the properties change.
// inputs.properties(resourceProperties)

filesMatching( "fabric.mod.json") {
expand(mapOf(
"curseHomepageUrl" to curseHomepageUrl,
"fabricApiVersion" to fabricApiVersion,
"fabricLoaderVersion" to fabricLoaderVersion,
"githubUrl" to githubUrl,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"modId" to modId,
"modJavaVersion" to modJavaVersion,
"modName" to modName,
"version" to versionProvider,
))
}
}

dependencies {
minecraft(
group = "com.mojang",
Expand Down
7 changes: 0 additions & 7 deletions Forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ tasks.withType<ProcessResources> {
inputs.files(it.sourceSets.main.get().resources)
from(it.sourceSets.main.get().resources)
}

// this will ensure that this task is redone when the properties change.
inputs.properties(resourceProperties)

filesMatching("META-INF/mods.toml") {
expand(resourceProperties)
}
}

tasks.jar {
Expand Down
7 changes: 0 additions & 7 deletions NeoForge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ tasks.withType<ProcessResources> {
inputs.files(it.sourceSets.main.get().resources)
from(it.sourceSets.main.get().resources)
}

// this will ensure that this task is redone when the properties change.
inputs.properties(resourceProperties)

filesMatching("META-INF/neoforge.mods.toml") {
expand(resourceProperties)
}
}

java {
Expand Down
32 changes: 31 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ spotless {
}

subprojects {
version = stringVersion
//adds the build number to the end of the version string if on a build server
var buildNumber = project.findProperty("BUILD_NUMBER")
if (buildNumber == null) {
buildNumber = "9999"
}
version = "${specificationVersion}.${buildNumber}"
group = modGroup

tasks.withType<Javadoc> {
Expand Down Expand Up @@ -120,6 +125,31 @@ subprojects {
}
}

tasks.withType<ProcessResources> {
val properties = mapOf(
"curseHomepageUrl" to curseHomepageUrl,
"fabricApiVersion" to fabricApiVersion,
"fabricLoaderVersion" to fabricLoaderVersion,
"forgeVersionRange" to forgeVersionRange,
"githubUrl" to githubUrl,
"forgeLoaderVersionRange" to forgeLoaderVersionRange,
"neoforgeVersionRange" to neoforgeVersionRange,
"neoforgeLoaderVersionRange" to neoforgeLoaderVersionRange,
"minecraftVersion" to minecraftVersion,
"minecraftVersionRange" to minecraftVersionRange,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"modId" to modId,
"modJavaVersion" to modJavaVersion,
"modName" to modName,
"version" to version,
)
inputs.properties(properties)
filesMatching(listOf("META-INF/mods.toml", "META-INF/neoforge.mods.toml", "pack.mcmeta", "fabric.mod.json")) {
expand(properties)
}
}

// Activate reproducible builds
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
tasks.withType<AbstractArchiveTask>().configureEach {
Expand Down

0 comments on commit b3d6dfb

Please sign in to comment.