Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Clean up build scripts using new Gradle features (#2436)
* Make use of `TYPESAFE_PROJECT_ACCESSORS` and `VERSION_CATALOGS` Gradle feature previews to clean up build scripts * Bump setup-java action to v2, specify AdoptOpenJDK distribution
Dieser Commit ist enthalten in:
Ursprung
c7e5b4a297
Commit
87d54f1103
3
.github/workflows/gradle.yml
vendored
3
.github/workflows/gradle.yml
vendored
@ -13,8 +13,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: 11
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
@ -1,9 +1,11 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
// Shade and relocate adventure in an extra module, so that common/the rest can directly depend on a
|
||||
// relocated adventure without breaking native platform's adventure usage with project wide relocation
|
||||
apply<ShadowPlugin>()
|
||||
tasks {
|
||||
withType<ShadowJar> {
|
||||
relocate("net.kyori", "us.myles.viaversion.libs.kyori")
|
||||
@ -14,16 +16,10 @@ tasks {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("net.kyori", "adventure-api", Versions.adventure) {
|
||||
api(libs.bundles.adventure) {
|
||||
exclude("org.checkerframework")
|
||||
}
|
||||
api("net.kyori", "adventure-text-serializer-gson", Versions.adventure) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
}
|
||||
api("net.kyori", "adventure-text-serializer-legacy", Versions.adventure) {
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom") version "1.2.0"
|
||||
id("net.kyori.blossom")
|
||||
}
|
||||
|
||||
blossom {
|
||||
@ -8,13 +8,15 @@ blossom {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":adventure", "shadow"))
|
||||
api("it.unimi.dsi", "fastutil", Versions.fastUtil)
|
||||
api("com.viaversion", "opennbt", Versions.openNBT)
|
||||
api("com.google.code.gson", "gson", Versions.gson)
|
||||
api(projects.adventure) {
|
||||
targetConfiguration = "shadow"
|
||||
}
|
||||
api(libs.fastutil)
|
||||
api(libs.openNBT)
|
||||
api(libs.gson)
|
||||
|
||||
compileOnlyApi("org.yaml", "snakeyaml", Versions.snakeYaml)
|
||||
compileOnlyApi("io.netty", "netty-all", Versions.netty)
|
||||
compileOnlyApi("com.google.guava", "guava", Versions.guava)
|
||||
compileOnlyApi("org.checkerframework", "checker-qual", Versions.checkerQual)
|
||||
compileOnlyApi(libs.snakeYaml)
|
||||
compileOnlyApi(libs.netty)
|
||||
compileOnlyApi(libs.guava)
|
||||
compileOnlyApi(libs.checkerQual)
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("net.kyori.blossom") version "1.2.0" apply false
|
||||
}
|
||||
|
||||
allprojects {
|
||||
@ -31,21 +32,6 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
val platforms = listOf(
|
||||
"bukkit",
|
||||
"bungee",
|
||||
"fabric",
|
||||
"sponge",
|
||||
"velocity"
|
||||
).map { "viaversion-$it" }
|
||||
if (platforms.contains(project.name)) {
|
||||
configureShadowJar()
|
||||
} else if (project.name == "viaversion-api") {
|
||||
configureShadowJarAPI()
|
||||
} else if (project.name == "viaversion") {
|
||||
apply<ShadowPlugin>()
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://repo.viaversion.com")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
@ -53,20 +39,18 @@ subprojects {
|
||||
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
|
||||
maven("https://repo.spongepowered.org/repository/maven-public/")
|
||||
maven("https://libraries.minecraft.net")
|
||||
maven("https://repo.maven.apache.org/maven2/")
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Note: If manually starting tests doesn't work for you in IJ, change 'Gradle -> Run Tests Using' to 'IntelliJ IDEA'
|
||||
testImplementation("io.netty", "netty-all", Versions.netty)
|
||||
testImplementation("com.google.guava", "guava", Versions.guava)
|
||||
testImplementation("org.junit.jupiter", "junit-jupiter-api", Versions.jUnit)
|
||||
testImplementation("org.junit.jupiter", "junit-jupiter-engine", Versions.jUnit)
|
||||
testImplementation(rootProject.libs.netty)
|
||||
testImplementation(rootProject.libs.guava)
|
||||
testImplementation(rootProject.libs.bundles.junit)
|
||||
}
|
||||
|
||||
configureJavaTarget(8)
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
@ -96,6 +80,18 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
sequenceOf(
|
||||
projects.viaversionBukkit,
|
||||
projects.viaversionBungee,
|
||||
projects.viaversionFabric,
|
||||
projects.viaversionSponge,
|
||||
projects.viaversionVelocity
|
||||
).map { it.dependencyProject }.forEach { project ->
|
||||
project.configureShadowJar()
|
||||
}
|
||||
|
||||
projects.viaversionApi.dependencyProject.configureShadowJarAPI()
|
||||
|
||||
tasks {
|
||||
// root project has no useful artifacts
|
||||
withType<Jar> {
|
||||
|
@ -1,24 +0,0 @@
|
||||
object Versions {
|
||||
// Common compiled
|
||||
const val adventure = "4.7.0"
|
||||
const val gson = "2.8.6"
|
||||
const val fastUtil = "8.3.1"
|
||||
const val openNBT = "2.0-SNAPSHOT"
|
||||
const val javassist = "3.27.0-GA"
|
||||
|
||||
// Common provided
|
||||
const val netty = "4.0.20.Final"
|
||||
const val guava = "17.0"
|
||||
const val snakeYaml = "1.18"
|
||||
|
||||
const val jUnit = "5.6.3"
|
||||
const val checkerQual = "3.12.0"
|
||||
|
||||
// Platforms
|
||||
const val paper = "1.16.5-R0.1-SNAPSHOT"
|
||||
const val legacyBukkit = "1.8.8-R0.1-SNAPSHOT"
|
||||
const val bungee = "1.16-R0.5-SNAPSHOT"
|
||||
const val sponge = "5.0.0"
|
||||
const val legacySponge = "4.0.0"
|
||||
const val velocity = "1.1.0-SNAPSHOT"
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import java.io.ByteArrayOutputStream
|
||||
@ -88,3 +91,10 @@ fun Project.latestCommitHash(): String {
|
||||
}
|
||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||
}
|
||||
|
||||
fun Project.configureJavaTarget(version: Int) {
|
||||
configure<JavaPluginConvention> {
|
||||
sourceCompatibility = JavaVersion.toVersion(version)
|
||||
targetCompatibility = JavaVersion.toVersion(version)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
dependencies {
|
||||
implementation(project(":viaversion-common"))
|
||||
compileOnly("org.bukkit", "bukkit", Versions.legacyBukkit) {
|
||||
implementation(projects.viaversionCommon)
|
||||
compileOnly(libs.legacyBukkit) {
|
||||
exclude("junit", "junit")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("javax.persistence", "persistence-api")
|
||||
|
@ -1,8 +1,8 @@
|
||||
dependencies {
|
||||
implementation(project(":viaversion-bukkit-legacy"))
|
||||
implementation(project(":viaversion-common"))
|
||||
implementation("org.javassist", "javassist", Versions.javassist)
|
||||
compileOnly("com.destroystokyo.paper", "paper-api", Versions.paper) {
|
||||
implementation(projects.viaversionBukkitLegacy)
|
||||
implementation(projects.viaversionCommon)
|
||||
implementation(libs.javassist)
|
||||
compileOnly(libs.paper) {
|
||||
exclude("junit", "junit")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("javax.persistence", "persistence-api")
|
||||
|
@ -1,7 +1,7 @@
|
||||
dependencies {
|
||||
implementation(project(":viaversion-common"))
|
||||
implementation(project(":java-compat"))
|
||||
compileOnly("net.md-5", "bungeecord-api", Versions.bungee)
|
||||
implementation(projects.viaversionCommon)
|
||||
implementation(projects.javaCompat)
|
||||
compileOnly(libs.bungee)
|
||||
}
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom") version "1.2.0"
|
||||
id("net.kyori.blossom")
|
||||
}
|
||||
|
||||
blossom {
|
||||
@ -8,5 +8,5 @@ blossom {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":viaversion-api"))
|
||||
api(projects.viaversionApi)
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
dependencies {
|
||||
implementation(project(":viaversion-common"))
|
||||
implementation(projects.viaversionCommon)
|
||||
}
|
||||
|
58
gradle/libs.versions.toml
Normale Datei
58
gradle/libs.versions.toml
Normale Datei
@ -0,0 +1,58 @@
|
||||
metadata.format.version = "1.0"
|
||||
|
||||
[versions]
|
||||
|
||||
adventure = "4.7.0"
|
||||
gson = "2.8.6"
|
||||
fastutil = "8.3.1"
|
||||
openNBT = "2.0-SNAPSHOT"
|
||||
javassist = "3.27.0-GA"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
guava = "17.0"
|
||||
snakeYaml = "1.18"
|
||||
|
||||
junit = "5.6.3"
|
||||
checkerQual = "3.12.0"
|
||||
|
||||
# Platforms
|
||||
paper = "1.16.5-R0.1-SNAPSHOT"
|
||||
legacyBukkit = "1.8.8-R0.1-SNAPSHOT"
|
||||
bungee = "1.16-R0.5-SNAPSHOT"
|
||||
sponge = "5.0.0"
|
||||
legacySponge = "4.0.0"
|
||||
velocity = "1.1.0-SNAPSHOT"
|
||||
|
||||
|
||||
[libraries]
|
||||
|
||||
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
|
||||
adventure-text-serializer-gson = { group = "net.kyori", name = "adventure-text-serializer-gson", version.ref = "adventure" }
|
||||
adventure-text-serializer-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" }
|
||||
|
||||
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
||||
fastutil = { group = "it.unimi.dsi", name = "fastutil", version.ref = "fastutil" }
|
||||
openNBT = { group = "com.viaversion", name = "opennbt", version.ref = "openNBT" }
|
||||
javassist = { group = "org.javassist", name = "javassist", version.ref = "javassist" }
|
||||
|
||||
netty = { group = "io.netty", name = "netty-all", version.ref = "netty" }
|
||||
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
|
||||
snakeYaml = { group = "org.yaml", name = "snakeyaml", version.ref = "snakeYaml" }
|
||||
|
||||
jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
|
||||
jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
|
||||
checkerQual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerQual" }
|
||||
|
||||
paper = { group = "com.destroystokyo.paper", name = "paper-api", version.ref = "paper" }
|
||||
legacyBukkit = { group = "org.bukkit", name = "bukkit", version.ref = "legacyBukkit" }
|
||||
bungee = { group = "net.md-5", name = "bungeecord-api", version.ref = "bungee" }
|
||||
sponge = { group = "org.spongepowered", name = "spongeapi", version.ref = "sponge" }
|
||||
legacySponge = { group = "org.spongepowered", name = "spongeapi", version.ref = "legacySponge" }
|
||||
velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
|
||||
|
||||
|
||||
[bundles]
|
||||
|
||||
adventure = ["adventure-api", "adventure-text-serializer-gson", "adventure-text-serializer-legacy"]
|
||||
junit = ["jupiter-api", "jupiter-engine"]
|
@ -1,8 +1,8 @@
|
||||
dependencies {
|
||||
api(project(":java-compat:java-compat-common"))
|
||||
api(project(":java-compat:java-compat-8"))
|
||||
api(project(":java-compat:java-compat-9"))
|
||||
api(project(":java-compat:java-compat-16"))
|
||||
api(projects.javaCompat.javaCompatCommon)
|
||||
api(projects.javaCompat.javaCompat8)
|
||||
api(projects.javaCompat.javaCompat9)
|
||||
api(projects.javaCompat.javaCompat16)
|
||||
}
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
|
@ -1,10 +1,7 @@
|
||||
dependencies {
|
||||
api(project(":java-compat:java-compat-common"))
|
||||
api(projects.javaCompat.javaCompatCommon)
|
||||
}
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
// This is for Java 16, but the minimum required for this
|
||||
// is actually just Java 9!
|
||||
sourceCompatibility = JavaVersion.VERSION_1_9
|
||||
targetCompatibility = JavaVersion.VERSION_1_9
|
||||
}
|
||||
// This is for Java 16, but the minimum required for this
|
||||
// is actually just Java 9!
|
||||
configureJavaTarget(9)
|
||||
|
@ -1,3 +1,5 @@
|
||||
dependencies {
|
||||
api(project(":java-compat:java-compat-common"))
|
||||
api(projects.javaCompat.javaCompatCommon)
|
||||
}
|
||||
|
||||
configureJavaTarget(8)
|
||||
|
@ -1,8 +1,5 @@
|
||||
dependencies {
|
||||
api(project(":java-compat:java-compat-common"))
|
||||
api(projects.javaCompat.javaCompatCommon)
|
||||
}
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_9
|
||||
targetCompatibility = JavaVersion.VERSION_1_9
|
||||
}
|
||||
configureJavaTarget(9)
|
||||
|
@ -1,5 +1,8 @@
|
||||
rootProject.name = "viaversion-parent"
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
enableFeaturePreview("VERSION_CATALOGS")
|
||||
|
||||
include("adventure")
|
||||
include("java-compat", "java-compat:java-compat-common", "java-compat:java-compat-8",
|
||||
"java-compat:java-compat-9", "java-compat:java-compat-16")
|
||||
|
@ -1,4 +1,4 @@
|
||||
dependencies {
|
||||
implementation(project(":viaversion-common"))
|
||||
compileOnly("org.spongepowered", "spongeapi", Versions.legacySponge)
|
||||
implementation(projects.viaversionCommon)
|
||||
compileOnly(libs.legacySponge)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
dependencies {
|
||||
implementation(project(":viaversion-sponge-legacy"))
|
||||
implementation(project(":viaversion-common"))
|
||||
compileOnly("org.spongepowered","spongeapi", Versions.sponge)
|
||||
implementation(projects.viaversionSpongeLegacy)
|
||||
implementation(projects.viaversionCommon)
|
||||
compileOnly(libs.sponge)
|
||||
}
|
||||
|
@ -1,22 +1,26 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<ShadowJar> {
|
||||
archiveClassifier.set("")
|
||||
archiveFileName.set("ViaVersion-${project.version}.jar")
|
||||
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))
|
||||
sequenceOf(
|
||||
rootProject.projects.viaversionBukkit,
|
||||
rootProject.projects.viaversionBungee,
|
||||
rootProject.projects.viaversionFabric,
|
||||
rootProject.projects.viaversionSponge,
|
||||
rootProject.projects.viaversionVelocity,
|
||||
).map { it.dependencyProject }.forEach { subproject ->
|
||||
val shadowJarTask = subproject.tasks.getByName("shadowJar", ShadowJar::class)
|
||||
dependsOn(shadowJarTask)
|
||||
dependsOn(subproject.tasks.withType<Jar>())
|
||||
from(zipTree(shadowJarTask.archiveFile))
|
||||
}
|
||||
}
|
||||
build {
|
||||
|
@ -1,5 +1,5 @@
|
||||
dependencies {
|
||||
implementation(project(":viaversion-common"))
|
||||
compileOnly("com.velocitypowered", "velocity-api", Versions.velocity)
|
||||
annotationProcessor("com.velocitypowered", "velocity-api", Versions.velocity)
|
||||
implementation(projects.viaversionCommon)
|
||||
compileOnly(libs.velocity)
|
||||
annotationProcessor(libs.velocity)
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren