build: Update Gradle and plugins, small cleanup to build scripts

This commit is contained in:
Jason Penilla 2021-06-14 05:33:09 -07:00 committed by Jason
parent 9692593095
commit fb48a3c8af
19 changed files with 245 additions and 189 deletions

View file

@ -0,0 +1,15 @@
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
}
dependencies {
implementation(libs.indraCommon)
implementation(libs.indraPublishingSonatype)
implementation(libs.testLoggerPlugin)
implementation(libs.errorpronePlugin)
implementation(libs.licenser)
}

View file

@ -0,0 +1,12 @@
import ca.stellardrift.build.configurate.ConfigFormats
import ca.stellardrift.build.configurate.catalog.PolyglotVersionCatalogExtension
enableFeaturePreview("VERSION_CATALOGS")
plugins {
id("ca.stellardrift.polyglot-version-catalogs") version "5.0.0"
}
extensions.configure<PolyglotVersionCatalogExtension> {
from(ConfigFormats.YAML, file("../gradle/libs.versions.yml"))
}

View file

@ -0,0 +1,2 @@
abstract class CloudExampleExtension {
}

View file

@ -0,0 +1,103 @@
import net.kyori.indra.repository.sonatypeSnapshots
import net.ltgt.gradle.errorprone.errorprone
import org.cadixdev.gradle.licenser.header.HeaderStyle
plugins {
id("net.kyori.indra")
id("net.kyori.indra.publishing")
id("net.kyori.indra.checkstyle")
id("net.kyori.indra.license-header")
id("net.ltgt.errorprone")
}
indra {
publishSnapshotsTo("incendo", "https://repo.incendo.org/content/repositories/snapshots/")
github("Incendo", "cloud") {
ci(true)
}
mitLicense()
javaVersions {
testWith(8, 11, 16)
}
checkstyle("8.39")
configurePublications {
pom {
developers {
developer {
id.set("Sauilitired")
name.set("Alexander Söderberg")
url.set("https://alexander-soderberg.com")
email.set("contact@alexander-soderberg.com")
}
}
}
}
}
/* Disable checkstyle on tests */
project.gradle.startParameter.excludedTaskNames.add("checkstyleTest")
tasks {
withType<JavaCompile> {
options.errorprone {
/* These are just annoying */
disable(
"JdkObsolete",
"FutureReturnValueIgnored",
"ImmutableEnumChecker",
"StringSplitter",
"EqualsGetClass",
"CatchAndPrintStackTrace"
)
}
options.compilerArgs.addAll(listOf("-Xlint:-processing", "-Werror"))
}
}
license {
header(rootProject.file("HEADER"))
style["java"] = HeaderStyle.DOUBLE_SLASH.format
style["kt"] = HeaderStyle.DOUBLE_SLASH.format
}
repositories {
mavenCentral()
sonatypeSnapshots()
/* Velocity, used for cloud-velocity */
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-release/") {
mavenContent { releasesOnly() }
}
/* The Minecraft repository, used for cloud-brigadier */
maven("https://libraries.minecraft.net/") {
mavenContent { releasesOnly() }
}
/* The current Sponge repository */
maven("https://repo-new.spongepowered.org/repository/maven-public/")
/* The Spigot repository, used for cloud-bukkit */
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
mavenContent { snapshotsOnly() }
}
/* The paper repository, used for cloud-paper */
maven("https://papermc.io/repo/repository/maven-public/")
/* The NukkitX repository, used for cloud-cloudburst */
maven("https://repo.nukkitx.com/maven-snapshots") {
mavenContent { snapshotsOnly() }
}
/* JitPack, used for random dependencies */
maven("https://jitpack.io") {
content { includeGroupByRegex("com\\.github\\..*") }
}
/* JDA's maven repository for cloud-jda */
maven("https://m2.dv8tion.net/releases")
}
dependencies {
compileOnlyApi("org.checkerframework", "checker-qual", Versions.checkerQual)
testImplementation("org.junit.jupiter", "junit-jupiter-engine", Versions.jupiterEngine)
errorprone("com.google.errorprone", "error_prone_core", Versions.errorprone)
compileOnlyApi("com.google.errorprone", "error_prone_annotations", Versions.errorprone)
}

View file

@ -0,0 +1,12 @@
plugins {
id("cloud.base-conventions")
}
extensions.create<CloudExampleExtension>("cloudExample")
// Only compile examples on CI, or when the compile-examples property exists
if (!ci.get() && !compileExamples) {
tasks.configureEach {
onlyIf { false }
}
}

View file

@ -0,0 +1,10 @@
plugins {
id("net.kyori.indra.publishing.sonatype")
}
System.getenv("SNAPSHOT_PUBLISHING_USERNAME")?.run {
setProperty("incendoUsername", this)
}
System.getenv("SNAPSHOT_PUBLISHING_PASSWORD")?.run {
setProperty("incendoPassword", this)
}

View file

