From f636b1ad962e909597fe949b86d722f0d694d1ae Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 13 Oct 2021 22:08:53 +0800 Subject: [PATCH] Switch to gradle components --- fabric/build.gradle | 53 +++++++++++++++++++------------------ forge/build.gradle | 53 +++++++++++++++++++------------------ testmod-fabric/build.gradle | 21 +++++++-------- testmod-forge/build.gradle | 21 +++++++-------- 4 files changed, 72 insertions(+), 76 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index b1ee45af..1ae4b8f9 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -7,8 +7,17 @@ loom { accessWidenerPath = file("src/main/resources/architectury.accessWidener") } +architectury { + platformSetupLoomIde() + fabric() +} + configurations { - shadowCommon + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common dev } @@ -16,11 +25,6 @@ artifacts { dev(jar) } -architectury { - platformSetupLoomIde() - fabric() -} - repositories { maven { url "https://maven.terraformersmc.com/releases/" } } @@ -30,15 +34,8 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" modCompileOnly("com.terraformersmc:modmenu:${rootProject.mod_menu_version}") { transitive false } - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentFabric(project(path: ":common", configuration: "dev")) { - transitive = false - } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } } processResources { @@ -50,13 +47,17 @@ processResources { shadowJar { configurations = [project.configurations.shadowCommon] - classifier "shadow" + classifier "dev-shadow" } remapJar { - dependsOn(shadowJar) - input.set(shadowJar.archiveFile) - archiveClassifier = "fabric" + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" } sourcesJar { @@ -71,17 +72,17 @@ sourcesJar { } } +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + publishing { publications { mavenFabric(MavenPublication) { artifactId = rootProject.archivesBaseName + "-fabric" - artifact(remapJar) { classifier null } - afterEvaluate { - artifact(remapSourcesJar.output) { - builtBy remapSourcesJar - classifier "sources" - } - } + from components.java } } diff --git a/forge/build.gradle b/forge/build.gradle index 2a4d0dcd..b53619e5 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -10,8 +10,17 @@ loom { } } +architectury { + platformSetupLoomIde() + forge() +} + configurations { - shadowCommon + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentForge.extendsFrom common dev } @@ -19,23 +28,11 @@ artifacts { dev(jar) } -architectury { - platformSetupLoomIde() - forge() -} - dependencies { forge "net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.forge_version}" - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentForge(project(path: ":common", configuration: "dev")) { - transitive = false - } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } } processResources { @@ -50,13 +47,17 @@ shadowJar { exclude "architectury-common.accessWidener" configurations = [project.configurations.shadowCommon] - classifier "shadow" + classifier "dev-shadow" } remapJar { - dependsOn(shadowJar) - input.set(shadowJar.archivePath) - archiveClassifier = "forge" + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" } sourcesJar { @@ -71,17 +72,17 @@ sourcesJar { } } +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + publishing { publications { mavenForge(MavenPublication) { artifactId = rootProject.archivesBaseName + "-forge" - artifact(remapJar) { classifier null } - afterEvaluate { - artifact(remapSourcesJar.output) { - builtBy remapSourcesJar - classifier "sources" - } - } + from components.java } } diff --git a/testmod-fabric/build.gradle b/testmod-fabric/build.gradle index 79a5813b..5179c899 100644 --- a/testmod-fabric/build.gradle +++ b/testmod-fabric/build.gradle @@ -12,21 +12,18 @@ architectury { fabric() } +configurations { + common + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common +} + dependencies { modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" implementation project(path: ":fabric", configuration: "dev") - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentFabric(project(path: ":common", configuration: "dev")) { - transitive = false - } - implementation(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } - developmentFabric(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive = false } + common(project(path: ":testmod-common", configuration: "dev")) { transitive false } } diff --git a/testmod-forge/build.gradle b/testmod-forge/build.gradle index d71a7742..8b0fa5d0 100644 --- a/testmod-forge/build.gradle +++ b/testmod-forge/build.gradle @@ -20,20 +20,17 @@ architectury { forge() } +configurations { + common + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentForge.extendsFrom common +} + dependencies { forge "net.minecraftforge:forge:${gradle.rootProject.architectury.minecraft}-${rootProject.forge_version}" implementation project(path: ":forge", configuration: "dev") - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentForge(project(path: ":common", configuration: "dev")) { - transitive = false - } - implementation(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } - developmentForge(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive false } + common(project(path: ":testmod-common", configuration: "dev")) { transitive false } }