From ef6c3471941fa6b9a6c54a120beaca83a5a71dbe Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 17 Feb 2021 17:50:47 +0100 Subject: [PATCH] *cries in elephant* --- buildSrc/build.gradle.kts | 14 ++++++ buildSrc/src/main/kotlin/extensions.kt | 45 +++++++++++++++++++ buildSrc/src/main/kotlin/relocator.gradle.kts | 0 bukkit-legacy/build.gradle.kts | 2 +- bukkit/build.gradle.kts | 4 +- bungee/build.gradle.kts | 2 +- common/build.gradle.kts | 17 +++++++ fabric/build.gradle.kts | 2 +- jar/build.gradle.kts | 8 ++++ sponge-legacy/build.gradle.kts | 2 +- sponge/build.gradle.kts | 2 +- velocity/build.gradle.kts | 2 +- 12 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/extensions.kt create mode 100644 buildSrc/src/main/kotlin/relocator.gradle.kts diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000..2fda01c25 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + // Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build. + `kotlin-dsl` + id("com.github.johnrengelman.shadow") version ("6.1.0") apply false +} + +repositories { + // Use the plugin portal to apply community plugins in convention plugins. + gradlePluginPortal() +} + +dependencies { + compileOnly("com.github.jengelman.gradle.plugins", "shadow", "6.1.0") +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/extensions.kt b/buildSrc/src/main/kotlin/extensions.kt new file mode 100644 index 000000000..cfe7f63b0 --- /dev/null +++ b/buildSrc/src/main/kotlin/extensions.kt @@ -0,0 +1,45 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +fun relocate(shadow: ShadowJar) { + shadow.relocate("org.yaml.snakeyaml", "us.myles.viaversion.libs.snakeyaml") + shadow.relocate("javassist", "us.myles.viaversion.libs.javassist") + shadow.relocate("com.google.gson", "us.myles.viaversion.libs.gson") + shadow.relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt") + + shadow.relocate("net.md_5.bungee", "us.myles.viaversion.libs.bungeecordchat") { + include("net.md_5.bungee.api.chat.*") + include("net.md_5.bungee.api.ChatColor") + include("net.md_5.bungee.api.ChatMessageType") + include("net.md_5.bungee.chat.*") + } +} + +fun relocateAll(shadow: ShadowJar) { + relocate(shadow) + shadow.relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil") { + // We only want int and Object maps + include("it.unimi.dsi.fastutil.ints.*") + include("it.unimi.dsi.fastutil.objects.*") + include("it.unimi.dsi.fastutil.*.class") + // Object types + exclude("it.unimi.dsi.fastutil.*.*Reference*") + exclude("it.unimi.dsi.fastutil.*.*Boolean*") + exclude("it.unimi.dsi.fastutil.*.*Byte*") + exclude("it.unimi.dsi.fastutil.*.*Short*") + exclude("it.unimi.dsi.fastutil.*.*Float*") + exclude("it.unimi.dsi.fastutil.*.*Double*") + exclude("it.unimi.dsi.fastutil.*.*Long*") + exclude("it.unimi.dsi.fastutil.*.*Char*") + // Map types + exclude("it.unimi.dsi.fastutil.*.*Custom*") + exclude("it.unimi.dsi.fastutil.*.*Linked*") + exclude("it.unimi.dsi.fastutil.*.*Sorted*") + exclude("it.unimi.dsi.fastutil.*.*Tree*") + exclude("it.unimi.dsi.fastutil.*.*Heap*") + exclude("it.unimi.dsi.fastutil.*.*Queue*") + // Crossing fingers + exclude("it.unimi.dsi.fastutil.*.*Big*") + exclude("it.unimi.dsi.fastutil.*.*Synchronized*") + exclude("it.unimi.dsi.fastutil.*.*Unmodifiable*") + } +} diff --git a/buildSrc/src/main/kotlin/relocator.gradle.kts b/buildSrc/src/main/kotlin/relocator.gradle.kts new file mode 100644 index 000000000..e69de29bb diff --git a/bukkit-legacy/build.gradle.kts b/bukkit-legacy/build.gradle.kts index afb9498c5..6e3199500 100644 --- a/bukkit-legacy/build.gradle.kts +++ b/bukkit-legacy/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viaversion-common")) + compileOnly(project(":viaversion-common")) compileOnly("org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT") { exclude("junit", "junit") exclude("com.google.code.gson", "gson") diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 262c78b66..9eb59e641 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -1,6 +1,8 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + dependencies { implementation(project(":viaversion-bukkit-legacy")) - implementation(project(":viaversion-common")) + compileOnly(project(":viaversion-common")) compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT") { exclude("junit", "junit") exclude("com.google.code.gson", "gson") diff --git a/bungee/build.gradle.kts b/bungee/build.gradle.kts index 060b085c8..387f235ba 100644 --- a/bungee/build.gradle.kts +++ b/bungee/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viaversion-common")) + compileOnly(project(":viaversion-common")) compileOnly("net.md-5:bungeecord-api:1.15-SNAPSHOT") } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index dae021786..dd1d62039 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -10,4 +10,21 @@ blossom { replaceToken("\$IMPL_VERSION", "git-ViaVersion-" + project.version + ":" + commitId) } +dependencies { + implementation("net.md-5:bungeecord-chat:1.16-R0.5-SNAPSHOT") + implementation("it.unimi.dsi:fastutil:8.3.1") + implementation("com.github.steveice10:opennbt:1.2-SNAPSHOT") + implementation("com.google.code.gson:gson:2.8.6") + implementation("org.javassist:javassist:3.27.0-GA") + implementation("org.yaml:snakeyaml:1.18") + + compileOnly("io.netty:netty-all:4.0.20.Final") + compileOnly("com.google.guava:guava:17.0") + compileOnly("org.jetbrains:annotations:19.0.0") + + testImplementation("io.netty:netty-all:4.0.20.Final") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.3") + testImplementation("org.junit.jupiter:junit-jupiter-engine:5.6.3") +} + description = "viaversion-common" diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 6d2a5ca65..c52771198 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viaversion-common")) + compileOnly(project(":viaversion-common")) } description = "viaversion-fabric" diff --git a/jar/build.gradle.kts b/jar/build.gradle.kts index 0e0156d3c..bcb1948c0 100644 --- a/jar/build.gradle.kts +++ b/jar/build.gradle.kts @@ -1,3 +1,5 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + dependencies { implementation(project(":viaversion-common")) implementation(project(":viaversion-bukkit")) @@ -7,4 +9,10 @@ dependencies { implementation(project(":viaversion-velocity")) } +tasks { + withType() { + archiveFileName.set("ViaVersion-" + project.version + ".jar") + } +} + description = "viaversion-jar" diff --git a/sponge-legacy/build.gradle.kts b/sponge-legacy/build.gradle.kts index 956a120a5..3b3023056 100644 --- a/sponge-legacy/build.gradle.kts +++ b/sponge-legacy/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viaversion-common")) + compileOnly(project(":viaversion-common")) compileOnly("org.spongepowered:spongeapi:4.0.0-SNAPSHOT") } diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts index 6dc243097..7f31ac37c 100644 --- a/sponge/build.gradle.kts +++ b/sponge/build.gradle.kts @@ -1,6 +1,6 @@ dependencies { implementation(project(":viaversion-sponge-legacy")) - implementation(project(":viaversion-common")) + compileOnly(project(":viaversion-common")) compileOnly("org.spongepowered:spongeapi:5.0.0-SNAPSHOT") } diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts index 3d6b01abe..eca0491e9 100644 --- a/velocity/build.gradle.kts +++ b/velocity/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viaversion-common")) + compileOnly(project(":viaversion-common")) compileOnly("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT") }