Skip to content

Commit

Permalink
Further buildscript cleanup (processResources props) + Gradle 8.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jul 31, 2023
1 parent 666cda9 commit 5c0d79e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 46 deletions.
61 changes: 23 additions & 38 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

import com.diffplug.gradle.spotless.SpotlessExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

import net.fabricmc.loom.api.LoomGradleExtensionAPI
import net.fabricmc.loom.task.RemapJarTask

import dev.architectury.plugin.ArchitectPluginExtension

import me.shedaniel.unifiedpublishing.UnifiedPublishingExtension

plugins {
java
`maven-publish`
id("architectury-plugin") version "3.4-SNAPSHOT" apply false
id("dev.architectury.loom") version "1.2-SNAPSHOT" apply false
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
id("me.shedaniel.unified-publishing") version "0.1.+" apply false
id("com.diffplug.spotless") version "6.4.1" apply false
id("dev.architectury.loom") version "1.3-SNAPSHOT" apply false
id("architectury-plugin") version "3.4-SNAPSHOT"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("me.shedaniel.unified-publishing") version "0.1.+"
id("com.diffplug.spotless") version "6.20.0"
}

val modId: String by project
val minecraftVersion: String by project
val javaVersion: String by project

val platforms by extra {
property("enabledPlatforms").toString().split(',')
Expand All @@ -33,7 +21,7 @@ val platforms by extra {
fun capitalise(str: String): String {
return str.replaceFirstChar {
if (it.isLowerCase()) {
it.titlecase(Locale.getDefault())
it.titlecase()
} else {
it.toString()
}
Expand Down Expand Up @@ -67,6 +55,8 @@ subprojects {
base.archivesName.set("$modId-${project.name}")
version = "${(System.getenv("MEGA_VERSION") ?: "v0.0.0").substring(1)}-$minecraftVersion"
group = "${property("mavenGroup")}.$modId"

val javaVersion: String by project

java {
sourceCompatibility = JavaVersion.valueOf("VERSION_$javaVersion")
Expand All @@ -75,7 +65,7 @@ subprojects {
withSourcesJar()
}

configure<ArchitectPluginExtension> {
architectury {
minecraft = minecraftVersion
injectInjectables = false
}
Expand Down Expand Up @@ -131,18 +121,6 @@ subprojects {
from(rootProject.file("LICENSE")) {
rename { "${it}_$modId"}
}

manifest {
attributes(
"Specification-Title" to modId,
"Specification-Version" to project.version.toString(),
"Specification-Vendor" to "90",
"Implementation-Title" to base.archivesName.get(),
"Implementation-Version" to project.version.toString(),
"Implementation-Vendor" to "90",
"Implementation-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date())
)
}
}

withType<JavaCompile> {
Expand All @@ -151,7 +129,7 @@ subprojects {
}
}

configure<SpotlessExtension> {
spotless {
java {
target("src/**/java/**/*.java")
endWithNewline()
Expand Down Expand Up @@ -204,7 +182,7 @@ for (platform in platforms) {
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "me.shedaniel.unified-publishing")

configure<ArchitectPluginExtension> {
architectury {
platformSetupLoomIde()
loader(platform)
}
Expand Down Expand Up @@ -234,18 +212,25 @@ for (platform in platforms) {

tasks {
processResources {
extra["commonProps"] = mapOf("version" to project.version) + project.properties
val commonProps by extra { mapOf(
"version" to project.version,
"minecraftVersion" to minecraftVersion,
"ae2Version" to project.extra.get("ae2Version"),
"ae2wtVersion" to project.extra.get("ae2wtVersion"),
"appbotVersion" to project.extra.get("appbotVersion"))
}

inputs.properties(commonProps)
}

withType<ShadowJar> {
shadowJar {
exclude("architectury.common.json")
configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}

withType<RemapJarTask> {
val shadowJar: ShadowJar by project.tasks
inputFile.set(shadowJar.archiveFile)
inputFile.set(shadowJar.get().archiveFile)
dependsOn(shadowJar)
archiveClassifier.set(null as String?)
}
Expand All @@ -267,7 +252,7 @@ for (platform in platforms) {
}

if (project.version != "0.0.0") {
configure<UnifiedPublishingExtension> {
unifiedPublishing {
project {
val modVersion = project.version.toString()

Expand Down
1 change: 0 additions & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

"depends": {
"minecraft": "$minecraftVersion",
"java": ">=$javaVersion",
"ae2": ">=$ae2Version"
},
"suggests": {
Expand Down
16 changes: 11 additions & 5 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ dependencies {
}

tasks.processResources {
val commonProps: Map<String, *> by extra
val forgeProps = mapOf(
"appmekVersion" to project.extra.get("appmekVersion"),
"loaderVersion" to forgeVersion.substringBefore('.'),
"ae2VersionEnd" to ae2Version.substringBefore('.').toInt() + 1
)

inputs.properties(commonProps)
inputs.properties(forgeProps)

filesMatching("META-INF/mods.toml") {
val commonProps: Map<String, *> by extra
expand(commonProps + mapOf(
"loaderVersion" to forgeVersion.substringBefore('.'),
"ae2VersionEnd" to ae2Version.substringBefore('.').toInt() + 1
))
expand(commonProps + forgeProps)
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down

0 comments on commit 5c0d79e

Please sign in to comment.