Switch to indra, attempt to fix shading and universal jar

This commit is contained in:
jmp 2021-02-17 21:32:43 -08:00 committed by KennyTV
parent ef6c347194
commit 024c36c584
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
17 changed files with 226 additions and 245 deletions

View File

@ -1,142 +1,74 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin import net.kyori.indra.IndraPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import net.kyori.indra.IndraPublishingPlugin
import net.kyori.indra.sonatypeSnapshots
plugins { plugins {
`java-library` `java-library`
`maven-publish` id("net.kyori.indra")
id("com.github.johnrengelman.shadow") version ("6.1.0") apply false
} }
group = "us.myles"
version = "3.3.0-21w06a"
description = "Allow newer clients to join older server versions."
subprojects { subprojects {
apply { apply<JavaLibraryPlugin>()
plugin<JavaPlugin>() apply<MavenPublishPlugin>()
plugin<JavaLibraryPlugin>() apply<IndraPlugin>()
plugin<MavenPublishPlugin>() apply<IndraPublishingPlugin>()
plugin<ShadowPlugin>()
}
group = "us.myles"
version = "3.3.0-21w06a"
description = "Allow newer clients to join older server versions."
java.sourceCompatibility = JavaVersion.VERSION_1_8
tasks { tasks {
build {
dependsOn(withType<ShadowJar>())
}
test {
useJUnitPlatform()
}
withType<JavaCompile>() {
options.encoding = "UTF-8"
}
javadoc {
options.encoding = "UTF-8"
}
// Variable replacements // Variable replacements
processResources { processResources {
filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) { filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) {
expand("version" to project.version, "description" to project.description) expand("version" to project.version, "description" to project.description)
} }
} }
withType<ShadowJar>() {
archiveFileName.set("ViaVersion-" + project.version + ".jar")
relocate("org.yaml.snakeyaml", "us.myles.viaversion.libs.snakeyaml")
relocate("javassist", "us.myles.viaversion.libs.javassist")
relocate("com.google.gson", "us.myles.viaversion.libs.gson")
relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt")
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.*")
} }
relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil") { val platforms = listOf(
// We only want int and Object maps "bukkit",
include("it.unimi.dsi.fastutil.ints.*") "bungee",
include("it.unimi.dsi.fastutil.objects.*") "fabric",
include("it.unimi.dsi.fastutil.*.class") "sponge",
// Object types "velocity"
exclude("it.unimi.dsi.fastutil.*.*Reference*") ).map { "viaversion-$it" }
exclude("it.unimi.dsi.fastutil.*.*Boolean*") if (platforms.contains(project.name)) {
exclude("it.unimi.dsi.fastutil.*.*Byte*") configureShadowJar()
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*")
}
}
} }
repositories { repositories {
maven { sonatypeSnapshots()
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots") maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots")
} maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
maven { maven("https://repo.spongepowered.org/maven")
url = uri("https://oss.sonatype.org/content/repositories/snapshots") maven("https://repo.viaversion.com")
} maven("https://libraries.minecraft.net")
maven { maven("https://repo.maven.apache.org/maven2/")
url = uri("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
}
maven {
url = uri("https://repo.spongepowered.org/maven")
}
maven {
url = uri("https://repo.viaversion.com")
}
maven {
url = uri("https://libraries.minecraft.net")
}
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
} }
dependencies { dependencies {
implementation("net.md-5:bungeecord-chat:1.16-R0.5-SNAPSHOT") testImplementation("io.netty", "netty-all", Versions.netty)
implementation("it.unimi.dsi:fastutil:8.3.1") testImplementation("com.google.guava", "guava", Versions.guava)
implementation("com.github.steveice10:opennbt:1.2-SNAPSHOT") testImplementation("org.junit.jupiter", "junit-jupiter-api", Versions.jUnit)
implementation("com.google.code.gson:gson:2.8.6") testImplementation("org.junit.jupiter", "junit-jupiter-engine", Versions.jUnit)
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")
} }
java { indra {
withSourcesJar() javaVersions {
withJavadocJar() target.set(8)
testWith(8, 11, 15)
} }
github("ViaVersion", "ViaVersion") {
publishing { issues = true
publications.create<MavenPublication>("maven") {
from(components["java"])
} }
mitLicense()
}
}
tasks {
// root project has no useful artifacts
withType<Jar> {
onlyIf { false }
} }
} }

View File

