Migrate buildSrc plugins to build-logic
This commit is contained in:
committed by
Andrew Steinborn
parent
7e932eaad4
commit
3d20c3dd2d
19
build-logic/build.gradle.kts
Normal file
19
build-logic/build.gradle.kts
Normal file
@@ -0,0 +1,19 @@
|
||||
@Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
alias(libs.plugins.spotless)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// this is OK as long as the same version catalog is used in the main build and build-logic
|
||||
// see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
|
||||
implementation("com.diffplug.spotless:spotless-plugin-gradle:${libs.plugins.spotless.get().version}")
|
||||
}
|
||||
|
||||
spotless {
|
||||
kotlin {
|
||||
licenseHeaderFile(rootProject.file("../HEADER.txt"))
|
||||
}
|
||||
}
|
15
build-logic/settings.gradle.kts
Normal file
15
build-logic/settings.gradle.kts
Normal file
@@ -0,0 +1,15 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
versionCatalogs {
|
||||
register("libs") {
|
||||
from(files("../gradle/libs.versions.toml")) // include from parent project
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "build-logic"
|
6
build-logic/src/main/kotlin/LibsAccessor.kt
Normal file
6
build-logic/src/main/kotlin/LibsAccessor.kt
Normal file
@@ -0,0 +1,6 @@
|
||||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
|
||||
val Project.libs: LibrariesForLibs
|
||||
get() = rootProject.extensions.getByType()
|
10
build-logic/src/main/kotlin/velocity-checkstyle.gradle.kts
Normal file
10
build-logic/src/main/kotlin/velocity-checkstyle.gradle.kts
Normal file
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
checkstyle
|
||||
}
|
||||
|
||||
extensions.configure<CheckstyleExtension> {
|
||||
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
||||
maxErrors = 0
|
||||
maxWarnings = 0
|
||||
toolVersion = libs.checkstyle.get().version.toString()
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
val currentShortRevision = ByteArrayOutputStream().use {
|
||||
exec {
|
||||
executable = "git"
|
||||
args = listOf("rev-parse", "HEAD")
|
||||
standardOutput = it
|
||||
}
|
||||
it.toString().trim().substring(0, 8)
|
||||
}
|
||||
|
||||
tasks.withType<Jar> {
|
||||
manifest {
|
||||
val buildNumber = System.getenv("BUILD_NUMBER")
|
||||
val velocityHumanVersion: String =
|
||||
if (project.version.toString().endsWith("-SNAPSHOT")) {
|
||||
if (buildNumber == null) {
|
||||
"${project.version} (git-$currentShortRevision)"
|
||||
} else {
|
||||
"${project.version} (git-$currentShortRevision-b$buildNumber)"
|
||||
}
|
||||
} else {
|
||||
archiveVersion.get()
|
||||
}
|
||||
attributes["Implementation-Version"] = velocityHumanVersion
|
||||
}
|
||||
}
|
33
build-logic/src/main/kotlin/velocity-publish.gradle.kts
Normal file
33
build-logic/src/main/kotlin/velocity-publish.gradle.kts
Normal file
@@ -0,0 +1,33 @@
|
||||
plugins {
|
||||
java
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
extensions.configure<PublishingExtension> {
|
||||
repositories {
|
||||
maven {
|
||||
credentials(PasswordCredentials::class.java)
|
||||
|
||||
name = "paper"
|
||||
val base = "https://papermc.io/repo/repository/maven"
|
||||
val releasesRepoUrl = "$base-releases/"
|
||||
val snapshotsRepoUrl = "$base-snapshots/"
|
||||
setUrl(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
|
||||
}
|
||||
}
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
pom {
|
||||
name.set("Velocity")
|
||||
description.set("The modern, next-generation Minecraft server proxy")
|
||||
url.set("https://www.velocitypowered.com")
|
||||
scm {
|
||||
url.set("https://github.com/PaperMC/Velocity")
|
||||
connection.set("scm:git:https://github.com/PaperMC/Velocity.git")
|
||||
developerConnection.set("scm:git:https://github.com/PaperMC/Velocity.git")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
build-logic/src/main/kotlin/velocity-spotless.gradle.kts
Normal file
15
build-logic/src/main/kotlin/velocity-spotless.gradle.kts
Normal file
@@ -0,0 +1,15 @@
|
||||
import com.diffplug.gradle.spotless.SpotlessExtension
|
||||
import com.diffplug.gradle.spotless.SpotlessPlugin
|
||||
|
||||
apply<SpotlessPlugin>()
|
||||
|
||||
extensions.configure<SpotlessExtension> {
|
||||
java {
|
||||
if (project.name == "velocity-api") {
|
||||
licenseHeaderFile(file("HEADER.txt"))
|
||||
} else {
|
||||
licenseHeaderFile(rootProject.file("HEADER.txt"))
|
||||
}
|
||||
removeUnusedImports()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user