Coffee/build.gradle.kts
BuriedInCode d146faeebd
Some checks failed
ci/crow/push/testing/1 Pipeline was successful
ci/crow/push/linting Pipeline was successful
ci/crow/push/testing/2 Pipeline was successful
ci/crow/tag/publishing Pipeline failed
Fix publishing
2026-04-07 22:28:29 +12:00

138 lines
3.5 KiB
Kotlin

import com.diffplug.spotless.kotlin.KtfmtStep.TrailingCommaManagementStrategy
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.github.benmanes.gradle.versions.updates.resolutionstrategy.ComponentSelectionWithCurrent
plugins {
alias(libs.plugins.graalvm)
alias(libs.plugins.lombok)
alias(libs.plugins.shadow)
alias(libs.plugins.spotless)
alias(libs.plugins.versions)
application
`maven-publish`
}
group = "duckpond.buriedincode"
version = "0.1.0"
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
annotationProcessor(libs.picocli.codegen)
implementation(libs.commons.compress)
implementation(libs.json)
implementation(libs.jspecify)
implementation(libs.jtoml)
implementation(libs.picocli)
runtimeOnly(libs.sqlite.jdbc)
}
java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }
application {
mainClass = "duckpond.buriedincode.Coffee"
applicationName = "Coffee"
}
graalvmNative {
testSupport.set(false)
binaries {
named("main") {
imageName.set("coffee")
mainClass.set("duckpond.buriedincode.Coffee")
}
}
binaries.all { resources.autodetect() }
toolchainDetection.set(false)
}
tasks.jar { manifest.attributes["Main-Class"] = "duckpond.buriedincode.Coffee" }
tasks.shadowJar {
manifest.attributes["Main-Class"] = "duckpond.buriedincode.Coffee"
mergeServiceFiles()
}
publishing {
repositories {
maven {
name = "Codefloe"
url = uri("https://codefloe.com/api/packages/BuriedInCode/maven")
credentials(HttpHeaderCredentials::class) {
name = "Authorization"
value = "token ${System.getenv("PACKAGE_TOKEN")}"
}
authentication { create<HttpHeaderAuthentication>("header") }
}
}
publications { create<MavenPublication>("coffee") { from(components["java"]) } }
}
spotless {
java {
importOrder()
removeUnusedImports()
expandWildcardImports()
forbidWildcardImports()
forbidModuleImports()
cleanthat().sourceCompatibility("21")
googleJavaFormat()
eclipse()
.configFile("code-format.xml")
.sortMembersEnabled(true)
.sortMembersOrder("SF,F,SI,I,C,SM,M,T")
.sortMembersVisibilityOrderEnabled(true)
.sortMembersVisibilityOrder("B,R,D,V")
leadingTabsToSpaces(2)
trimTrailingWhitespace()
}
kotlin {
ktfmt().kotlinlangStyle().configure {
it.setMaxWidth(120)
it.setBlockIndent(2)
it.setContinuationIndent(2)
it.setRemoveUnusedImports(true)
it.setTrailingCommaManagementStrategy(TrailingCommaManagementStrategy.COMPLETE)
}
}
kotlinGradle {
ktfmt().kotlinlangStyle().configure {
it.setMaxWidth(120)
it.setBlockIndent(2)
it.setContinuationIndent(2)
it.setRemoveUnusedImports(true)
it.setTrailingCommaManagementStrategy(TrailingCommaManagementStrategy.COMPLETE)
}
}
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
tasks.withType<DependencyUpdatesTask> {
gradleReleaseChannel = "current"
checkForGradleUpdate = true
checkConstraints = false
checkBuildEnvironmentConstraints = false
resolutionStrategy {
componentSelection {
all(
Action<ComponentSelectionWithCurrent> {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
)
}
}
}