diff --git a/buildSrc/src/main/kotlin/multiloader-platform.gradle.kts b/buildSrc/src/main/kotlin/multiloader-platform.gradle.kts index 3e65fd82fa..94da445d40 100644 --- a/buildSrc/src/main/kotlin/multiloader-platform.gradle.kts +++ b/buildSrc/src/main/kotlin/multiloader-platform.gradle.kts @@ -3,12 +3,12 @@ plugins { id("maven-publish") } -val configurationDesktopIntegration: Configuration = configurations.create("commonDesktopIntegration") { +val configurationDesktopIntegrationJava: Configuration = configurations.create("commonDesktopIntegration") { isCanBeResolved = true } dependencies { - configurationDesktopIntegration(project(path = ":common", configuration = "commonDesktop")) + configurationDesktopIntegrationJava(project(path = ":common", configuration = "commonDesktopJava")) } tasks { @@ -25,8 +25,7 @@ tasks { from(rootDir.resolve("LICENSE.md")) // Entry-point for desktop integration when the file is executed directly - dependsOn(configurationDesktopIntegration) - from(configurationDesktopIntegration.map { zipTree(it) }) + from(configurationDesktopIntegrationJava) manifest.attributes["Main-Class"] = "net.caffeinemc.mods.sodium.desktop.LaunchWarn" } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 507da1060e..dd30605417 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -72,21 +72,38 @@ loom { } } -// Exports the compiled output of the source set to the named configuration. -fun exportSourceSet(name: String, sourceSet: SourceSet) { - configurations.create(name) { +fun exportSourceSetJava(name: String, sourceSet: SourceSet) { + val configuration = configurations.create("${name}Java") { isCanBeResolved = true isCanBeConsumed = true } - val jarTask = tasks.create("${name}Jar") { - destinationDirectory.set(layout.buildDirectory.dir("devlibs/${name}")) + val compileTask = tasks.getByName(sourceSet.compileJavaTaskName) + artifacts.add(configuration.name, compileTask.destinationDirectory) { + builtBy(compileTask) + } +} - from(sourceSet.output) +fun exportSourceSetResources(name: String, sourceSet: SourceSet) { + val configuration = configurations.create("${name}Resources") { + isCanBeResolved = true + isCanBeConsumed = true + } + + val compileTask = tasks.getByName(sourceSet.processResourcesTaskName) + compileTask.apply { exclude("/*.accesswidener") } - artifacts.add(name, jarTask) + artifacts.add(configuration.name, compileTask.destinationDir) { + builtBy(compileTask) + } +} + +// Exports the compiled output of the source set to the named configuration. +fun exportSourceSet(name: String, sourceSet: SourceSet) { + exportSourceSetJava(name, sourceSet) + exportSourceSetResources(name, sourceSet) } exportSourceSet("commonMain", sourceSets["main"]) diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 112fce3337..a92e58f953 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -8,20 +8,27 @@ base { archivesName = "sodium-fabric" } -val configurationCommon: Configuration = configurations.create("common") { +val configurationCommonModJava: Configuration = configurations.create("commonJava") { + isCanBeResolved = true +} +val configurationCommonModResources: Configuration = configurations.create("commonResources") { isCanBeResolved = true } dependencies { - configurationCommon(project(path = ":common", configuration = "commonMain")) - configurationCommon(project(path = ":common", configuration = "commonApi")) - configurationCommon(project(path = ":common", configuration = "commonEarlyLaunch")) + configurationCommonModJava(project(path = ":common", configuration = "commonMainJava")) + configurationCommonModJava(project(path = ":common", configuration = "commonApiJava")) + configurationCommonModJava(project(path = ":common", configuration = "commonEarlyLaunchJava")) + + configurationCommonModResources(project(path = ":common", configuration = "commonMainResources")) + configurationCommonModResources(project(path = ":common", configuration = "commonApiResources")) + configurationCommonModResources(project(path = ":common", configuration = "commonEarlyLaunchResources")) } sourceSets.apply { main { - compileClasspath += configurationCommon - runtimeClasspath += configurationCommon + compileClasspath += configurationCommonModJava + runtimeClasspath += configurationCommonModJava } } @@ -72,7 +79,10 @@ loom { tasks { jar { - dependsOn(configurationCommon) - from(configurationCommon.map { zipTree(it) }) + from(configurationCommonModJava) + } + + processResources { + from(configurationCommonModResources) } } \ No newline at end of file diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index a9feca3159..cb01e26d1c 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -25,19 +25,28 @@ sourceSets { create("service") } -val configurationCommonMod: Configuration = configurations.create("commonMod") { +val configurationCommonModJava: Configuration = configurations.create("commonModJava") { + isCanBeResolved = true +} +val configurationCommonModResources: Configuration = configurations.create("commonModResources") { isCanBeResolved = true } -val configurationCommonEarly: Configuration = configurations.create("commonEarly") { +val configurationCommonServiceJava: Configuration = configurations.create("commonServiceJava") { + isCanBeResolved = true +} +val configurationCommonServiceResources: Configuration = configurations.create("commonServiceResources") { isCanBeResolved = true } dependencies { - configurationCommonMod(project(path = ":common", configuration = "commonMain")) - configurationCommonMod(project(path = ":common", configuration = "commonApi")) + configurationCommonModJava(project(path = ":common", configuration = "commonMainJava")) + configurationCommonModJava(project(path = ":common", configuration = "commonApiJava")) + configurationCommonServiceJava(project(path = ":common", configuration = "commonEarlyLaunchJava")) - configurationCommonEarly(project(path = ":common", configuration = "commonEarlyLaunch")) + configurationCommonModResources(project(path = ":common", configuration = "commonMainResources")) + configurationCommonModResources(project(path = ":common", configuration = "commonApiResources")) + configurationCommonServiceResources(project(path = ":common", configuration = "commonEarlyLaunchResources")) fun addEmbeddedFabricModule(dependency: String) { dependencies.implementation(dependency) @@ -53,8 +62,8 @@ dependencies { } val serviceJar = tasks.create("serviceJar") { - dependsOn(configurationCommonEarly) - from(configurationCommonEarly.map { zipTree(it) }) + from(configurationCommonServiceJava) + from(configurationCommonServiceResources) from(sourceSets["service"].output) @@ -79,13 +88,13 @@ sourceSets { compileClasspath = sourceSets["main"].compileClasspath runtimeClasspath = sourceSets["main"].runtimeClasspath - compileClasspath += configurationCommonEarly - runtimeClasspath += configurationCommonEarly + compileClasspath += configurationCommonServiceJava + runtimeClasspath += configurationCommonServiceJava } main { - compileClasspath += configurationCommonMod - runtimeClasspath += configurationCommonMod + compileClasspath += configurationCommonModJava + runtimeClasspath += configurationCommonModJava } } @@ -122,7 +131,10 @@ neoForge { tasks { jar { - dependsOn(configurationCommonMod) - from(configurationCommonMod.map { zipTree(it) }) + from(configurationCommonModJava) + } + + processResources { + from(configurationCommonModResources) } } \ No newline at end of file