Skip to content

Commit

Permalink
Fix inclusion of common project in loader projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Erdragh committed Jun 18, 2024
1 parent 5f4981b commit 3980602
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
15 changes: 11 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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>("shadowJar")).forEach {
it { from(project(":common").sourceSets.main.get().output) }
}

tasks.named<ShadowJar>("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")

Expand All @@ -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/**")

Expand Down
13 changes: 0 additions & 13 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ loom {
}

tasks {
withType<JavaCompile> {
source(project(":common").sourceSets.main.get().allSource)
}
withType<KotlinCompile> {
source(project(":common").sourceSets.main.get().allSource)
}

javadoc { source(project(":common").sourceSets.main.get().allJava) }

jar {
archiveClassifier.set("dev")
}
Expand All @@ -84,10 +75,6 @@ tasks {
inputFile.set(named<ShadowJar>("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 {
Expand Down
20 changes: 7 additions & 13 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Task> = Spec { !it.name.startsWith("neo") }

tasks {
withType<JavaCompile>().matching(notNeoTask).configureEach { source(project(":common").sourceSets.main.get().allSource) }
withType<KotlinCompile>().matching(notNeoTask).configureEach {
source(project(":common").sourceSets.main.get().allSource)
}

withType<Javadoc>().matching(notNeoTask).configureEach { source(project(":common").sourceSets.main.get().allJava) }

shadowJar {
archiveClassifier = null
}
Expand All @@ -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 {
Expand Down

0 comments on commit 3980602

Please sign in to comment.