build: update build-time dependencies, address new warnings (#413)

* build: update build-time dependencies, address new warnings

* build: switch to central repo declaration, remove redundant repositories

* build: use spotless predeclaration, more task avoidance on kotlin modules
This commit is contained in:
zml 2022-12-08 20:40:52 -08:00 committed by Jason
parent 86b76b91c7
commit 59c5a8310c
33 changed files with 204 additions and 135 deletions

View file

@ -1,4 +1,4 @@
import net.kyori.indra.repository.sonatypeSnapshots
import com.diffplug.gradle.spotless.FormatExtension
import net.ltgt.gradle.errorprone.errorprone
plugins {
@ -32,7 +32,7 @@ tasks {
"StringSplitter",
"EqualsGetClass",
"CatchAndPrintStackTrace",
"InlineMeSuggester",
"InlineMeSuggester"
)
}
options.compilerArgs.addAll(listOf("-Xlint:-processing", "-Werror"))
@ -40,74 +40,30 @@ tasks {
}
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER"))
importOrderFile(rootProject.file(".spotless/cloud.importorder"))
indentWithSpaces(4)
fun FormatExtension.applyCommon(spaces: Int = 4) {
indentWithSpaces(spaces)
trimTrailingWhitespace()
endWithNewline()
}
java {
licenseHeaderFile(rootProject.file("HEADER"))
importOrderFile(rootProject.file(".spotless/cloud.importorder"))
applyCommon()
}
kotlin {
licenseHeaderFile(rootProject.file("HEADER"))
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
applyCommon()
}
kotlinGradle {
ktlint(libs.versions.ktlint.get())
}
format("configs") {
target("**/*.yml", "**/*.yaml", "**/*.json")
targetExclude("run/**")
indentWithSpaces(2)
trimTrailingWhitespace()
endWithNewline()
applyCommon(2)
}
}
repositories {
mavenCentral()
sonatypeSnapshots()
/* Velocity, used for cloud-velocity */
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-release/") {
mavenContent {
releasesOnly()
includeGroup("com.velocitypowered")
}
}
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/") {
mavenContent {
snapshotsOnly()
includeGroup("com.velocitypowered")
}
}
/* The Minecraft repository, used for cloud-brigadier */
maven("https://libraries.minecraft.net/") {
mavenContent { releasesOnly() }
}
/* 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://repo.papermc.io/repository/maven-public/")
/* Used for cloud-cloudburst */
maven("https://repo.opencollab.dev/maven-snapshots/") {
mavenContent { includeGroup("org.cloudburstmc") }
}
/* The current Fabric repository */
maven("https://maven.fabricmc.net/") {
mavenContent { includeGroup("net.fabricmc") }
}
/* The current Sponge repository */
maven("https://repo.spongepowered.org/repository/maven-public/") {
mavenContent { includeGroup("org.spongepowered") }
}
/* 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(libs.checkerQual)
compileOnlyApi(libs.apiguardian)

View file

@ -1,5 +1,4 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("cloud.base-conventions")
@ -8,9 +7,17 @@ plugins {
}
kotlin {
explicitApi()
jvmToolchain {
(this as JavaToolchainSpec).apply {
languageVersion.set(JavaLanguageVersion.of(8))
languageVersion.set(JavaLanguageVersion.of(8))
}
coreLibrariesVersion = "1.5.31"
target {
compilations.configureEach {
kotlinOptions {
jvmTarget = "1.8"
languageVersion = "1.5"
}
}
}
}
@ -20,7 +27,7 @@ dependencies {
}
tasks {
withType<DokkaTask> {
withType(DokkaTask::class).configureEach {
dokkaSourceSets.named("main") {
includes.from(layout.projectDirectory.file("src/main/descriptions.md"))
/*externalDocumentationLink { // todo: fix KDoc linking to JavaDoc
@ -32,19 +39,11 @@ tasks {
javadocJar {
from(dokkaHtml)
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
spotless {
kotlin {
ktlint()
ktlint(libs.versions.ktlint.get())
.editorConfigOverride(mapOf("ktlint_disabled_rules" to "filename"))
}
}
kotlin {
explicitApi()
}

View file

@ -1,3 +1,6 @@
plugins {
id("net.kyori.indra.publishing.sonatype")
id("com.diffplug.spotless")
}
spotless.predeclareDeps()

View file

@ -6,12 +6,12 @@ import org.gradle.kotlin.dsl.the
// set by GitHub Actions
val Project.ci: Provider<Boolean>
get() = providers.environmentVariable("CI")
.map { it.toBoolean() }
.orElse(false)
.map { it.toBoolean() }
.orElse(false)
val Project.compileExamples: Boolean
get() = providers.gradleProperty("compile-examples")
.isPresent
.isPresent
val Project.libs: LibrariesForLibs
get() = the()