diff --git a/build.gradle.kts b/build.gradle.kts index 637041b..ee240f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -217,18 +217,25 @@ subprojects { apply(plugin = "io.github.goooler.shadow") dependencies { - implementation(project(":common")) + // This is runtimeLib, because NG doesn't add the common classes to the runtime classpath correctly + runtimeLib(project(":common")) { + isTransitive = false + } + } + + // Include common classes in jar and shadowJar output + listOf(tasks.jar, tasks.named("shadowJar")).forEach { + it { from(project(":common").sourceSets.main.get().output) } } tasks.named("shadowJar") { // The shadowBotDep configuration was explicitly made to be shaded in, this is where that happens - configurations.clear() configurations = listOf(shadowBotDep) // This transforms the service files to make relocated Exposed work (see: https://github.com/JetBrains/Exposed/issues/1353) mergeServiceFiles() - // Forge restricts loading certain classes for security reasons. + // (Neo-)Forge restricts loading certain classes for security reasons. // Luckily, shadow can relocate them to a different package. relocate("org.apache.commons.collections4", "dev.erdragh.shadowed.org.apache.commons.collections4") @@ -249,7 +256,7 @@ subprojects { relocate("com.iwebpp.crypto", "dev.erdragh.shadowed.com.iwebpp.crypto") relocate("com.neovisionaries.ws", "dev.erdragh.shadowed.com.neovisionaries.ws") relocate("org.json", "dev.erdragh.shadowed.org.json") - relocate("net.bytebuddy", "dev.erdragh.net.bytebuddy") + relocate("net.bytebuddy", "dev.erdragh.shadowed.net.bytebuddy") exclude("**/org/slf4j/**") diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index c0e42bc..8362dcd 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -63,15 +63,6 @@ loom { } tasks { - withType { - source(project(":common").sourceSets.main.get().allSource) - } - withType { - source(project(":common").sourceSets.main.get().allSource) - } - - javadoc { source(project(":common").sourceSets.main.get().allJava) } - jar { archiveClassifier.set("dev") } @@ -84,10 +75,6 @@ tasks { inputFile.set(named("shadowJar").get().archiveFile) dependsOn("shadowJar") } - - named("sourcesJar", Jar::class) { from(project(":common").sourceSets.main.get().allSource) } - - processResources { from(project(":common").sourceSets.main.get().resources) } } publishing { diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index a7a83eb..837f7fb 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -79,17 +79,7 @@ dependencies { includeBotDep.dependencies.forEach { jarJar(it) } } -// NeoGradle compiles the game, but we don't want to add our common code to the game's code -val notNeoTask: Spec = Spec { !it.name.startsWith("neo") } - tasks { - withType().matching(notNeoTask).configureEach { source(project(":common").sourceSets.main.get().allSource) } - withType().matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.get().allSource) - } - - withType().matching(notNeoTask).configureEach { source(project(":common").sourceSets.main.get().allJava) } - shadowJar { archiveClassifier = null } @@ -98,9 +88,13 @@ tasks { dependsOn(shadowJar) } - named("sourcesJar", Jar::class) { from(project(":common").sourceSets.main.get().allSource) } - - processResources { from(project(":common").sourceSets.main.get().resources) } + // Fixes IDE runs not processing common resources + processResources { + from(project(":common").sourceSets.main.get().resources) + } + jar { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } } publishing {