Skip to content

Commit

Permalink
build: use cloud-build-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Citymonstret committed Jan 7, 2024
1 parent d12d3d6 commit 2c0c584
Show file tree
Hide file tree
Showing 22 changed files with 203 additions and 159 deletions.
29 changes: 16 additions & 13 deletions HEADER
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
Hyperverse - A minecraft world management plugin
//
// Hyperverse - A minecraft world management plugin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
149 changes: 25 additions & 124 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,141 +1,42 @@
import com.hierynomus.gradle.license.LicenseBasePlugin
import com.hierynomus.gradle.license.tasks.LicenseCheck
import net.kyori.indra.IndraExtension
import net.kyori.indra.IndraPlugin
import net.kyori.indra.IndraPublishingPlugin
import net.kyori.indra.IndraCheckstylePlugin
import net.ltgt.gradle.errorprone.ErrorPronePlugin
import net.ltgt.gradle.errorprone.errorprone
import nl.javadude.gradle.plugins.license.LicenseExtension
import org.gradle.api.plugins.JavaPlugin.*
import org.gradle.kotlin.dsl.support.serviceOf
import java.nio.charset.StandardCharsets
import com.diffplug.gradle.spotless.SpotlessTask

plugins {
val indraVersion = "3.1.3"
id("net.kyori.indra") version indraVersion
id("net.kyori.indra.checkstyle") version indraVersion apply false
id("net.kyori.indra.publishing.sonatype") version indraVersion
id("com.github.hierynomus.license") version "0.16.1" apply false
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("net.ltgt.errorprone") version "3.1.0" apply false
id("com.github.ben-manes.versions") version "0.50.0"
idea
alias(libs.plugins.cloud.buildLogic.rootProject.publishing)
alias(libs.plugins.cloud.buildLogic.rootProject.spotless)
}

group = "se.hyperver.hyperverse"
version = "0.11.0-SNAPSHOT"
description = "Minecraft world management plugin"

apply<IdeaPlugin>()

val targetJavaVersion = 17
spotlessPredeclare {
kotlin { ktlint(libs.versions.ktlint.get()) }
kotlinGradle { ktlint(libs.versions.ktlint.get()) }
}

