improve addon dependency system

This commit is contained in:
dfsek
2022-04-29 23:03:18 -07:00
parent d2795bfdb6
commit 4396623420
40 changed files with 104 additions and 102 deletions
+11 -1
View File
@@ -1,3 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
preRelease(true) preRelease(true)
versionProjects(":common:api", version("6.0.0")) versionProjects(":common:api", version("6.0.0"))
@@ -43,11 +45,19 @@ afterEvaluate {
configureDistribution() configureDistribution()
} }
forSubProjects(":common:addons") { forSubProjects(":common:addons") {
apply(plugin = "com.github.johnrengelman.shadow")
dependencies { dependencies {
"compileOnly"(project(":common:api")) "compileOnly"(project(":common:api"))
"shadedImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama) "implementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
"testImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama) "testImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
"testImplementation"(project(":common:api")) "testImplementation"(project(":common:api"))
} }
val libPackage = "com.dfsek.terra.addons.${this.name.replace('-', '_')}.lib"
tasks.named<ShadowJar>("shadowJar") {
relocate("net.jafama", "$libPackage.jafama")
}
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
}
} }
} }
+1 -5
View File
@@ -21,11 +21,7 @@ fun Project.addonDir(dir: File, task: Task) {
it.delete() it.delete()
} }
forSubProjects(":common:addons") { forSubProjects(":common:addons") {
val jar = if (tasks.findByName("shadowJar") != null) { val jar = tasks.named("shadowJar").get() as ShadowJar
(tasks.named("shadowJar").get() as ShadowJar)
} else {
(tasks.named("jar").get() as Jar)
}
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else "" val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get()) val target = File(dir, boot + jar.archiveFileName.get())
@@ -6,25 +6,9 @@ import org.gradle.kotlin.dsl.getting
import org.gradle.kotlin.dsl.repositories import org.gradle.kotlin.dsl.repositories
fun Project.configureDependencies() { fun Project.configureDependencies() {
val api by configurations.getting
val implementation by configurations.getting
val testImplementation by configurations.getting val testImplementation by configurations.getting
val compileOnly by configurations.getting val compileOnly by configurations.getting
val shaded by configurations.creating
@Suppress("UNUSED_VARIABLE")
val shadedApi by configurations.creating {
shaded.extendsFrom(this)
api.extendsFrom(this)
}
@Suppress("UNUSED_VARIABLE")
val shadedImplementation by configurations.creating {
shaded.extendsFrom(this)
implementation.extendsFrom(this)
}
repositories { repositories {
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
@@ -122,14 +122,13 @@ fun Project.configureDistribution() {
// Tell shadow to download the packs // Tell shadow to download the packs
dependsOn(downloadDefaultPacks) dependsOn(downloadDefaultPacks)
configurations = listOf(project.configurations["shaded"])
archiveClassifier.set("shaded") archiveClassifier.set("shaded")
setVersion(project.version) setVersion(project.version)
relocate("org.apache.commons", "com.dfsek.terra.lib.commons") relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm") relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
relocate("org.json", "com.dfsek.terra.lib.json") relocate("org.json", "com.dfsek.terra.lib.json")
relocate("org.yaml", "com.dfsek.terra.lib.yaml") relocate("org.yaml", "com.dfsek.terra.lib.yaml")
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")
} }
configure<BasePluginExtension> { configure<BasePluginExtension> {
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
+1 -1
View File
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
+1 -1
View File
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
+1 -1
View File
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,17 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
version = version("0.1.0") version = version("0.1.0")
dependencies { plugins {
shadedApi(project(":common:addons:manifest-addon-loader")) id("com.github.johnrengelman.shadow")
} }
dependencies {
compileOnly(project(":common:addons:manifest-addon-loader"))
implementation("com.dfsek", "paralithic", Versions.Libraries.paralithic)
}
tasks.named<ShadowJar>("shadowJar") {
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.noise.lib.paralithic")
}
+1 -1
View File
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,6 +1,6 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi("com.googlecode.json-simple:json-simple:1.1.1") api("com.googlecode.json-simple:json-simple:1.1.1")
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
+2 -2
View File
@@ -1,6 +1,6 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}") implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,8 +1,8 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi("commons-io:commons-io:2.6") api("commons-io:commons-io:2.6")
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}") implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
} }
tasks.withType<Jar> { tasks.withType<Jar> {
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,5 +1,5 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
@@ -11,15 +11,11 @@ repositories {
} }
dependencies { dependencies {
shadedApi("commons-io:commons-io:2.6") api("commons-io:commons-io:2.7")
shadedApi("com.github.Querz:NBT:6.1") api("com.github.Querz:NBT:6.1")
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
tasks.named<ShadowJar>("shadowJar") { tasks.named<ShadowJar>("shadowJar") {
relocate("org.apache.commons", "com.dfsek.terra.addons.sponge.lib.commons") relocate("org.apache.commons", "com.dfsek.terra.addons.sponge.lib.commons")
} }
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
}
@@ -8,14 +8,10 @@ plugins {
} }
dependencies { dependencies {
shadedApi("commons-io:commons-io:2.6") api("commons-io:commons-io:2.7")
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
} }
tasks.named<ShadowJar>("shadowJar") { tasks.named<ShadowJar>("shadowJar") {
relocate("org.apache.commons", "com.dfsek.terra.addons.terrascript.lib.commons") relocate("org.apache.commons", "com.dfsek.terra.addons.terrascript.lib.commons")
}
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
} }
@@ -1,7 +1,7 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
shadedApi(project(":common:addons:chunk-generator-noise-3d")) api(project(":common:addons:chunk-generator-noise-3d"))
shadedApi(project(":common:addons:structure-terrascript-loader")) api(project(":common:addons:structure-terrascript-loader"))
} }
@@ -1,7 +1,7 @@
version = version("0.1.0") version = version("0.1.0")
dependencies { dependencies {
shadedApi(project(":common:addons:manifest-addon-loader")) compileOnly(project(":common:addons:manifest-addon-loader"))
shadedApi(project(":common:addons:config-noise-function")) api(project(":common:addons:config-noise-function"))
shadedApi(project(":common:addons:structure-terrascript-loader")) api(project(":common:addons:structure-terrascript-loader"))
} }
+5 -7
View File
@@ -1,11 +1,9 @@
dependencies { dependencies {
shadedApi("ca.solo-studios", "strata", Versions.Libraries.strata) compileOnlyApi("ca.solo-studios", "strata", Versions.Libraries.strata)
shadedApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j) compileOnlyApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
shadedApi("cloud.commandframework", "cloud-core", Versions.Libraries.cloud) compileOnlyApi("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
shadedApi("com.dfsek", "paralithic", Versions.Libraries.paralithic) compileOnlyApi("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
shadedApi("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
compileOnlyApi("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
} }
+17 -6
View File
@@ -1,13 +1,24 @@
dependencies { dependencies {
shadedApi(project(":common:api")) api(project(":common:api"))
shadedApi(project(":common:implementation:bootstrap-addon-loader")) api(project(":common:implementation:bootstrap-addon-loader"))
shadedImplementation("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO) implementation("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
implementation("org.apache.commons", "commons-text", Versions.Libraries.Internal.apacheText)
shadedImplementation("org.apache.commons", "commons-text", Versions.Libraries.Internal.apacheText) implementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic)
shadedImplementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic) implementation("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama) implementation("com.dfsek", "paralithic", Versions.Libraries.paralithic)
implementation("ca.solo-studios", "strata", Versions.Libraries.strata)
implementation("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
implementation("org.ow2.asm", "asm", Versions.Libraries.Internal.asm) implementation("org.ow2.asm", "asm", Versions.Libraries.Internal.asm)
testImplementation("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
} }
@@ -1,3 +1,3 @@
dependencies { dependencies {
"shadedApi"(project(":common:api")) "api"(project(":common:api"))
} }
+6 -6
View File
@@ -14,21 +14,21 @@ val paperURL = "https://papermc.io/api/v2/projects/paper/versions/%version%/buil
val purpurURL = "https://api.pl3x.net/v2/purpur/%version%/latest/download" val purpurURL = "https://api.pl3x.net/v2/purpur/%version%/latest/download"
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) api(project(":common:implementation:base"))
shadedApi("org.slf4j:slf4j-api:1.8.0-beta4") { api("org.slf4j:slf4j-api:1.8.0-beta4") {
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.") because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
} }
shadedImplementation("org.apache.logging.log4j", "log4j-slf4j18-impl", Versions.Libraries.log4j_slf4j_impl) { implementation("org.apache.logging.log4j", "log4j-slf4j18-impl", Versions.Libraries.log4j_slf4j_impl) {
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.") because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
} }
compileOnly("io.papermc.paper", "paper-api", Versions.Bukkit.paper) compileOnly("io.papermc.paper", "paper-api", Versions.Bukkit.paper)
shadedImplementation("io.papermc", "paperlib", Versions.Bukkit.paperLib) implementation("io.papermc", "paperlib", Versions.Bukkit.paperLib)
shadedApi("com.google.guava:guava:30.0-jre") api("com.google.guava:guava:30.0-jre")
shadedApi("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud) api("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
} }
val jvmFlags = listOf( val jvmFlags = listOf(
+6 -6
View File
@@ -3,15 +3,15 @@ repositories {
} }
dependencies { dependencies {
shadedApi("commons-io:commons-io:2.6") api("commons-io:commons-io:2.6")
shadedApi("com.github.Querz:NBT:6.1") api("com.github.Querz:NBT:6.1")
shadedApi(project(":common:implementation:base")) api(project(":common:implementation:base"))
shadedImplementation("com.google.guava:guava:31.0.1-jre") implementation("com.google.guava:guava:31.0.1-jre")
shadedImplementation("ch.qos.logback:logback-classic:1.2.7") implementation("ch.qos.logback:logback-classic:1.2.7")
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama) implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
} }
tasks.withType<Jar>() { tasks.withType<Jar>() {
+1 -1
View File
@@ -8,7 +8,7 @@ plugins {
} }
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) api(project(":common:implementation:base"))
minecraft("com.mojang:minecraft:${Versions.Fabric.minecraft}") minecraft("com.mojang:minecraft:${Versions.Fabric.minecraft}")
mappings("net.fabricmc:yarn:${Versions.Fabric.yarn}:v2") mappings("net.fabricmc:yarn:${Versions.Fabric.yarn}:v2")
+1 -1
View File
@@ -3,7 +3,7 @@ val platformOverrides = mapOf(
) )
dependencies { dependencies {
shadedApi(project(":common:implementation")) api(project(":common:implementation"))
} }
val taskSet = HashSet<AbstractArchiveTask>() val taskSet = HashSet<AbstractArchiveTask>()
+3 -3
View File
@@ -9,12 +9,12 @@ repositories {
} }
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) api(project(":common:implementation:base"))
shadedApi("org.slf4j:slf4j-api:1.8.0-beta4") { api("org.slf4j:slf4j-api:1.8.0-beta4") {
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.") because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
} }
shadedImplementation("org.apache.logging.log4j", "log4j-slf4j18-impl", Versions.Libraries.log4j_slf4j_impl) { implementation("org.apache.logging.log4j", "log4j-slf4j18-impl", Versions.Libraries.log4j_slf4j_impl) {
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.") because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
} }