@ -0,0 +1,12 @@
import org.gradle.api.Project
import org.gradle.api.provider.Provider
// set by GitHub Actions
val Project.ci: Provider<Boolean>
get() = providers.environmentVariable("CI")
.forUseAtConfigurationTime()
.map { it.toBoolean() }
.orElse(false)
val Project.compileExamples: Boolean
get() = hasProperty("compile-examples")

View file

@ -1,148 +1,12 @@
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import net.kyori.indra.IndraLicenseHeaderPlugin
import net.kyori.indra.IndraCheckstylePlugin
import net.kyori.indra.IndraPublishingPlugin
import net.kyori.indra.IndraExtension
import net.kyori.indra.IndraPlugin
import net.kyori.indra.repository.sonatypeSnapshots
import net.ltgt.gradle.errorprone.ErrorPronePlugin
import net.ltgt.gradle.errorprone.errorprone
import org.cadixdev.gradle.licenser.LicenseExtension
import org.cadixdev.gradle.licenser.header.HeaderStyle
import org.gradle.api.plugins.JavaPlugin.COMPILE_ONLY_API_CONFIGURATION_NAME
import org.gradle.api.plugins.JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME
plugins {
val indraVersion = "2.0.2"
id("net.kyori.indra") version indraVersion apply false
id("net.kyori.indra.checkstyle") version indraVersion apply false
id("net.kyori.indra.publishing") version indraVersion apply false
id("net.kyori.indra.publishing.sonatype") version indraVersion
id("net.kyori.indra.license-header") version indraVersion apply false
id("com.github.johnrengelman.shadow") version "7.0.0" apply false
id("net.ltgt.errorprone") version "2.0.1" apply false
id("com.github.ben-manes.versions") version "0.38.0"
}
//buildGroups("Minecraft", "Discord", "IRC")
gradle.taskGraph.whenReady {
gradle.taskGraph.allTasks.forEach {
if (it.project.name.contains("example")) {
it.onlyIf {
project.hasProperty("compile-examples")
}
}
}
id("cloud.parent-build-logic")
id("com.github.ben-manes.versions")
}
group = "cloud.commandframework"
version = "1.5.0-SNAPSHOT"
description = "Command framework and dispatcher for the JVM"
extensions.configure<NexusPublishExtension> {
repositories.create("incendoSnapshots") {
snapshotRepositoryUrl.set(uri("https://repo.incendo.org/content/repositories/snapshots/"))
username.set(System.getenv("SNAPSHOT_PUBLISHING_USERNAME"))
password.set(System.getenv("SNAPSHOT_PUBLISHING_PASSWORD"))
}
}
subprojects {
apply<IndraPlugin>()
apply<IndraPublishingPlugin>()
apply<IndraCheckstylePlugin>()
apply<IndraLicenseHeaderPlugin>()
apply<ErrorPronePlugin>()
extensions.configure(IndraExtension::class) {
github("Incendo", "cloud") {
ci(true)
}
mitLicense()
javaVersions {
testWith(8, 11, 16)
}
checkstyle("8.39")
configurePublications {
pom {
developers {
developer {
id.set("Sauilitired")
name.set("Alexander Söderberg")
url.set("https://alexander-soderberg.com")
email.set("contact@alexander-soderberg.com")
}
}
}
}
}
/* Disable checkstyle on tests */
project.gradle.startParameter.excludedTaskNames.add("checkstyleTest")
tasks {
withType(JavaCompile::class) {
options.errorprone {
/* These are just annoying */
disable(
"JdkObsolete",
"FutureReturnValueIgnored",
"ImmutableEnumChecker",
"StringSplitter",
"EqualsGetClass",
"CatchAndPrintStackTrace"
)
}
options.compilerArgs.addAll(listOf("-Xlint:-processing", "-Werror"))
}
}
extensions.configure<LicenseExtension> {
header(rootProject.file("HEADER"))
style["java"] = HeaderStyle.DOUBLE_SLASH.format
style["kt"] = HeaderStyle.DOUBLE_SLASH.format
}
repositories {
mavenCentral()
sonatypeSnapshots()
/* Velocity, used for cloud-velocity */
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-release/") {
mavenContent { releasesOnly() }
}
/* The Minecraft repository, used for cloud-brigadier */
maven("https://libraries.minecraft.net/") {
mavenContent { releasesOnly() }
}
/* The current Sponge repository */
maven("https://repo-new.spongepowered.org/repository/maven-public/")
/* The Spigot repository, used for cloud-bukkit */
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
mavenContent { snapshotsOnly() }
}
/* The paper repository, used for cloud-paper */
maven("https://papermc.io/repo/repository/maven-public/")
/* The NukkitX repository, used for cloud-cloudburst */
maven("https://repo.nukkitx.com/maven-snapshots") {
mavenContent { snapshotsOnly() }
}
/* JitPack, used for random dependencies */
maven("https://jitpack.io") {
content { includeGroupByRegex("com\\.github\\..*") }
}
/* JDA's maven repository for cloud-jda */
maven("https://m2.dv8tion.net/releases")
}
dependencies {
COMPILE_ONLY_API_CONFIGURATION_NAME("org.checkerframework", "checker-qual", Versions.checkerQual)
TEST_IMPLEMENTATION_CONFIGURATION_NAME("org.junit.jupiter", "junit-jupiter-engine", Versions.jupiterEngine)
"errorprone"("com.google.errorprone", "error_prone_core", Versions.errorprone)
COMPILE_ONLY_API_CONFIGURATION_NAME("com.google.errorprone", "error_prone_annotations", Versions.errorprone)
}
plugins.apply("cloud.base-conventions")
}

