Skip to content

Commit

Permalink
Cleanup buildscripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Sep 19, 2024
1 parent 08cd053 commit a22f53a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 71 deletions.
76 changes: 23 additions & 53 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ repositories {
}

// SpongeForge libraries
val serviceLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeServiceLibraries")
val gameLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeGameLibraries")
val serviceLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("serviceLibraries")
val gameLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("gameLibraries")

val gameManagedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeGameManagedLibraries")
val gameManagedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("gameManagedLibraries")

val serviceShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeServiceShadedLibraries")
val gameShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeGameShadedLibraries")
val serviceShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("serviceShadedLibraries")
val gameShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("gameShadedLibraries")

val runTaskOnlyConfig: NamedDomainObjectProvider<Configuration> = configurations.register("runTaskOnly")

Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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)

Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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"))

Expand All @@ -458,6 +443,9 @@ publishing {
artifact(tasks["jar"])
artifact(tasks["sourcesJar"])

artifact(tasks["forgeLangJar"])
artifact(tasks["langSourcesJar"])

artifact(tasks["forgeMixinsJar"])
artifact(tasks["mixinsSourcesJar"])

Expand Down Expand Up @@ -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)
}
}
}
42 changes: 24 additions & 18 deletions vanilla/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ description = "The SpongeAPI implementation for Vanilla Minecraft"
version = spongeImpl.generatePlatformBuildVersionString(apiVersion, minecraftVersion, recommendedVersion)

// SpongeVanilla libraries
val installerLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeInstallerLibraries")
val initLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeInitLibraries") // JVM initial classpath
val bootLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeBootLibraries")
val gameLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeGameLibraries") {
val installerLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("installerLibraries")
val initLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("initLibraries") // JVM initial classpath
val bootLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("bootLibraries")
val gameLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("gameLibraries") {
extendsFrom(configurations.minecraft.get())
}

val gameManagedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeGameManagedLibraries")
val gameManagedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("gameManagedLibraries")

val bootShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeBootShadedLibraries")
val gameShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("spongeGameShadedLibraries")
val bootShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("bootShadedLibraries")
val gameShadedLibrariesConfig: NamedDomainObjectProvider<Configuration> = configurations.register("gameShadedLibraries")

val runTaskOnlyConfig: NamedDomainObjectProvider<Configuration> = configurations.register("runTaskOnly")

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a22f53a

Please sign in to comment.