From a22f53a882fc92d7a2fa81314e627b9d9c86e404 Mon Sep 17 00:00:00 2001 From: Yeregorix Date: Tue, 3 Sep 2024 00:00:14 +0200 Subject: [PATCH] Cleanup buildscripts --- forge/build.gradle.kts | 76 ++++++++++++---------------------------- vanilla/build.gradle.kts | 42 ++++++++++++---------- 2 files changed, 47 insertions(+), 71 deletions(-) diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index e3c75af6d4c..45e64e85bfb 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -38,13 +38,13 @@ repositories { } // SpongeForge libraries -val serviceLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeServiceLibraries") -val gameLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeGameLibraries") +val serviceLibrariesConfig: NamedDomainObjectProvider = configurations.register("serviceLibraries") +val gameLibrariesConfig: NamedDomainObjectProvider = configurations.register("gameLibraries") -val gameManagedLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeGameManagedLibraries") +val gameManagedLibrariesConfig: NamedDomainObjectProvider = configurations.register("gameManagedLibraries") -val serviceShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeServiceShadedLibraries") -val gameShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeGameShadedLibraries") +val serviceShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("serviceShadedLibraries") +val gameShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("gameShadedLibraries") val runTaskOnlyConfig: NamedDomainObjectProvider = configurations.register("runTaskOnly") @@ -206,27 +206,27 @@ dependencies { forgeMixins.implementationConfigurationName(project(commonProject.path)) - val serviceLibraries = serviceLibrariesConfig.name - serviceLibraries(apiLibs.pluginSpi) - serviceLibraries(project(transformersProject.path)) - serviceLibraries(platform(apiLibs.configurate.bom)) - serviceLibraries(apiLibs.configurate.core) { + val service = serviceLibrariesConfig.name + service(apiLibs.pluginSpi) + service(project(transformersProject.path)) + service(platform(apiLibs.configurate.bom)) + service(apiLibs.configurate.core) { exclude(group = "org.checkerframework", module = "checker-qual") } - serviceLibraries(apiLibs.configurate.hocon) { + service(apiLibs.configurate.hocon) { exclude(group = "org.spongepowered", module = "configurate-core") exclude(group = "org.checkerframework", module = "checker-qual") } - serviceLibraries(libs.configurate.jackson) { + service(libs.configurate.jackson) { exclude(group = "org.spongepowered", module = "configurate-core") exclude(group = "org.checkerframework", module = "checker-qual") } - val gameLibraries = gameLibrariesConfig.name - gameLibraries("org.spongepowered:spongeapi:$apiVersion") - gameLibraries(libs.javaxInject) - gameLibraries(platform(apiLibs.adventure.bom)) - gameLibraries(libs.adventure.serializerConfigurate4) + val game = gameLibrariesConfig.name + game("org.spongepowered:spongeapi:$apiVersion") + game(libs.javaxInject) + game(platform(apiLibs.adventure.bom)) + game(libs.adventure.serializerConfigurate4) val serviceShadedLibraries = serviceShadedLibrariesConfig.name serviceShadedLibraries(project(transformersProject.path)) { isTransitive = false } @@ -293,7 +293,7 @@ tasks { from(forgeLang.output) } - val forgeServicesDevJar by registering(Jar::class) { + val forgeServicesJar by registering(Jar::class) { archiveClassifier.set("services") manifest.from(forgeManifest) @@ -308,7 +308,7 @@ tasks { // Default classpath is a mess, we better start a new one from scratch classpath = files( configurations.getByName("forgeRuntimeLibrary"), - forgeServicesDevJar, forgeLangJar, runTaskOnlyConfig + forgeServicesJar, forgeLangJar, runTaskOnlyConfig ) testPluginsProject?.also { @@ -327,7 +327,7 @@ tasks { .toList() } - jvmArguments.add("-Dbsl.debug=true") // Uncomment to debug bootstrap classpath + // jvmArguments.add("-Dbsl.debug=true") // Uncomment to debug bootstrap classpath sourceSets.forEach { dependsOn(it.classesTaskName) @@ -427,21 +427,6 @@ sourceSets { } } -afterEvaluate { - sourceSets.configureEach { - // Don't apply Mixin AP - configurations.named(annotationProcessorConfigurationName) { - exclude(group = "org.spongepowered", module = "mixin") - exclude(group = "net.fabricmc", module = "fabric-mixin-compile-extensions") - } - // And don't pass AP parameters - tasks.named(compileJavaTaskName, JavaCompile::class) { - val mixinApArgs = setOf("outRefMapFile", "defaultObfuscationEnv", "outMapFileNamedIntermediary", "inMapFileNamedIntermediary") - options.compilerArgs.removeIf { mixinApArgs.any { mixin -> it.contains(mixin)} } - } - } -} - indraSpotlessLicenser { licenseHeaderFile(rootProject.file("HEADER.txt")) @@ -458,6 +443,9 @@ publishing { artifact(tasks["jar"]) artifact(tasks["sourcesJar"]) + artifact(tasks["forgeLangJar"]) + artifact(tasks["langSourcesJar"]) + artifact(tasks["forgeMixinsJar"]) artifact(tasks["mixinsSourcesJar"]) @@ -491,21 +479,3 @@ publishing { } } } - -tasks.register("printRunTasks") { - group = "debug" - doLast { - tasks.withType(net.fabricmc.loom.task.AbstractRunTask::class) { - println() - println("Task ${this.name}:") - println("mainClass: " + this.mainClass.orNull) - println("mainModule: " + this.mainModule.orNull) - println("allJvmArgs: " + this.allJvmArgs) - println("jvmArgs: " + this.jvmArgs) - println("args: " + this.args) - println("commandLine: " + this.commandLine) - println("environment: " + this.environment) - println("classpath: " + this.classpath.files) - } - } -} diff --git a/vanilla/build.gradle.kts b/vanilla/build.gradle.kts index 8352b028903..524906a28a6 100644 --- a/vanilla/build.gradle.kts +++ b/vanilla/build.gradle.kts @@ -23,17 +23,17 @@ description = "The SpongeAPI implementation for Vanilla Minecraft" version = spongeImpl.generatePlatformBuildVersionString(apiVersion, minecraftVersion, recommendedVersion) // SpongeVanilla libraries -val installerLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeInstallerLibraries") -val initLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeInitLibraries") // JVM initial classpath -val bootLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeBootLibraries") -val gameLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeGameLibraries") { +val installerLibrariesConfig: NamedDomainObjectProvider = configurations.register("installerLibraries") +val initLibrariesConfig: NamedDomainObjectProvider = configurations.register("initLibraries") // JVM initial classpath +val bootLibrariesConfig: NamedDomainObjectProvider = configurations.register("bootLibraries") +val gameLibrariesConfig: NamedDomainObjectProvider = configurations.register("gameLibraries") { extendsFrom(configurations.minecraft.get()) } -val gameManagedLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeGameManagedLibraries") +val gameManagedLibrariesConfig: NamedDomainObjectProvider = configurations.register("gameManagedLibraries") -val bootShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeBootShadedLibraries") -val gameShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("spongeGameShadedLibraries") +val bootShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("bootShadedLibraries") +val gameShadedLibrariesConfig: NamedDomainObjectProvider = configurations.register("gameShadedLibraries") val runTaskOnlyConfig: NamedDomainObjectProvider = configurations.register("runTaskOnly") @@ -159,7 +159,7 @@ minecraft { ) // ModLauncher - jvmArgs("-Dbsl.debug=true") // Uncomment to debug bootstrap classpath + // jvmArgs("-Dbsl.debug=true") // Uncomment to debug bootstrap classpath mainClass("net.minecraftforge.bootstrap.ForgeBootstrap") allArgumentProviders += CommandLineArgumentProvider { @@ -270,7 +270,6 @@ dependencies { } boot(apiLibs.pluginSpi) { exclude(group = "org.checkerframework", module = "checker-qual") - // exclude(group = "com.google.code.gson", module = "gson") exclude(group = "org.apache.logging.log4j", module = "log4j-api") } boot(libs.lmaxDisruptor) @@ -546,19 +545,26 @@ val vanillaMixinsJar by tasks.existing publishing { publications { register("sponge", MavenPublication::class) { + artifact(tasks["universalJar"]) - artifact(universalJar.get()) - artifact(vanillaInstallerJar.get()) - artifact(vanillaAppLaunchJar.get()) - artifact(vanillaLaunchJar.get()) - artifact(vanillaAccessorsJar.get()) - artifact(vanillaMixinsJar.get()) + artifact(tasks["jar"]) + artifact(tasks["sourcesJar"]) - artifact(tasks["applaunchSourcesJar"]) - artifact(tasks["launchSourcesJar"]) - artifact(tasks["accessorsSourcesJar"]) + artifact(tasks["vanillaInstallerJar"]) + artifact(tasks["installerSourcesJar"]) + + artifact(tasks["vanillaMixinsJar"]) artifact(tasks["mixinsSourcesJar"]) + artifact(tasks["vanillaAccessorsJar"]) + artifact(tasks["accessorsSourcesJar"]) + + artifact(tasks["vanillaLaunchJar"]) + artifact(tasks["launchSourcesJar"]) + + artifact(tasks["vanillaAppLaunchJar"]) + artifact(tasks["applaunchSourcesJar"]) + pom { artifactId = project.name.lowercase() this.name.set(project.name)