View file

@ -1,12 +0,0 @@
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
implementation("com.bmuschko", "gradle-nexus-plugin", "2.3.1")
}

View file

@ -1,24 +0,0 @@
import org.gradle.api.Project
import org.gradle.kotlin.dsl.invoke
fun Project.buildGroups(vararg groupNames: String) =
groupNames.forEach(this::buildGroup)
fun Project.buildGroup(groupName: String) {
tasks {
register("build$groupName") {
group = "cloud"
rootProject.subprojects
.filter { it.projectDir.parentFile.name == "cloud-${groupName.toLowerCase()}" }
.map { it.tasks.getByName("build") }
.forEach { dependsOn(it) }
}
register("install$groupName") {
group = "cloud"
rootProject.subprojects
.filter { it.projectDir.parentFile.name == "cloud-${groupName.toLowerCase()}" }
.map { it.tasks.getByName("publishToMavenLocal") }
.forEach { dependsOn(it) }
}
}
}

View file

@ -1,8 +1,21 @@
plugins {
id("cloud.example-conventions")
id("com.github.johnrengelman.shadow")
id("xyz.jpenilla.run-paper") version "1.0.3-SNAPSHOT"
}
dependencies {
/* Cloud */
implementation(project(":cloud-paper"))
implementation(project(":cloud-annotations"))
implementation(project(":cloud-minecraft-extras"))
/* Extras */
implementation("me.lucko", "commodore", Versions.commodore)
implementation("net.kyori", "adventure-platform-bukkit", Versions.adventurePlatform)
/* Bukkit */
compileOnly("org.bukkit", "bukkit", Versions.bukkit)
}
tasks {
shadowJar {
dependencies {
@ -18,15 +31,3 @@ tasks {
legacyPluginLoading()
}
}
dependencies {
/* Cloud */
implementation(project(":cloud-paper"))
implementation(project(":cloud-annotations"))
implementation(project(":cloud-minecraft-extras"))
/* Extras */
implementation("me.lucko", "commodore", Versions.commodore)
implementation("net.kyori", "adventure-platform-bukkit", Versions.adventurePlatform)
/* Bukkit */
compileOnly("org.bukkit", "bukkit", Versions.bukkit)
}

View file

@ -1,4 +1,5 @@
plugins {
id("cloud.example-conventions")
id ("com.github.johnrengelman.shadow")
}

View file

@ -1,3 +1,7 @@
plugins {
id("cloud.example-conventions")
}
apply plugin: "application"
apply plugin: "com.github.johnrengelman.shadow"

View file

@ -1,5 +1,6 @@
plugins {
application
id("cloud.example-conventions")
id("com.github.johnrengelman.shadow")
}

View file

@ -1,5 +1,6 @@
plugins {
id ("com.github.johnrengelman.shadow")
id("com.github.johnrengelman.shadow")
id("cloud.example-conventions")
}
val velocityRunClasspath by configurations.creating {

49
gradle/libs.versions.yml Normal file
View file

@ -0,0 +1,49 @@
metadata:
format: { version: 1.0 }
polyglot-extensions:
- plugins
plugins:
com.github.johnrengelman.shadow: 7.0.0
net.ltgt.errorprone: 2.0.1
com.github.ben-manes.versions: 0.36.0
versions:
checkerQual: 3.14.0
# build-logic
checkstyle: 8.39
indra: 2.0.5
testLoggerPlugin: 3.0.0
errorpronePlugin: 2.0.1
licenser: 0.6.0
dependencies:
checkerQual:
group: org.checkerframework
name: checker-qual
version: { ref: checkerQual }
# build-logic
indraCommon:
group: net.kyori
name: indra-common
version: { ref: indra }
indraPublishingSonatype:
group: net.kyori
name: indra-publishing-sonatype
version: { ref: indra }
licenser:
group: gradle.plugin.org.cadixdev.gradle
name: licenser
version: { ref: licenser }
testLoggerPlugin:
group: com.adarshr
name: gradle-test-logger-plugin
version: { ref: testLoggerPlugin }
errorpronePlugin:
group: net.ltgt.gradle
name: gradle-errorprone-plugin
version: { ref: errorpronePlugin }
bundles:

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -4,6 +4,11 @@ pluginManagement {
maven("https://maven.fabricmc.net")
maven("https://repo.jpenilla.xyz/snapshots") // todo - for run-paper snapshot
}
includeBuild("build-logic")
}
plugins {
id("ca.stellardrift.polyglot-version-catalogs") version "5.0.0"
}
rootProject.name = "cloud"