Gradle: avoid cross-configuration and enable configuration-on-demand (#5012)

This commit is contained in:
Konicai 2024-09-03 00:54:50 -04:00 committed by GitHub
parent 65cb15400a
commit f8884568ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 123 additions and 123 deletions

View file

@ -0,0 +1,3 @@
plugins {
id("geyser.base-conventions")
}

View file

@ -1,3 +1,8 @@
plugins {
id("geyser.platform-conventions")
id("geyser.modrinth-uploading-conventions")
}
dependencies { dependencies {
api(projects.core) api(projects.core)

View file

@ -1,3 +1,7 @@
plugins {
id("geyser.modded-conventions")
}
architectury { architectury {
common("neoforge", "fabric") common("neoforge", "fabric")
} }

View file

@ -1,3 +1,8 @@
plugins {
id("geyser.modded-conventions")
id("geyser.modrinth-uploading-conventions")
}
architectury { architectury {
platformSetupLoomIde() platformSetupLoomIde()
fabric() fabric()

View file

@ -1,13 +1,18 @@
// This is provided by "org.cloudburstmc.math.mutable" too, so yeet. plugins {
// NeoForge's class loader is *really* annoying. id("geyser.modded-conventions")
provided("org.cloudburstmc.math", "api") id("geyser.modrinth-uploading-conventions")
provided("com.google.errorprone", "error_prone_annotations") }
architectury { architectury {
platformSetupLoomIde() platformSetupLoomIde()
neoForge() neoForge()
} }
// This is provided by "org.cloudburstmc.math.mutable" too, so yeet.
// NeoForge's class loader is *really* annoying.
provided("org.cloudburstmc.math", "api")
provided("com.google.errorprone", "error_prone_annotations")
val includeTransitive: Configuration = configurations.getByName("includeTransitive") val includeTransitive: Configuration = configurations.getByName("includeTransitive")
dependencies { dependencies {

View file

@ -1,3 +1,8 @@
plugins {
id("geyser.platform-conventions")
id("geyser.modrinth-uploading-conventions")
}
dependencies { dependencies {
api(projects.core) api(projects.core)
api(libs.erosion.bukkit.common) { api(libs.erosion.bukkit.common) {

View file

@ -2,6 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCach
plugins { plugins {
application application
id("geyser.platform-conventions")
} }
val terminalConsoleVersion = "1.2.0" val terminalConsoleVersion = "1.2.0"

View file

@ -1,3 +1,8 @@
plugins {
id("geyser.platform-conventions")
id("geyser.modrinth-uploading-conventions")
}
dependencies { dependencies {
annotationProcessor(libs.velocity.api) annotationProcessor(libs.velocity.api)
api(projects.core) api(projects.core)

View file

@ -1,3 +1,7 @@
plugins {
id("geyser.platform-conventions")
}
dependencies { dependencies {
api(projects.core) api(projects.core)

View file

@ -12,9 +12,14 @@ repositories {
} }
dependencies { dependencies {
// This is for the LibsAccessor.kt hack
// this is OK as long as the same version catalog is used in the main build and build-logic // this is OK as long as the same version catalog is used in the main build and build-logic
// see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 // see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
// This is for applying plugins, and using the version from the libs.versions.toml
// Unfortunately they still need to be applied by their string name in the convention scripts.
implementation(libs.lombok)
implementation(libs.indra) implementation(libs.indra)
implementation(libs.shadow) implementation(libs.shadow)
implementation(libs.architectury.plugin) implementation(libs.architectury.plugin)

View file

@ -8,4 +8,4 @@ dependencyResolutionManagement {
} }
} }
rootProject.name = "build-logic" rootProject.name = "build-logic"

View file

@ -3,9 +3,10 @@ plugins {
id("net.kyori.indra") id("net.kyori.indra")
} }
dependencies { val rootProperties: Map<String, *> = project.rootProject.properties
compileOnly("org.checkerframework", "checker-qual", "3.19.0") group = rootProperties["group"] as String + "." + rootProperties["id"] as String
} version = rootProperties["version"] as String
description = rootProperties["description"] as String
indra { indra {
github("GeyserMC", "Geyser") { github("GeyserMC", "Geyser") {
@ -20,18 +21,52 @@ indra {
} }
} }
tasks { dependencies {
processResources { compileOnly("org.checkerframework", "checker-qual", libs.checker.qual.get().version)
// Spigot, BungeeCord, Velocity, Fabric, ViaProxy, NeoForge }
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json", "fabric.mod.json", "viaproxy.yml", "META-INF/neoforge.mods.toml")) {
expand( repositories {
"id" to "geyser", // mavenLocal()
"name" to "Geyser",
"version" to project.version, mavenCentral()
"description" to project.description,
"url" to "https://geysermc.org", // Floodgate, Cumulus etc.
"author" to "GeyserMC" maven("https://repo.opencollab.dev/main")
)
} // Paper, Velocity
maven("https://repo.papermc.io/repository/maven-public")
// Spigot
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") {
mavenContent { snapshotsOnly() }
} }
}
// BungeeCord
maven("https://oss.sonatype.org/content/repositories/snapshots") {
mavenContent { snapshotsOnly() }
}
// NeoForge
maven("https://maven.neoforged.net/releases") {
mavenContent { releasesOnly() }
}
// Minecraft
maven("https://libraries.minecraft.net") {
name = "minecraft"
mavenContent { releasesOnly() }
}
// ViaVersion
maven("https://repo.viaversion.com") {
name = "viaversion"
}
// Jitpack for e.g. MCPL
maven("https://jitpack.io") {
content { includeGroupByRegex("com\\.github\\..*") }
}
// For Adventure snapshots
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

View file

@ -1,45 +0,0 @@
repositories {
// mavenLocal()
mavenCentral()
// Floodgate, Cumulus etc.
maven("https://repo.opencollab.dev/main")
// Paper, Velocity
maven("https://repo.papermc.io/repository/maven-public")
// Spigot
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") {
mavenContent { snapshotsOnly() }
}
// BungeeCord
maven("https://oss.sonatype.org/content/repositories/snapshots") {
mavenContent { snapshotsOnly() }
}
// NeoForge
maven("https://maven.neoforged.net/releases") {
mavenContent { releasesOnly() }
}
// Minecraft
maven("https://libraries.minecraft.net") {
name = "minecraft"
mavenContent { releasesOnly() }
}
// ViaVersion
maven("https://repo.viaversion.com") {
name = "viaversion"
}
// Jitpack for e.g. MCPL
maven("https://jitpack.io") {
content { includeGroupByRegex("com\\.github\\..*") }
}
// For Adventure snapshots
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

View file

@ -2,11 +2,9 @@
import net.fabricmc.loom.task.RemapJarTask import net.fabricmc.loom.task.RemapJarTask
import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.maven
plugins { plugins {
id("geyser.build-logic") id("geyser.platform-conventions")
id("geyser.publish-conventions")
id("architectury-plugin") id("architectury-plugin")
id("dev.architectury.loom") id("dev.architectury.loom")
} }

View file

@ -1,3 +1,20 @@
plugins { plugins {
id("geyser.publish-conventions") id("geyser.publish-conventions")
} id("io.freefair.lombok")
}
tasks {
processResources {
// Spigot, BungeeCord, Velocity, Fabric, ViaProxy, NeoForge
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json", "fabric.mod.json", "viaproxy.yml", "META-INF/neoforge.mods.toml")) {
expand(
"id" to "geyser",
"name" to "Geyser",
"version" to project.version,
"description" to project.description,
"url" to "https://geysermc.org",
"author" to "GeyserMC"
)
}
}
}

View file

@ -1,55 +1,5 @@
plugins { plugins {
`java-library`
// Ensure AP works in eclipse (no effect on other IDEs) // Ensure AP works in eclipse (no effect on other IDEs)
eclipse eclipse
id("geyser.build-logic") id("geyser.base-conventions")
alias(libs.plugins.lombok) apply false
} }
allprojects {
group = properties["group"] as String + "." + properties["id"] as String
version = properties["version"] as String
description = properties["description"] as String
}
val basePlatforms = setOf(
projects.bungeecord,
projects.spigot,
projects.standalone,
projects.velocity,
projects.viaproxy
).map { it.dependencyProject }
val moddedPlatforms = setOf(
projects.fabric,
projects.neoforge,
projects.mod
).map { it.dependencyProject }
val modrinthPlatforms = setOf(
projects.bungeecord,
projects.fabric,
projects.neoforge,
projects.spigot,
projects.velocity
).map { it.dependencyProject }
subprojects {
apply {
plugin("java-library")
plugin("io.freefair.lombok")
plugin("geyser.build-logic")
}
when (this) {
in basePlatforms -> plugins.apply("geyser.platform-conventions")
in moddedPlatforms -> plugins.apply("geyser.modded-conventions")
else -> plugins.apply("geyser.base-conventions")
}
// Not combined with platform-conventions as that also contains
// platforms which we cant publish to modrinth
if (modrinthPlatforms.contains(this)) {
plugins.apply("geyser.modrinth-uploading-conventions")
}
}

View file

@ -1,5 +1,6 @@
plugins { plugins {
id("geyser.publish-conventions") id("geyser.publish-conventions")
id("io.freefair.lombok")
} }
dependencies { dependencies {

View file

@ -3,6 +3,7 @@ plugins {
idea idea
alias(libs.plugins.blossom) alias(libs.plugins.blossom)
id("geyser.publish-conventions") id("geyser.publish-conventions")
id("io.freefair.lombok")
} }
dependencies { dependencies {

View file

@ -1,6 +1,7 @@
# Gradle settings # Gradle settings
org.gradle.jvmargs=-Xmx4G org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false org.gradle.daemon=false
org.gradle.configureondemand=true
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.caching=true org.gradle.caching=true
org.gradle.vfs.watch=false org.gradle.vfs.watch=false

View file

@ -134,6 +134,7 @@ protocol-connection = { group = "org.cloudburstmc.protocol", name = "bedrock-con
math = { group = "org.cloudburstmc.math", name = "immutable", version = "2.0" } math = { group = "org.cloudburstmc.math", name = "immutable", version = "2.0" }
# plugins # plugins
lombok = { group = "io.freefair.gradle", name = "lombok-plugin", version.ref = "lombok" }
indra = { group = "net.kyori", name = "indra-common", version.ref = "indra" } indra = { group = "net.kyori", name = "indra-common", version.ref = "indra" }
shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" } shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" }
architectury-plugin = { group = "architectury-plugin", name = "architectury-plugin.gradle.plugin", version.ref = "architectury-plugin" } architectury-plugin = { group = "architectury-plugin", name = "architectury-plugin.gradle.plugin", version.ref = "architectury-plugin" }
@ -141,7 +142,6 @@ architectury-loom = { group = "dev.architectury.loom", name = "dev.architectury.
minotaur = { group = "com.modrinth.minotaur", name = "Minotaur", version.ref = "minotaur" } minotaur = { group = "com.modrinth.minotaur", name = "Minotaur", version.ref = "minotaur" }
[plugins] [plugins]
lombok = { id = "io.freefair.lombok", version.ref = "lombok" }
indra = { id = "net.kyori.indra", version.ref = "indra" } indra = { id = "net.kyori.indra", version.ref = "indra" }
blossom = { id = "net.kyori.blossom", version.ref = "blossom" } blossom = { id = "net.kyori.blossom", version.ref = "blossom" }