Improve Gradle setup

Don't build full platform jars to reduce build time
This commit is contained in:
Nassim Jahnke 2023-11-06 14:45:30 +10:00
parent c13a89a29c
commit 8eca6bf0b2
10 changed files with 20 additions and 58 deletions

View File

@ -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"))
}
}

View File

@ -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")
}
}

View File

@ -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")

View File

@ -1,4 +1,4 @@
dependencies {
implementation(projects.viabackwardsCommon)
compileOnlyApi(projects.viabackwardsCommon)
compileOnly(libs.bungee)
}

View File

@ -1,5 +1,5 @@
dependencies {
implementation(projects.viabackwardsCommon)
compileOnlyApi(projects.viabackwardsCommon)
compileOnly(libs.fabricLoader)
compileOnly(libs.log4j)
}

View File

@ -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"

View File

@ -1,4 +1,4 @@
dependencies {
implementation(projects.viabackwardsCommon)
compileOnlyApi(projects.viabackwardsCommon)
compileOnly(libs.sponge)
}

View File

@ -1,3 +1,3 @@
dependencies {
implementation(projects.viabackwardsCommon)
compileOnlyApi(projects.viabackwardsCommon)
}

View File

@ -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<Jar>())
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('-')

View File

@ -1,5 +1,5 @@
dependencies {
implementation(projects.viabackwardsCommon)
compileOnlyApi(projects.viabackwardsCommon)
compileOnly(libs.velocity) {
// Requires Java 11
exclude("com.velocitypowered", "velocity-brigadier")