From fad65e5b812896a3cc1b973238beadc3866c2928 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 14 Apr 2021 13:58:59 +0200 Subject: [PATCH] Update gradle build files Co-authored-by: jmp --- .github/workflows/gradle.yml | 3 ++- build.gradle.kts | 29 ++++++++++------------ buildSrc/src/main/kotlin/Versions.kt | 17 ------------- bukkit/build.gradle.kts | 4 +-- bungee/build.gradle.kts | 4 +-- common/build.gradle.kts | 10 ++++---- fabric/build.gradle.kts | 6 ++--- gradle/libs.versions.toml | 37 ++++++++++++++++++++++++++++ settings.gradle.kts | 3 +++ sponge/build.gradle.kts | 6 ++--- universal/build.gradle.kts | 24 ++++++++++-------- velocity/build.gradle.kts | 6 ++--- 12 files changed, 87 insertions(+), 62 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/Versions.kt create mode 100644 gradle/libs.versions.toml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 62f401fb..648ab1c4 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -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 diff --git a/build.gradle.kts b/build.gradle.kts index 3a8381ee..e2c2887a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { @@ -33,27 +34,13 @@ subprojects { } } - val platforms = listOf( - "bukkit", - "bungee", - "sponge", - "velocity", - "fabric" - ).map { "viabackwards-$it" } - if (platforms.contains(project.name)) { - configureShadowJar() - } - if (project.name == "viabackwards") { - apply() - } - repositories { maven("https://repo.viaversion.com") + maven("https://papermc.io/repo/repository/maven-public/") maven("https://oss.sonatype.org/content/repositories/snapshots/") - maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/") maven("https://repo.spongepowered.org/maven") - maven("https://repo.maven.apache.org/maven2/") + mavenCentral() } java { @@ -88,6 +75,16 @@ subprojects { } } +sequenceOf( + projects.viabackwardsBukkit, + projects.viabackwardsBungee, + projects.viabackwardsFabric, + projects.viabackwardsSponge, + projects.viabackwardsVelocity +).map { it.dependencyProject }.forEach { project -> + project.configureShadowJar() +} + tasks { withType { onlyIf { false } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt deleted file mode 100644 index b341e08a..00000000 --- a/buildSrc/src/main/kotlin/Versions.kt +++ /dev/null @@ -1,17 +0,0 @@ -object Versions { - // ViaVersion - const val viaversion = "3.3.0-21w14a" - - // Common - const val netty = "4.0.20.Final" - const val guava = "17.0" - const val fabricLoader = "0.4.8+build.154" - const val log4j = "2.8.1" - const val checkerQual = "3.12.0" - - // Platforms - const val spigot = "1.16.5-R0.1-SNAPSHOT" - const val bungee = "1.16-R0.5-SNAPSHOT" - const val sponge = "5.0.0-SNAPSHOT" - const val velocity = "1.1.0-SNAPSHOT" -} diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index af846bbb..807c4fcc 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -1,6 +1,6 @@ dependencies { - implementation(project(":viabackwards-common")) - compileOnly("org.spigotmc", "spigot-api", Versions.spigot) { + implementation(projects.viabackwardsCommon) + compileOnly(libs.paper) { exclude("com.google.code.gson", "gson") exclude("javax.persistence", "persistence-api") } diff --git a/bungee/build.gradle.kts b/bungee/build.gradle.kts index 69f07b3c..0995d6f3 100644 --- a/bungee/build.gradle.kts +++ b/bungee/build.gradle.kts @@ -1,4 +1,4 @@ dependencies { - implementation(project(":viabackwards-common")) - compileOnly("net.md-5", "bungeecord-api", Versions.bungee) + implementation(projects.viabackwardsCommon) + compileOnly(libs.bungee) } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index a31cb762..30460105 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("net.kyori.blossom") version "1.2.0" + id("net.kyori.blossom") } blossom { @@ -8,8 +8,8 @@ blossom { } dependencies { - compileOnly("io.netty", "netty-all", Versions.netty) - compileOnlyApi("us.myles", "viaversion", Versions.viaversion) - compileOnlyApi("com.google.guava", "guava", Versions.guava) - compileOnlyApi("org.checkerframework", "checker-qual", Versions.checkerQual) + compileOnlyApi(libs.viaver) + compileOnlyApi(libs.netty) + compileOnlyApi(libs.guava) + compileOnlyApi(libs.checkerQual) } \ No newline at end of file diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 2bd07e82..4e6c8cb8 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viabackwards-common")) - compileOnly("net.fabricmc", "fabric-loader", Versions.fabricLoader) - compileOnly("org.apache.logging.log4j", "log4j-api", Versions.log4j) + implementation(projects.viabackwardsCommon) + compileOnly(libs.fabricLoader) + compileOnly(libs.log4j) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..26c90a90 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,37 @@ +metadata.format.version = "1.0" + +[versions] + +# ViaVersion +viaver = "3.3.0-21w14a" + +# Common provided +netty = "4.0.20.Final" +guava = "17.0" +log4j = "2.8.1" + +checkerQual = "3.12.0" + +# Platforms +paper = "1.16.5-R0.1-SNAPSHOT" +bungee = "1.16-R0.5-SNAPSHOT" +sponge = "5.0.0" +velocity = "1.1.0-SNAPSHOT" +fabricLoader = "0.4.8+build.154" + + +[libraries] + +viaver = { group = "us.myles", name = "viaversion", version.ref = "viaver" } + +netty = { group = "io.netty", name = "netty-all", version.ref = "netty" } +guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } +log4j = { group = "org.apache.logging.log4j", name = "log4j-api", version.ref = "log4j" } + +checkerQual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerQual" } + +paper = { group = "com.destroystokyo.paper", name = "paper-api", version.ref = "paper" } +bungee = { group = "net.md-5", name = "bungeecord-api", version.ref = "bungee" } +sponge = { group = "org.spongepowered", name = "spongeapi", version.ref = "sponge" } +velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" } +fabricLoader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabricLoader" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 0e90bdbe..2d2de557 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,8 @@ rootProject.name = "viabackwards-parent" +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") +enableFeaturePreview("VERSION_CATALOGS") + setupViaSubproject("common") setupViaSubproject("bukkit") setupViaSubproject("bungee") diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts index 49de7657..16ecd5bc 100644 --- a/sponge/build.gradle.kts +++ b/sponge/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viabackwards-common")) - compileOnly("org.spongepowered","spongeapi", Versions.sponge) - annotationProcessor("org.spongepowered","spongeapi", Versions.sponge) + implementation(projects.viabackwardsCommon) + compileOnly(libs.sponge) + annotationProcessor(libs.sponge) } diff --git a/universal/build.gradle.kts b/universal/build.gradle.kts index a3cfb268..123fabde 100644 --- a/universal/build.gradle.kts +++ b/universal/build.gradle.kts @@ -1,22 +1,26 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +plugins { + id("com.github.johnrengelman.shadow") +} + tasks { withType { archiveClassifier.set("") archiveFileName.set("ViaBackwards-${project.version}.jar") destinationDirectory.set(rootProject.projectDir.resolve("build/libs")) duplicatesStrategy = DuplicatesStrategy.EXCLUDE - arrayOf( - "bukkit", - "bungee", - "sponge", - "velocity", - "fabric" - ).forEach { - val subProject = rootProject.project(":viabackwards-$it") - val shadowJarTask = subProject.tasks.getByName("shadowJar") - from(zipTree(shadowJarTask.outputs.files.singleFile)) + sequenceOf( + rootProject.projects.viabackwardsBukkit, + rootProject.projects.viabackwardsBungee, + rootProject.projects.viabackwardsFabric, + rootProject.projects.viabackwardsSponge, + rootProject.projects.viabackwardsVelocity, + ).map { it.dependencyProject }.forEach { subproject -> + val shadowJarTask = subproject.tasks.getByName("shadowJar", ShadowJar::class) dependsOn(shadowJarTask) + dependsOn(subproject.tasks.withType()) + from(zipTree(shadowJarTask.archiveFile)) } } build { diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts index 932e48b0..e325be0e 100644 --- a/velocity/build.gradle.kts +++ b/velocity/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(project(":viabackwards-common")) - compileOnly("com.velocitypowered", "velocity-api", Versions.velocity) - annotationProcessor("com.velocitypowered", "velocity-api", Versions.velocity) + implementation(projects.viabackwardsCommon) + compileOnly(libs.velocity) + annotationProcessor(libs.velocity) }