@ -1,14 +1,13 @@
plugins { 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` `kotlin-dsl`
id("com.github.johnrengelman.shadow") version ("6.1.0") apply false
} }
repositories { repositories {
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal() gradlePluginPortal()
} }
dependencies { dependencies {
compileOnly("com.github.jengelman.gradle.plugins", "shadow", "6.1.0") implementation("net.kyori", "indra-common", "1.3.1")
implementation("net.kyori", "indra-publishing-gradle-plugin", "1.3.1")
implementation("com.github.jengelman.gradle.plugins", "shadow", "6.1.0")
} }

View File

@ -0,0 +1,31 @@
object Versions {
// common
const val netty = "4.0.20.Final"
const val guava = "17.0"
const val jUnit = "5.6.3"
const val bungeeChat = "1.16-R0.5-SNAPSHOT"
const val fastUtil = "8.3.1"
const val openNBT = "1.2-SNAPSHOT"
const val gson = "2.8.6"
const val javassist = "3.27.0-GA"
const val snakeYaml = "1.18"
const val jetbrainsAnnotations = "19.0.0"
// bukkit
const val spigot = "1.16.5-R0.1-SNAPSHOT"
// bukkit-legacy
const val legacyBukkit = "1.8.8-R0.1-SNAPSHOT"
// bungee
const val bungee = "1.15-SNAPSHOT"
// sponge
const val sponge = "5.0.0-SNAPSHOT"
// sponge-legacy
const val legacySponge = "4.0.0-SNAPSHOT"
// velocity
const val velocityApi = "1.1.0-SNAPSHOT"
}

View File

@ -1,45 +1,81 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.invoke
import org.gradle.kotlin.dsl.withType
import java.io.ByteArrayOutputStream
fun relocate(shadow: ShadowJar) { fun Project.configureShadowJar() {
shadow.relocate("org.yaml.snakeyaml", "us.myles.viaversion.libs.snakeyaml") apply<ShadowPlugin>()
shadow.relocate("javassist", "us.myles.viaversion.libs.javassist") tasks {
shadow.relocate("com.google.gson", "us.myles.viaversion.libs.gson") withType<ShadowJar> {
shadow.relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt") archiveClassifier.set("")
destinationDirectory.set(rootProject.projectDir.resolve("build/libs"))
//minimize() // ?
configureRelocations()
configureExcludes()
}
getByName("build") {
dependsOn(withType<ShadowJar>())
}
}
}
shadow.relocate("net.md_5.bungee", "us.myles.viaversion.libs.bungeecordchat") { private fun ShadowJar.configureRelocations() {
relocate("org.yaml.snakeyaml", "us.myles.viaversion.libs.snakeyaml")
relocate("javassist", "us.myles.viaversion.libs.javassist")
relocate("com.google.gson", "us.myles.viaversion.libs.gson")
relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt")
relocate("net.md_5.bungee", "us.myles.viaversion.libs.bungeecordchat")
relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil")
}
private fun ShadowJar.configureExcludes() {
// bungee api
/*
include("net.md_5.bungee.api.chat.*") include("net.md_5.bungee.api.chat.*")
include("net.md_5.bungee.api.ChatColor") include("net.md_5.bungee.api.ChatColor")
include("net.md_5.bungee.api.ChatMessageType") include("net.md_5.bungee.api.ChatMessageType")
include("net.md_5.bungee.chat.*") include("net.md_5.bungee.chat.*")
} */
}
// fastutil
fun relocateAll(shadow: ShadowJar) {
relocate(shadow)
shadow.relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil") {
// We only want int and Object maps // We only want int and Object maps
/*
include("it.unimi.dsi.fastutil.ints.*") include("it.unimi.dsi.fastutil.ints.*")
include("it.unimi.dsi.fastutil.objects.*") include("it.unimi.dsi.fastutil.objects.*")
include("it.unimi.dsi.fastutil.*.class") include("it.unimi.dsi.fastutil.*.class")
*/
// Object types // Object types
exclude("it.unimi.dsi.fastutil.*.*Reference*") exclude("it/unimi/dsi/fastutil/*/*Reference*")
exclude("it.unimi.dsi.fastutil.*.*Boolean*") exclude("it/unimi/dsi/fastutil/*/*Boolean*")
exclude("it.unimi.dsi.fastutil.*.*Byte*") exclude("it/unimi/dsi/fastutil/*/*Byte*")
exclude("it.unimi.dsi.fastutil.*.*Short*") exclude("it/unimi/dsi/fastutil/*/*Short*")
exclude("it.unimi.dsi.fastutil.*.*Float*") exclude("it/unimi/dsi/fastutil/*/*Float*")
exclude("it.unimi.dsi.fastutil.*.*Double*") exclude("it/unimi/dsi/fastutil/*/*Double*")
exclude("it.unimi.dsi.fastutil.*.*Long*") exclude("it/unimi/dsi/fastutil/*/*Long*")
exclude("it.unimi.dsi.fastutil.*.*Char*") exclude("it/unimi/dsi/fastutil/*/*Char*")
// Map types // Map types
exclude("it.unimi.dsi.fastutil.*.*Custom*") exclude("it/unimi/dsi/fastutil/*/*Custom*")
exclude("it.unimi.dsi.fastutil.*.*Linked*") exclude("it/unimi/dsi/fastutil/*/*Linked*")
exclude("it.unimi.dsi.fastutil.*.*Sorted*") exclude("it/unimi/dsi/fastutil/*/*Sorted*")
exclude("it.unimi.dsi.fastutil.*.*Tree*") exclude("it/unimi/dsi/fastutil/*/*Tree*")
exclude("it.unimi.dsi.fastutil.*.*Heap*") exclude("it/unimi/dsi/fastutil/*/*Heap*")
exclude("it.unimi.dsi.fastutil.*.*Queue*") exclude("it/unimi/dsi/fastutil/*/*Queue*")
// Crossing fingers // Crossing fingers
exclude("it.unimi.dsi.fastutil.*.*Big*") exclude("it/unimi/dsi/fastutil/*/*Big*")
exclude("it.unimi.dsi.fastutil.*.*Synchronized*") exclude("it/unimi/dsi/fastutil/*/*Synchronized*")
exclude("it.unimi.dsi.fastutil.*.*Unmodifiable*") exclude("it/unimi/dsi/fastutil/*/*Unmodifiable*")
} }
fun Project.latestCommitHash(): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
} }

View File

@ -1,10 +1,8 @@
dependencies { dependencies {
compileOnly(project(":viaversion-common")) implementation(project(":viaversion-common"))
compileOnly("org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT") { compileOnly("org.bukkit", "bukkit", Versions.legacyBukkit) {
exclude("junit", "junit") exclude("junit", "junit")
exclude("com.google.code.gson", "gson") exclude("com.google.code.gson", "gson")
exclude("javax.persistence", "persistence-api") exclude("javax.persistence", "persistence-api")
} }
} }
description = "viaversion-bukkit-legacy"

View File

@ -1,13 +1,9 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
dependencies { dependencies {
implementation(project(":viaversion-bukkit-legacy")) implementation(project(":viaversion-bukkit-legacy"))
compileOnly(project(":viaversion-common")) implementation(project(":viaversion-common"))
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT") { compileOnly("org.spigotmc", "spigot-api", Versions.spigot) {
exclude("junit", "junit") exclude("junit", "junit")
exclude("com.google.code.gson", "gson") exclude("com.google.code.gson", "gson")
exclude("javax.persistence", "persistence-api") exclude("javax.persistence", "persistence-api")
} }
} }
description = "viaversion-bukkit"

View File

@ -1,6 +1,4 @@
dependencies { dependencies {
compileOnly(project(":viaversion-common")) implementation(project(":viaversion-common"))
compileOnly("net.md-5:bungeecord-api:1.15-SNAPSHOT") compileOnly("net.md-5", "bungeecord-api", Versions.bungee)
} }
description = "viaversion-bungee"

View File

@ -1,30 +1,23 @@
plugins { plugins {
id("net.kyori.blossom") version "1.1.0" id("net.kyori.blossom") version "1.1.0"
id("org.ajoberstar.grgit") version "4.1.0"
} }
val commitId: String = grgit.head().abbreviatedId
blossom { blossom {
replaceToken("\$VERSION", project.version) replaceToken("\$VERSION", project.version)
replaceToken("\$IMPL_VERSION", "git-ViaVersion-" + project.version + ":" + commitId) replaceToken("\$IMPL_VERSION", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
} }
dependencies { dependencies {
implementation("net.md-5:bungeecord-chat:1.16-R0.5-SNAPSHOT") api("net.md-5", "bungeecord-chat", Versions.bungeeChat) {
implementation("it.unimi.dsi:fastutil:8.3.1") exclude("com.google.guava")
implementation("com.github.steveice10:opennbt:1.2-SNAPSHOT") }
implementation("com.google.code.gson:gson:2.8.6") api("it.unimi.dsi", "fastutil", Versions.fastUtil)
implementation("org.javassist:javassist:3.27.0-GA") api("com.github.steveice10", "opennbt", Versions.openNBT)
implementation("org.yaml:snakeyaml:1.18") api("com.google.code.gson", "gson", Versions.gson)
api("org.javassist", "javassist", Versions.javassist)
api("org.yaml", "snakeyaml", Versions.snakeYaml)
compileOnly("io.netty:netty-all:4.0.20.Final") compileOnlyApi("io.netty", "netty-all", Versions.netty)
compileOnly("com.google.guava:guava:17.0") compileOnlyApi("com.google.guava", "guava", Versions.guava)
compileOnly("org.jetbrains:annotations:19.0.0") compileOnlyApi("org.jetbrains", "annotations", Versions.jetbrainsAnnotations)
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"

View File

@ -1,5 +1,3 @@
dependencies { dependencies {
compileOnly(project(":viaversion-common")) implementation(project(":viaversion-common"))
} }
description = "viaversion-fabric"

0
gradlew vendored Normal file → Executable file
View File

View File

@ -1,18 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
dependencies {
implementation(project(":viaversion-common"))
implementation(project(":viaversion-bukkit"))
implementation(project(":viaversion-bungee"))
implementation(project(":viaversion-fabric"))
implementation(project(":viaversion-sponge"))
implementation(project(":viaversion-velocity"))
}
tasks {
withType<ShadowJar>() {
archiveFileName.set("ViaVersion-" + project.version + ".jar")
}
}
description = "viaversion-jar"

View File

@ -1,21 +1,22 @@
rootProject.name = "viaversion-parent" rootProject.name = "viaversion-parent"
include(":viaversion") setupViaSubproject("common")
include(":viaversion-common") setupViaSubproject("bukkit")
include(":viaversion-bukkit") setupViaSubproject("bukkit-legacy")
include(":viaversion-bukkit-legacy") setupViaSubproject("bungee")
include(":viaversion-bungee") setupViaSubproject("velocity")
include(":viaversion-velocity") setupViaSubproject("sponge")
include(":viaversion-sponge-legacy") setupViaSubproject("sponge-legacy")
include(":viaversion-sponge") setupViaSubproject("fabric")
include(":viaversion-fabric") setupViaSubproject("universal")
project(":viaversion-common").projectDir = file("common") fun setupViaSubproject(name: String) {
project(":viaversion-bukkit").projectDir = file("bukkit") setupSubproject("viaversion-$name") {
project(":viaversion-bukkit-legacy").projectDir = file("bukkit-legacy") projectDir = file(name)
project(":viaversion-bungee").projectDir = file("bungee") }
project(":viaversion-velocity").projectDir = file("velocity") }
project(":viaversion-sponge").projectDir = file("sponge")
project(":viaversion-sponge-legacy").projectDir = file("sponge-legacy") inline fun setupSubproject(name: String, block: ProjectDescriptor.() -> Unit) {
project(":viaversion-fabric").projectDir = file("fabric") include(name)
project(":viaversion").projectDir = file("jar") project(":$name").apply(block)
}

View File

@ -1,6 +1,4 @@
dependencies { dependencies {
compileOnly(project(":viaversion-common")) implementation(project(":viaversion-common"))
compileOnly("org.spongepowered:spongeapi:4.0.0-SNAPSHOT") compileOnly("org.spongepowered", "spongeapi", Versions.legacySponge)
} }
description = "viaversion-sponge-legacy"

View File

@ -1,7 +1,5 @@
dependencies { dependencies {
implementation(project(":viaversion-sponge-legacy")) implementation(project(":viaversion-sponge-legacy"))
compileOnly(project(":viaversion-common")) implementation(project(":viaversion-common"))
compileOnly("org.spongepowered:spongeapi:5.0.0-SNAPSHOT") compileOnly("org.spongepowered","spongeapi", Versions.sponge)
} }
description = "viaversion-sponge"

View File

@ -0,0 +1,23 @@
tasks {
val universalJar = register<Jar>("universalJar") {
artifacts.add("archives", this)
archiveClassifier.set("")
destinationDirectory.set(rootProject.projectDir.resolve("build/libs"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
arrayOf(
"bukkit",
"bungee",
"fabric",
"sponge",
"velocity"
).forEach {
val subProject = rootProject.project(":viaversion-$it")
val shadowJarTask = subProject.tasks.getByName("shadowJar")
from(zipTree(shadowJarTask.outputs.files.singleFile))
dependsOn(shadowJarTask)
}
}
build {
dependsOn(universalJar)
}
}

View File

@ -1,7 +1,5 @@
dependencies { dependencies {
compileOnly(project(":viaversion-common")) implementation(project(":viaversion-common"))
compileOnly("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT") compileOnly("com.velocitypowered", "velocity-api", Versions.velocityApi)
annotationProcessor("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT") annotationProcessor("com.velocitypowered", "velocity-api", Versions.velocityApi)
} }
description = "viaversion-velocity"