From 8eca6bf0b2fa36b55d81bd6d63252613057d45a0 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 6 Nov 2023 14:45:30 +1000 Subject: [PATCH] Improve Gradle setup Don't build full platform jars to reduce build time --- .../kotlin/vb.platform-conventions.gradle.kts | 12 ------ build.gradle.kts | 12 ++---- bukkit/build.gradle.kts | 2 +- bungee/build.gradle.kts | 2 +- fabric/build.gradle.kts | 2 +- gradle/libs.versions.toml | 4 +- sponge/build.gradle.kts | 2 +- template/build.gradle.kts | 2 +- universal/build.gradle.kts | 38 ++++--------------- velocity/build.gradle.kts | 2 +- 10 files changed, 20 insertions(+), 58 deletions(-) delete mode 100644 build-logic/src/main/kotlin/vb.platform-conventions.gradle.kts diff --git a/build-logic/src/main/kotlin/vb.platform-conventions.gradle.kts b/build-logic/src/main/kotlin/vb.platform-conventions.gradle.kts deleted file mode 100644 index 256535ad..00000000 --- a/build-logic/src/main/kotlin/vb.platform-conventions.gradle.kts +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.* - -plugins { - id("vb.shadow-conventions") -} - -tasks { - shadowJar { - archiveFileName.set("ViaBackwards-${project.name.substringAfter("viabackwards-").replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}-${project.version}.jar") - destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs")) - } -} diff --git a/build.gradle.kts b/build.gradle.kts index f84d0b0a..b605067c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,9 @@ allprojects { description = "Allow older clients to join newer server versions." } -val platforms = setOf( +val main = setOf( + projects.viabackwards, + projects.viabackwardsCommon, projects.viabackwardsBukkit, projects.viabackwardsBungee, projects.viabackwardsFabric, @@ -17,15 +19,9 @@ val platforms = setOf( projects.viabackwardsVelocity ).map { it.dependencyProject } -// Would otherwise contain api/depdency modules if at some point needed -val special = setOf( - projects.viabackwards -).map { it.dependencyProject } - subprojects { when (this) { - in platforms -> plugins.apply("vb.platform-conventions") - in special -> plugins.apply("vb.base-conventions") + in main -> plugins.apply("vb.shadow-conventions") else -> plugins.apply("vb.standard-conventions") } } diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 807c4fcc..cb1c16d1 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(projects.viabackwardsCommon) + compileOnlyApi(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 0995d6f3..bad9a0d6 100644 --- a/bungee/build.gradle.kts +++ b/bungee/build.gradle.kts @@ -1,4 +1,4 @@ dependencies { - implementation(projects.viabackwardsCommon) + compileOnlyApi(projects.viabackwardsCommon) compileOnly(libs.bungee) } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 4e6c8cb8..9bed613b 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(projects.viabackwardsCommon) + compileOnlyApi(projects.viabackwardsCommon) compileOnly(libs.fabricLoader) compileOnly(libs.log4j) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8d0bfd6b..b652b0bb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,14 +3,14 @@ metadata.format.version = "1.1" [versions] # ViaVersion -viaver = "4.9.0-23w43a-SNAPSHOT" +viaver = "4.9.0-23w44a-SNAPSHOT" # Common provided netty = "4.0.20.Final" guava = "17.0" log4j = "2.8.1" -checkerQual = "3.29.0" +checkerQual = "3.39.0" # Platforms paper = "1.16.5-R0.1-SNAPSHOT" diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts index c3bca6f0..a4a1a55d 100644 --- a/sponge/build.gradle.kts +++ b/sponge/build.gradle.kts @@ -1,4 +1,4 @@ dependencies { - implementation(projects.viabackwardsCommon) + compileOnlyApi(projects.viabackwardsCommon) compileOnly(libs.sponge) } diff --git a/template/build.gradle.kts b/template/build.gradle.kts index a94bedae..82d518d3 100644 --- a/template/build.gradle.kts +++ b/template/build.gradle.kts @@ -1,3 +1,3 @@ dependencies { - implementation(projects.viabackwardsCommon) + compileOnlyApi(projects.viabackwardsCommon) } diff --git a/universal/build.gradle.kts b/universal/build.gradle.kts index 04ef5920..bad97b70 100644 --- a/universal/build.gradle.kts +++ b/universal/build.gradle.kts @@ -1,48 +1,26 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import io.papermc.hangarpublishplugin.model.Platforms plugins { - id("com.github.johnrengelman.shadow") id("io.papermc.hangar-publish-plugin") version "0.1.0" id("com.modrinth.minotaur") version "2.+" } -val platforms = setOf( - projects.viabackwardsBukkit, - projects.viabackwardsBungee, - projects.viabackwardsFabric, - projects.viabackwardsSponge, - projects.viabackwardsVelocity -).map { it.dependencyProject } +dependencies { + api(projects.viabackwardsCommon) + api(projects.viabackwardsBukkit) + api(projects.viabackwardsBungee) + api(projects.viabackwardsFabric) + api(projects.viabackwardsSponge) + api(projects.viabackwardsVelocity) +} tasks { shadowJar { - archiveClassifier.set("") archiveFileName.set("ViaBackwards-${project.version}.jar") destinationDirectory.set(rootProject.projectDir.resolve("build/libs")) - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - platforms.forEach { platform -> - val shadowJarTask = platform.tasks.getByName("shadowJar", ShadowJar::class) - dependsOn(shadowJarTask) - dependsOn(platform.tasks.withType()) - from(zipTree(shadowJarTask.archiveFile)) - } - } - build { - dependsOn(shadowJar) - } - sourcesJar { - rootProject.subprojects.forEach { subproject -> - if (subproject == project) return@forEach - val platformSourcesJarTask = subproject.tasks.findByName("sourcesJar") as? Jar ?: return@forEach - dependsOn(platformSourcesJarTask) - from(zipTree(platformSourcesJarTask.archiveFile)) - } } } -publishShadowJar() - val branch = rootProject.branchName() val baseVersion = project.version as String val isRelease = !baseVersion.contains('-') diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts index a4935c02..ba4756ac 100644 --- a/velocity/build.gradle.kts +++ b/velocity/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - implementation(projects.viabackwardsCommon) + compileOnlyApi(projects.viabackwardsCommon) compileOnly(libs.velocity) { // Requires Java 11 exclude("com.velocitypowered", "velocity-brigadier")