summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaint_Ninja <PaintNinja@users.noreply.github.com>2023-06-27 12:56:42 +0100
committerGitHub <noreply@github.com>2023-06-27 13:56:42 +0200
commit9b6e4991b6ccf8bd15d3106083c83854765db234 (patch)
tree9b9cf404cba8e497cbedc84768cb94ea94bedd35
parent773c579dab4a64bc30053cb84c9d1d943b337e19 (diff)
Lazily configure MDK tasks, improve IDE support (#9592)
-rw-r--r--build.gradle53
1 files changed, 27 insertions, 26 deletions
diff --git a/build.gradle b/build.gradle
index 6da6a06..0995112 100644
--- a/build.gradle
+++ b/build.gradle
@@ -182,47 +182,48 @@ dependencies {
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
-def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta']
-def replaceProperties = [
- minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
- forge_version: forge_version, forge_version_range: forge_version_range,
- loader_version_range: loader_version_range,
- mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
- mod_authors: mod_authors, mod_description: mod_description
-]
-processResources {
+tasks.named('processResources', ProcessResources).configure {
+ var replaceProperties = [
+ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
+ forge_version: forge_version, forge_version_range: forge_version_range,
+ loader_version_range: loader_version_range,
+ mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
+ mod_authors: mod_authors, mod_description: mod_description,
+ ]
inputs.properties replaceProperties
- replaceProperties.put 'project', project
- filesMatching(resourceTargets) {
- expand replaceProperties
+ filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
+ expand replaceProperties + [project: project]
}
}
// Example for how to get properties into the manifest for reading at runtime.
-jar {
+tasks.named('jar', Jar).configure {
manifest {
attributes([
- "Specification-Title" : mod_id,
- "Specification-Vendor" : mod_authors,
- "Specification-Version" : "1", // We are version 1 of ourselves
- "Implementation-Title" : project.name,
- "Implementation-Version" : project.jar.archiveVersion,
- "Implementation-Vendor" : mod_authors,
- "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
+ 'Specification-Title' : mod_id,
+ 'Specification-Vendor' : mod_authors,
+ 'Specification-Version' : '1', // We are version 1 of ourselves
+ 'Implementation-Title' : project.name,
+ 'Implementation-Version' : project.jar.archiveVersion,
+ 'Implementation-Vendor' : mod_authors,
+ 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
+
+ // This is the preferred method to reobfuscate your jar file
+ finalizedBy 'reobfJar'
}
-// Example configuration to allow publishing using the maven-publish plugin
-// This is the preferred method to reobfuscate your jar file
-jar.finalizedBy('reobfJar')
-// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
-// publish.dependsOn('reobfJar')
+// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
+// tasks.named('publish').configure {
+// dependsOn 'reobfJar'
+// }
+// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
- mavenJava(MavenPublication) {
+ register('mavenJava', MavenPublication) {
artifact jar
}
}