subprojects {
apply<IndraPlugin>()
apply<IndraPublishingPlugin>()
apply<ErrorPronePlugin>()
apply<LicenseBasePlugin>()
apply<IdeaPlugin>()

if (this.name.startsWith("hyperverse-nms").not()) {
apply<IndraCheckstylePlugin>()
}

extensions.configure(LicenseExtension::class) {
header = rootProject.file("HEADER")
mapping("java", "DOUBLESLASH_STYLE")
mapping("kt", "DOUBLESLASH_STYLE")
includes(listOf("**/*.java", "**/*.kt"))
}

extensions.configure(IndraExtension::class) {
github("Incendo", "Hyperverse") {
ci(true)
}
gpl3OnlyLicense()

javaVersions {
target(targetJavaVersion)
testWith(targetJavaVersion)
}
checkstyle("8.39")

configurePublications {
pom {
developers {
developer {
id.set("Sauilitired")
name.set("Alexander Söderberg")
url.set("https://alexander-soderberg.com")
email.set("[email protected]")
}
if ("nms" in name) {
tasks {
whenTaskAdded {
if ("checkstyle" in name) {
enabled = false
}
}
}
}

/* Disable checkstyle on tests */
project.gradle.startParameter.excludedTaskNames.add("checkstyleTest")

tasks {
withType(JavaCompile::class) {
javaCompiler.set(serviceOf<JavaToolchainService>().compilerFor(java.toolchain))
options.release.set(targetJavaVersion)

options.errorprone {
/* These are just annoying */
disable(
"JdkObsolete",
"FutureReturnValueIgnored",
"ImmutableEnumChecker",
"StringSplitter",
"EqualsGetClass",
"CatchAndPrintStackTrace",
"TypeParameterUnusedInFormals",
"EmptyCatch"
)
}
// TODO: Re-enable
// options.compilerArgs.addAll(listOf("-Xlint:-processing", "-Werror"))
}

withType(Javadoc::class) {
javadocTool.set(serviceOf<JavaToolchainService>().javadocToolFor(java.toolchain))
options.encoding = StandardCharsets.UTF_8.name()
}

named("check") {
dependsOn(withType(LicenseCheck::class))
repositories {
maven("https://repo.aikar.co/content/groups/aikar/")
}
}

repositories {
mavenCentral()
sonatype.ossSnapshots()

maven("https://oss.sonatype.org/content/repositories/releases") {
mavenContent {
releasesOnly()
}
afterEvaluate {
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.remove("-Werror")
}
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://repo.aikar.co/content/groups/aikar/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://repo.spongepowered.org/maven")
maven("https://repo.onarandombox.com/content/repositories/multiverse/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://ci.mg-dev.eu/plugin/repository/everything/")
maven("https://repo.essentialsx.net/releases/")

tasks.findByName("spotlessConfigsCheck")?.enabled = false
}
}

dependencies {
COMPILE_ONLY_API_CONFIGURATION_NAME("org.checkerframework", "checker-qual", "3.9.1")
TEST_IMPLEMENTATION_CONFIGURATION_NAME("org.junit.jupiter", "junit-jupiter-engine", "5.8.2")
"errorprone"("com.google.errorprone", "error_prone_core", "2.10.0")
COMPILE_ONLY_API_CONFIGURATION_NAME("com.google.errorprone", "error_prone_annotations", "2.5.1")
COMPILE_ONLY_API_CONFIGURATION_NAME("org.jetbrains", "annotations", "23.0.0")
tasks {
spotlessCheck {
dependsOn(gradle.includedBuild("build-logic").task(":spotlessCheck") )
}
spotlessApply {
dependsOn(gradle.includedBuild("build-logic").task(":spotlessApply"))
}
}
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
group=org.incendo
version=1.0.0-SNAPSHOT
description=Minecraft world management plugin

org.gradle.parallel=true
org.gradle.jvmargs=-Xmx512m
org.gradle.java.installations.auto-download=false
Expand Down
21 changes: 21 additions & 0 deletions gradle/build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
`kotlin-dsl`
alias(libs.plugins.cloud.buildLogic.spotless)
}

repositories {
gradlePluginPortal()
mavenLocal()
}

dependencies {
implementation(libs.cloud.build.logic)
implementation(libs.gradleKotlinJvm)

implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}

cloudSpotless {
licenseHeaderFile.convention(null as RegularFile?)
ktlintVersion = libs.versions.ktlint
}
16 changes: 16 additions & 0 deletions gradle/build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rootProject.name = "build-logic"

pluginManagement {
repositories {
gradlePluginPortal()
mavenLocal()
}
}

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../libs.versions.toml"))
}
}
}
6 changes: 6 additions & 0 deletions gradle/build-logic/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.kotlin.dsl.the

val Project.libs: LibrariesForLibs
get() = the()
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id("org.incendo.cloud-build-logic")
id("org.incendo.cloud-build-logic.spotless")
}

indra {
javaVersions {
minimumToolchain(17)
target(17)
testWith().set(setOf(17))
}
checkstyle().set(libs.versions.checkstyle)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import org.incendo.cloudbuildlogic.city

plugins {
id("org.incendo.cloud-build-logic.publishing")
}

indra {
github("Incendo", "hyperverse") {
ci(true)
}
mitLicense()

configurePublications {
pom {
developers {
city()
}
}
}
}
32 changes: 29 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[versions]
cloud-build-logic = "0.0.1-SNAPSHOT"
ktlint = "0.50.0"
checkstyle = "10.12.5"
kotlin = "1.9.20"
shadow = "8.1.1"
paperweight = "1.5.10"

# Platforms
minecraft = "1.17.1-R0.1-SNAPSHOT"

Expand All @@ -7,11 +14,19 @@ cloud = "1.8.4"
guice = "5.1.0"
paperlib = "1.0.8"
taskchain = "3.7.2"
bstats = "3.0.2"
configurate = "4.1.2"

# Gradle plugins
paperweight = "1.5.10"
# Minecraft Plugins
multiverse = "4.3.1"
myworlds = "1.20.4-v3"
essentialsx = "2.20.1"
placeholderapi = "2.11.5"

[libraries]
cloud-build-logic = { module = "org.incendo:cloud-build-logic", version.ref = "cloud-build-logic" }
gradleKotlinJvm = { group = "org.jetbrains.kotlin.jvm", name = "org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" }

# Platform
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "minecraft" }

Expand All @@ -23,7 +38,18 @@ guice = { group = "com.google.inject", name = "guice", version.ref = "guice" }
assistedInject = { group = "com.google.inject.extensions", name = "guice-assistedinject", version.ref = "guice" }
paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib"}
taskchain = { group = "co.aikar", name = "taskchain-bukkit", version.ref = "taskchain" }
bstats = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" }
configurateHocon = { group = "org.spongepowered", name = "configurate-hocon", version.ref = "configurate"}

# Minecraft Plugins
multiverse = { group = "com.onarandombox.multiversecore", name = "Multiverse-Core", version.ref = "multiverse" }
myworlds = { group = "com.bergerkiller.bukkit", name = "MyWorlds", version.ref = "myworlds" }
essentialsx = { group = "net.essentialsx", name = "EssentialsX", version.ref = "essentialsx" }
placeholderapi = { group = "me.clip", name = "placeholderapi", version.ref = "placeholderapi" }

[plugins]
# Gradle plugins
paperweightUserdev = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight" }
cloud-buildLogic-spotless = { id = "org.incendo.cloud-build-logic.spotless", version.ref = "cloud-build-logic" }
cloud-buildLogic-rootProject-publishing = { id = "org.incendo.cloud-build-logic.publishing.root-project", version.ref = "cloud-build-logic" }
cloud-buildLogic-rootProject-spotless = { id = "org.incendo.cloud-build-logic.spotless.root-project", version.ref = "cloud-build-logic" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
21 changes: 12 additions & 9 deletions hyperverse-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin

plugins {
id("com.github.johnrengelman.shadow")
id("hyperverse.base-conventions")
id("hyperverse.publishing-conventions")
alias(libs.plugins.shadow)
}

apply {
plugin<ShadowPlugin>()
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

dependencies {
api(projects.hyperverseNmsCommon)

compileOnlyApi(libs.paper)

compileOnly("com.onarandombox.multiversecore:Multiverse-Core:4.3.1")
compileOnly("com.bergerkiller.bukkit:MyWorlds:1.20.4-v3")
compileOnly("net.essentialsx:EssentialsX:2.20.1")
compileOnly("me.clip:placeholderapi:2.11.5")
compileOnly(libs.multiverse)
compileOnly(libs.myworlds)
compileOnly(libs.essentialsx)
compileOnly(libs.placeholderapi)

// TODO: Remove, because yuck.
implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT")
implementation(libs.taskchain)
implementation(libs.paperlib)
Expand All @@ -29,11 +30,13 @@ dependencies {
implementation(libs.assistedInject) {
exclude("com.google.guava", "guava")
}
implementation("org.bstats:bstats-bukkit:3.0.2")
implementation("org.spongepowered:configurate-hocon:4.1.2")
implementation(libs.bstats)
implementation(libs.configurateHocon)
implementation(libs.cloudPaper)
implementation(libs.cloudMinecraftExtras)
implementation(libs.cloudMinecraftExtras)

// TODO: Remove and use native versions.
implementation("net.kyori:adventure-platform-bukkit:4.3.2")
implementation("net.kyori:adventure-text-minimessage:4.14.0")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//
//
// Hyperverse - A minecraft world management plugin
//
// This program is free software: you can redistribute it and/or modify
Expand Down
Loading

0 comments on commit 2c0c584

Please sign in to comment.