mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
build: Update run-paper to 1.0.2, improve up to date checking for FileCopyTask, use version catalog in build-logic
This commit is contained in:
13 files changed
+92
-62
No files matched your search
@@ -1,3 +1,7 @@
|
|||||||
|
plugins {
|
||||||
|
id("carbon.base-conventions")
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Doesn't add any dependencies, only version constraints
|
// Doesn't add any dependencies, only version constraints
|
||||||
api(platform(libs.adventureBom))
|
api(platform(libs.adventureBom))
|
||||||
|
|||||||
@@ -7,13 +7,10 @@ repositories {
|
|||||||
maven("https://repo.jpenilla.xyz/snapshots/") // todo: for shadow snapshot
|
maven("https://repo.jpenilla.xyz/snapshots/") // todo: for shadow snapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
// sadly can't use the version catalog here (?), need to keep in sync manually
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// temporary until shadow bumps jdependency for Record support
|
implementation(libs.shadow)
|
||||||
//implementation("gradle.plugin.com.github.jengelman.gradle.plugins", "shadow", "7.0.0")
|
implementation(libs.indraCommon)
|
||||||
implementation("com.github.johnrengelman", "shadow", "7.1.0-hexaoxide-SNAPSHOT")
|
|
||||||
|
|
||||||
val indraVersion = "2.0.5"
|
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||||
implementation("net.kyori", "indra-common", indraVersion)
|
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
implementation("net.kyori", "indra-git", indraVersion)
|
|
||||||
}
|
}
|
||||||
@@ -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"))
|
||||||
|
}
|
||||||
@@ -1,20 +1,18 @@
|
|||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.tasks.InputFile
|
import org.gradle.api.tasks.InputFile
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
import org.gradle.api.tasks.OutputFile
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
abstract class FileCopyTask : DefaultTask() {
|
abstract class FileCopyTask : DefaultTask() {
|
||||||
@InputFile
|
@InputFile
|
||||||
val fileToCopy = project.objects.fileProperty()
|
val fileToCopy = project.objects.fileProperty()
|
||||||
|
|
||||||
@OutputDirectory
|
@OutputFile
|
||||||
val destinationDirectory = project.objects.directoryProperty()
|
val destination = project.objects.fileProperty()
|
||||||
|
|
||||||
private val destination = project.objects.fileProperty().convention(destinationDirectory.file(fileToCopy.map { it.asFile.name }))
|
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
private fun copyFile() {
|
private fun copyFile() {
|
||||||
destinationDirectory.get().asFile.mkdirs()
|
destination.get().asFile.parentFile.mkdirs()
|
||||||
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
|
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,3 +12,14 @@ indra {
|
|||||||
}
|
}
|
||||||
github(GITHUB_ORGANIZATION, GITHUB_REPO)
|
github(GITHUB_ORGANIZATION, GITHUB_REPO)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
withType<JavaCompile> {
|
||||||
|
// disable 'warning: No processor claimed any of these annotations' spam
|
||||||
|
options.compilerArgs.add("-Xlint:-processing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
checkstyle(libs.stylecheck)
|
||||||
|
}
|
||||||
@@ -7,8 +7,9 @@ val platformExtension = extensions.create<CarbonPlatformExtension>("carbonPlatfo
|
|||||||
tasks {
|
tasks {
|
||||||
val copyJar = register<FileCopyTask>("copyJar") {
|
val copyJar = register<FileCopyTask>("copyJar") {
|
||||||
fileToCopy.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
fileToCopy.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||||
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
|
destination.set(rootProject.layout.buildDirectory.dir("libs").flatMap {
|
||||||
dependsOn(platformExtension.jarTask)
|
it.file(fileToCopy.map { file -> file.asFile.name })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
build {
|
build {
|
||||||
dependsOn(copyJar)
|
dependsOn(copyJar)
|
||||||
@@ -18,5 +19,6 @@ tasks {
|
|||||||
val projectVersion = version as String
|
val projectVersion = version as String
|
||||||
if (projectVersion.endsWith("-SNAPSHOT")) {
|
if (projectVersion.endsWith("-SNAPSHOT")) {
|
||||||
// Add git commit hash to version for platforms
|
// Add git commit hash to version for platforms
|
||||||
version = "$projectVersion+${indraGit.commit()?.name?.substring(0, 7) ?: error("Failed to retrieve git commit hash")}"
|
val gitHash = latestGitHash() ?: error("Failed to retrieve git commit hash")
|
||||||
|
version = "$projectVersion+$gitHash"
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
import net.kyori.indra.git.IndraGitExtension
|
||||||
|
import org.gradle.accessors.dm.LibrariesForLibs
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.the
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relocate a package into the `net.draycia.carbon.libs` namespace.
|
* Relocate a package into the `net.draycia.carbon.libs` namespace.
|
||||||
@@ -36,3 +40,9 @@ fun ShadowJar.configureShadowJar() {
|
|||||||
exclude(dependency("com.google.j2objc:j2objc-annotations"))
|
exclude(dependency("com.google.j2objc:j2objc-annotations"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Project.latestGitHash(): String? =
|
||||||
|
the<IndraGitExtension>().commit()?.name?.substring(0, 7)
|
||||||
|
|
||||||
|
val Project.libs: LibrariesForLibs
|
||||||
|
get() = the()
|
||||||
@@ -6,11 +6,3 @@ group = "net.draycia"
|
|||||||
description = "CarbonChat - A modern chat plugin"
|
description = "CarbonChat - A modern chat plugin"
|
||||||
val projectVersion: String by project // get from gradle.properties
|
val projectVersion: String by project // get from gradle.properties
|
||||||
version = projectVersion
|
version = projectVersion
|
||||||
|
|
||||||
subprojects {
|
|
||||||
plugins.apply("carbon.base-conventions")
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
"checkstyle"(rootProject.libs.stylecheck)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+13
-9
@@ -1,13 +1,17 @@
|
|||||||
|
plugins {
|
||||||
|
id("carbon.base-conventions")
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(projects.carbonchatApi)
|
api(projects.carbonchatApi)
|
||||||
|
|
||||||
// Configs
|
// Configs
|
||||||
api(libs.configurateHocon)
|
api(libs.configurateHocon)
|
||||||
api(libs.adventureSerializerConfigurate4) {
|
api(libs.adventureSerializerConfigurate4) {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
}
|
}
|
||||||
api(libs.typesafeConfig)
|
api(libs.typesafeConfig)
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
api(libs.guice)
|
api(libs.guice)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -2,6 +2,6 @@
|
|||||||
projectVersion=2.0.0-SNAPSHOT
|
projectVersion=2.0.0-SNAPSHOT
|
||||||
|
|
||||||
# Gradle Properties
|
# Gradle Properties
|
||||||
|
org.gradle.configureondemand=true
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.daemon=true
|
|
||||||
@@ -4,17 +4,15 @@ metadata:
|
|||||||
- plugins
|
- plugins
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
net.kyori.blossom: 1.2.0
|
net.kyori.blossom: 1.3.0
|
||||||
net.kyori.indra: &indra 2.0.5
|
|
||||||
net.kyori.indra.checkstyle: *indra
|
|
||||||
net.kyori.indra.publishing: *indra
|
|
||||||
net.kyori.indra.git: *indra
|
|
||||||
com.github.johnrengelman.shadow: 7.1.0-hexaoxide-SNAPSHOT # todo: temporary until shadow bumps jdependency for Record support
|
|
||||||
net.minecrell.plugin-yml.bukkit: 0.4.0
|
net.minecrell.plugin-yml.bukkit: 0.4.0
|
||||||
org.spongepowered.gradle.plugin: 1.1.1
|
org.spongepowered.gradle.plugin: 1.1.1
|
||||||
xyz.jpenilla.run-paper: 1.0.1
|
xyz.jpenilla.run-paper: 1.0.2
|
||||||
|
|
||||||
versions:
|
versions:
|
||||||
|
indra: 2.0.5
|
||||||
|
# todo: temporary until shadow bumps jdependency for Record support
|
||||||
|
shadow: 7.1.0-hexaoxide-SNAPSHOT
|
||||||
adventure: 4.7.0
|
adventure: 4.7.0
|
||||||
minimessage: 4.1.0-SNAPSHOT
|
minimessage: 4.1.0-SNAPSHOT
|
||||||
cloud: 1.5.0-SNAPSHOT
|
cloud: 1.5.0-SNAPSHOT
|
||||||
@@ -162,4 +160,15 @@ dependencies:
|
|||||||
name: velocity-api
|
name: velocity-api
|
||||||
version: { ref: velocityApi }
|
version: { ref: velocityApi }
|
||||||
|
|
||||||
|
# for build-logic
|
||||||
|
indraCommon:
|
||||||
|
group: net.kyori
|
||||||
|
name: indra-common
|
||||||
|
version: { ref: indra }
|
||||||
|
# todo: temporary until shadow bumps jdependency for Record support
|
||||||
|
shadow:
|
||||||
|
group: com.github.johnrengelman
|
||||||
|
name: shadow
|
||||||
|
version: { ref: shadow }
|
||||||
|
|
||||||
bundles:
|
bundles:
|
||||||
+9
-19
@@ -56,23 +56,13 @@ plugins {
|
|||||||
|
|
||||||
rootProject.name = "CarbonChat"
|
rootProject.name = "CarbonChat"
|
||||||
|
|
||||||
setupSubproject("carbonchat-api") {
|
sequenceOf(
|
||||||
projectDir = file("api")
|
"api",
|
||||||
}
|
"common",
|
||||||
setupSubproject("carbonchat-common") {
|
"bukkit",
|
||||||
projectDir = file("common")
|
"sponge",
|
||||||
}
|
"velocity"
|
||||||
setupSubproject("carbonchat-bukkit") {
|
).forEach {
|
||||||
projectDir = file("bukkit")
|
include("carbonchat-$it")
|
||||||
}
|
project(":carbonchat-$it").projectDir = file(it)
|
||||||
setupSubproject("carbonchat-sponge") {
|
|
||||||
projectDir = file("sponge")
|
|
||||||
}
|
|
||||||
setupSubproject("carbonchat-velocity") {
|
|
||||||
projectDir = file("velocity")
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun setupSubproject(name: String, block: ProjectDescriptor.() -> Unit) {
|
|
||||||
include(name)
|
|
||||||
project(":$name").apply(block)
|
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,8 @@ tasks {
|
|||||||
classpath(velocityRun.asFileTree)
|
classpath(velocityRun.asFileTree)
|
||||||
workingDir = layout.projectDirectory.dir("run").asFile
|
workingDir = layout.projectDirectory.dir("run").asFile
|
||||||
|
|
||||||
dependsOn(shadowJar)
|
val pluginJar = shadowJar.flatMap { it.archiveFile }
|
||||||
|
inputs.file(pluginJar)
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
if (!workingDir.exists()) {
|
if (!workingDir.exists()) {
|
||||||
@@ -51,7 +52,7 @@ tasks {
|
|||||||
plugins.mkdirs()
|
plugins.mkdirs()
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar.get().archiveFile.get().asFile.copyTo(plugins.resolve("carbon.jar"), overwrite = true)
|
pluginJar.get().asFile.copyTo(plugins.resolve("carbon.jar"), overwrite = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user