diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index cc02e636..2d396659 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -1,7 +1,12 @@ plugins { `kotlin-dsl` + java } repositories { gradlePluginPortal() } + +dependencies { + implementation("gradle.plugin.com.github.jengelman.gradle.plugins", "shadow", "7.0.0") +} diff --git a/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts b/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts new file mode 100644 index 00000000..65abc2ff --- /dev/null +++ b/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts @@ -0,0 +1,38 @@ +plugins { + `java-library` + `maven-publish` +// id("net.ltgt.errorprone") +} + +tasks { + processResources { + filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) { + expand( + "id" to "floodgate", + "name" to "floodgate", + "version" to project.version, + "description" to project.description, + "url" to "https://geysermc.org", + "author" to "GeyserMC" + ) + } + } + compileJava { + options.encoding = Charsets.UTF_8.name() + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + withSourcesJar() +} + +publishing { + publications.create("mavenJava") { + groupId = rootProject.group as String + artifactId = project.name + version = rootProject.version as String + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/floodgate.shadow-conventions.gradle.kts b/build-logic/src/main/kotlin/floodgate.shadow-conventions.gradle.kts new file mode 100644 index 00000000..3a7062ba --- /dev/null +++ b/build-logic/src/main/kotlin/floodgate.shadow-conventions.gradle.kts @@ -0,0 +1,33 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id("floodgate.base-conventions") + id("com.github.johnrengelman.shadow") +} + +tasks { + named("jar") { + archiveClassifier.set("unshaded") + from(project.rootProject.file("LICENSE")) + } + val shadowJar = named("shadowJar") { + archiveBaseName.set("floodgate-${project.name}") + archiveVersion.set("") + archiveClassifier.set("") + configureRelocations() + } + named("build") { + dependsOn(shadowJar) + } +} + +fun ShadowJar.configureRelocations() { + //todo platform-independent relocations +} + +publishing { + publications.named("mavenJava") { + artifact(tasks["shadowJar"]) + artifact(tasks["sourcesJar"]) + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/floodgate.standard-conventions.gradle.kts b/build-logic/src/main/kotlin/floodgate.standard-conventions.gradle.kts new file mode 100644 index 00000000..67bd0c5c --- /dev/null +++ b/build-logic/src/main/kotlin/floodgate.standard-conventions.gradle.kts @@ -0,0 +1,9 @@ +plugins { + id("floodgate.base-conventions") +} + +publishing { + publications.named("mavenJava") { + from(components["java"]) + } +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index ee7520a7..3ec63fb9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,27 +1,24 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - plugins { `java-library` - `maven-publish` id("floodgate.build-logic") apply false // id("com.github.spotbugs") version "4.8.0" apply false - -// id("net.kyori.indra") -// id("net.kyori.indra.checkstyle") -// id("net.kyori.indra.license-header") - - id("com.github.johnrengelman.shadow") version "7.1.0" apply false id("io.freefair.lombok") version "6.3.0" apply false } +val platforms = setOf( + projects.bungee, + projects.spigot, + projects.velocity +).map { it.dependencyProject } + +val api: Project = projects.api.dependencyProject + subprojects { // apply(plugin = "pmd") // apply(plugin = "com.github.spotbugs") apply { plugin("java-library") - plugin("maven-publish") - plugin("com.github.johnrengelman.shadow") plugin("io.freefair.lombok") plugin("floodgate.build-logic") } @@ -33,35 +30,13 @@ subprojects { } version = "2.1.1-SNAPSHOT" - java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + when (this) { + in platforms -> plugins.apply("floodgate.shadow-conventions") + api -> plugins.apply("floodgate.base-conventions") + else -> plugins.apply("floodgate.standard-conventions") } dependencies { compileOnly("org.checkerframework", "checker-qual", Versions.checkerQual) } - - tasks { - val shadowJar = named("shadowJar") { - archiveBaseName.set("floodgate-${project.name}") - archiveVersion.set("") - archiveClassifier.set("") - } - named("build") { - dependsOn(shadowJar) - } - - compileJava { - options.encoding = Charsets.UTF_8.name() - } - } - - publishing { - publications { - create("maven") { - from(components["java"]) - } - } - } } \ No newline at end of file diff --git a/bungee/build.gradle.kts b/bungee/build.gradle.kts index 5d8f57d4..dd36089e 100644 --- a/bungee/build.gradle.kts +++ b/bungee/build.gradle.kts @@ -3,7 +3,7 @@ var gsonVersion = "2.8.0"; var guavaVersion = "21.0"; dependencies { - api(project(":core", "shadow")) + api(project(":core")) implementation("cloud.commandframework", "cloud-bungee", "1.5.0") implementation("net.kyori", "adventure-text-serializer-gson", Versions.adventureApiVersion) implementation("net.kyori", "adventure-text-serializer-bungeecord", Versions.adventurePlatformVersion) diff --git a/bungee/src/main/resources/plugin.yml b/bungee/src/main/resources/plugin.yml index e2a1b90b..457d2a02 100644 --- a/bungee/src/main/resources/plugin.yml +++ b/bungee/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ -name: ${project.parent.name} -description: ${project.description} -version: ${project.version} -author: ${project.organization.name} +name: ${name} +description: ${description} +version: ${version} +author: ${author} main: org.geysermc.floodgate.BungeePlugin \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts index c0859bd0..e5ed8985 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,5 +1,5 @@ dependencies { - api(project(":api", "shadow")) + api(project(":api")) api("com.google.inject", "guice", Versions.guiceVersion) api("com.nukkitx.fastutil", "fastutil-short-object-maps", Versions.fastutilVersion) api("com.nukkitx.fastutil", "fastutil-int-object-maps", Versions.fastutilVersion) diff --git a/gradle.properties b/gradle.properties index af82e006..e68633cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ +org.gradle.caching=true org.gradle.parallel=true \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index ffac0eb4..58163ddf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,14 +39,12 @@ dependencyResolutionManagement { pluginManagement { plugins { id("net.kyori.blossom") version "1.2.0" - id("com.github.johnrengelman.shadow") version "7.1.0" } + includeBuild("build-logic") } rootProject.name = "floodgate-parent" -includeBuild("build-logic") - include(":api") include(":core") include(":bungee") diff --git a/spigot/build.gradle.kts b/spigot/build.gradle.kts index b108f738..56f2c23c 100644 --- a/spigot/build.gradle.kts +++ b/spigot/build.gradle.kts @@ -3,7 +3,7 @@ var guavaVersion = "21.0" var gsonVersion = "2.8.5" dependencies { - api(project(":core", "shadow")) + api(project(":core")) implementation("com.google.guava", "guava", guavaVersion) implementation("cloud.commandframework", "cloud-bukkit", Versions.cloudVersion) diff --git a/spigot/src/main/resources/plugin.yml b/spigot/src/main/resources/plugin.yml index 972691db..c9a5d232 100644 --- a/spigot/src/main/resources/plugin.yml +++ b/spigot/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ -name: ${project.parent.name} -description: ${project.description} -version: ${project.version} -author: ${project.organization.name} -website: ${project.url} +name: ${name} +description: ${description} +version: ${version} +author: ${author} +website: ${url} main: org.geysermc.floodgate.SpigotPlugin api-version: 1.13 \ No newline at end of file diff --git a/velocity/src/main/resources/velocity-plugin.json b/velocity/src/main/resources/velocity-plugin.json index bf949f5e..a4df39d2 100644 --- a/velocity/src/main/resources/velocity-plugin.json +++ b/velocity/src/main/resources/velocity-plugin.json @@ -1 +1 @@ -{"id": "${project.parent.name}", "name": "${project.parent.name}", "version": "${project.version}", "description": "${project.description}", "url": "${project.url}", "authors": ["${project.organization.name}"], "main": "org.geysermc.floodgate.VelocityPlugin"} \ No newline at end of file +{"id": "${id}", "name": "${name}", "version": "${version}", "description": "${description}", "url": "$url}", "authors": ["${author}"], "main": "org.geysermc.floodgate.VelocityPlugin"} \ No newline at end of file