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

View File

@@ -1,3 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
preRelease(true)
versionProjects(":common:api", version("6.0.0"))
@@ -43,11 +45,19 @@ afterEvaluate {
configureDistribution()
}
forSubProjects(":common:addons") {
apply(plugin = "com.github.johnrengelman.shadow")
dependencies {
"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"(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"))
}
}
}

View File

@@ -21,11 +21,7 @@ fun Project.addonDir(dir: File, task: Task) {
it.delete()
}
forSubProjects(":common:addons") {
val jar = if (tasks.findByName("shadowJar") != null) {
(tasks.named("shadowJar").get() as ShadowJar)
} else {
(tasks.named("jar").get() as Jar)
}
val jar = tasks.named("shadowJar").get() as ShadowJar
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get())

View File

@@ -6,25 +6,9 @@ import org.gradle.kotlin.dsl.getting
import org.gradle.kotlin.dsl.repositories
fun Project.configureDependencies() {
val api by configurations.getting
val implementation by configurations.getting
val testImplementation 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 {
mavenCentral()
gradlePluginPortal()

View File

@@ -122,14 +122,13 @@ fun Project.configureDistribution() {
// Tell shadow to download the packs
dependsOn(downloadDefaultPacks)
configurations = listOf(project.configurations["shaded"])
archiveClassifier.set("shaded")
setVersion(project.version)
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
relocate("org.json", "com.dfsek.terra.lib.json")
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")
}
configure<BasePluginExtension> {

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,17 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
plugins {
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")
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,6 +1,6 @@
version = version("0.1.0")
dependencies {
shadedApi("com.googlecode.json-simple:json-simple:1.1.1")
shadedApi(project(":common:addons:manifest-addon-loader"))
api("com.googlecode.json-simple:json-simple:1.1.1")
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,6 +1,6 @@
version = version("0.1.0")
dependencies {
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
shadedApi(project(":common:addons:manifest-addon-loader"))
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,8 +1,8 @@
version = version("0.1.0")
dependencies {
shadedApi("commons-io:commons-io:2.6")
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
api("commons-io:commons-io:2.6")
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
}
tasks.withType<Jar> {

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -1,5 +1,5 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
}

View File

@@ -11,15 +11,11 @@ repositories {
}
dependencies {
shadedApi("commons-io:commons-io:2.6")
shadedApi("com.github.Querz:NBT:6.1")
shadedApi(project(":common:addons:manifest-addon-loader"))
api("commons-io:commons-io:2.7")
api("com.github.Querz:NBT:6.1")
compileOnly(project(":common:addons:manifest-addon-loader"))
}
tasks.named<ShadowJar>("shadowJar") {
relocate("org.apache.commons", "com.dfsek.terra.addons.sponge.lib.commons")
}
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
}

View File

@@ -8,14 +8,10 @@ plugins {
}
dependencies {
shadedApi("commons-io:commons-io:2.6")
shadedApi(project(":common:addons:manifest-addon-loader"))
api("commons-io:commons-io:2.7")
compileOnly(project(":common:addons:manifest-addon-loader"))
}
tasks.named<ShadowJar>("shadowJar") {
relocate("org.apache.commons", "com.dfsek.terra.addons.terrascript.lib.commons")
}
tasks.named("build") {
finalizedBy(tasks.named("shadowJar"))
}

View File

@@ -1,7 +1,7 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
shadedApi(project(":common:addons:chunk-generator-noise-3d"))
shadedApi(project(":common:addons:structure-terrascript-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
api(project(":common:addons:chunk-generator-noise-3d"))
api(project(":common:addons:structure-terrascript-loader"))
}

View File

@@ -1,7 +1,7 @@
version = version("0.1.0")
dependencies {
shadedApi(project(":common:addons:manifest-addon-loader"))
shadedApi(project(":common:addons:config-noise-function"))
shadedApi(project(":common:addons:structure-terrascript-loader"))
compileOnly(project(":common:addons:manifest-addon-loader"))
api(project(":common:addons:config-noise-function"))
api(project(":common:addons:structure-terrascript-loader"))
}

View File

@@ -1,11 +1,9 @@
dependencies {
shadedApi("ca.solo-studios", "strata", Versions.Libraries.strata)
shadedApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
shadedApi("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
compileOnlyApi("ca.solo-studios", "strata", Versions.Libraries.strata)
compileOnlyApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
compileOnlyApi("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
shadedApi("com.dfsek", "paralithic", Versions.Libraries.paralithic)
shadedApi("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
compileOnlyApi("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
compileOnlyApi("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}

View File

@@ -1,13 +1,24 @@
dependencies {
shadedApi(project(":common:api"))
shadedApi(project(":common:implementation:bootstrap-addon-loader"))
api(project(":common:api"))
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)
shadedImplementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic)
implementation("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)
testImplementation("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
}

View File

@@ -1,3 +1,3 @@
dependencies {
"shadedApi"(project(":common:api"))
"api"(project(":common:api"))
}

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"
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.")
}
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.")
}
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(

View File

@@ -3,15 +3,15 @@ repositories {
}
dependencies {
shadedApi("commons-io:commons-io:2.6")
shadedApi("com.github.Querz:NBT:6.1")
shadedApi(project(":common:implementation:base"))
api("commons-io:commons-io:2.6")
api("com.github.Querz:NBT:6.1")
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>() {

View File

@@ -8,7 +8,7 @@ plugins {
}
dependencies {
shadedApi(project(":common:implementation:base"))
api(project(":common:implementation:base"))
minecraft("com.mojang:minecraft:${Versions.Fabric.minecraft}")
mappings("net.fabricmc:yarn:${Versions.Fabric.yarn}:v2")

View File

@@ -3,7 +3,7 @@ val platformOverrides = mapOf(
)
dependencies {
shadedApi(project(":common:implementation"))
api(project(":common:implementation"))
}
val taskSet = HashSet<AbstractArchiveTask>()

View File

@@ -9,12 +9,12 @@ repositories {
}
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.")
}
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.")
}