mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +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 {
|
||||
// Doesn't add any dependencies, only version constraints
|
||||
api(platform(libs.adventureBom))
|
||||
|
||||
@@ -7,13 +7,10 @@ repositories {
|
||||
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 {
|
||||
// temporary until shadow bumps jdependency for Record support
|
||||
//implementation("gradle.plugin.com.github.jengelman.gradle.plugins", "shadow", "7.0.0")
|
||||
implementation("com.github.johnrengelman", "shadow", "7.1.0-hexaoxide-SNAPSHOT")
|
||||
implementation(libs.shadow)
|
||||
implementation(libs.indraCommon)
|
||||
|
||||
val indraVersion = "2.0.5"
|
||||
implementation("net.kyori", "indra-common", indraVersion)
|
||||
implementation("net.kyori", "indra-git", indraVersion)
|
||||
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
}
|
||||
@@ -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.tasks.InputFile
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
abstract class FileCopyTask : DefaultTask() {
|
||||
@InputFile
|
||||
val fileToCopy = project.objects.fileProperty()
|
||||
|
||||
@OutputDirectory
|
||||
val destinationDirectory = project.objects.directoryProperty()
|
||||
|
||||
private val destination = project.objects.fileProperty().convention(destinationDirectory.file(fileToCopy.map { it.asFile.name }))
|
||||
@OutputFile
|
||||
val destination = project.objects.fileProperty()
|
||||
|
||||
@TaskAction
|
||||
private fun copyFile() {
|
||||
destinationDirectory.get().asFile.mkdirs()
|
||||
destination.get().asFile.parentFile.mkdirs()
|
||||
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
|
||||
}
|
||||
}
|
||||
@@ -12,3 +12,14 @@ indra {
|
||||
}
|
||||
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 {
|
||||
val copyJar = register<FileCopyTask>("copyJar") {
|
||||
fileToCopy.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
|
||||
dependsOn(platformExtension.jarTask)
|
||||
destination.set(rootProject.layout.buildDirectory.dir("libs").flatMap {
|
||||
it.file(fileToCopy.map { file -> file.asFile.name })
|
||||
})
|
||||
}
|
||||
build {
|
||||
dependsOn(copyJar)
|
||||
@@ -18,5 +19,6 @@ tasks {
|
||||
val projectVersion = version as String
|
||||
if (projectVersion.endsWith("-SNAPSHOT")) {
|
||||
// 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 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.
|
||||
@@ -36,3 +40,9 @@ fun ShadowJar.configureShadowJar() {
|
||||
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"
|
||||
val projectVersion: String by project // get from gradle.properties
|
||||
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 {
|
||||
api(projects.carbonchatApi)
|
||||
api(projects.carbonchatApi)
|
||||
|
||||
// Configs
|
||||
api(libs.configurateHocon)
|
||||
api(libs.adventureSerializerConfigurate4) {
|
||||
isTransitive = false
|
||||
}
|
||||
api(libs.typesafeConfig)
|
||||
// Configs
|
||||
api(libs.configurateHocon)
|
||||
api(libs.adventureSerializerConfigurate4) {
|
||||
isTransitive = false
|
||||
}
|
||||
api(libs.typesafeConfig)
|
||||
|
||||
// Other
|
||||
api(libs.guice)
|
||||
// Other
|
||||
api(libs.guice)
|
||||
}
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
projectVersion=2.0.0-SNAPSHOT
|
||||
|
||||
# Gradle Properties
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.daemon=true
|
||||
@@ -4,17 +4,15 @@ metadata:
|
||||
- plugins
|
||||
|
||||
plugins:
|
||||
net.kyori.blossom: 1.2.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.kyori.blossom: 1.3.0
|
||||
net.minecrell.plugin-yml.bukkit: 0.4.0
|
||||
org.spongepowered.gradle.plugin: 1.1.1
|
||||
xyz.jpenilla.run-paper: 1.0.1
|
||||
xyz.jpenilla.run-paper: 1.0.2
|
||||
|
||||
versions:
|
||||
indra: 2.0.5
|
||||
# todo: temporary until shadow bumps jdependency for Record support
|
||||
shadow: 7.1.0-hexaoxide-SNAPSHOT
|
||||
adventure: 4.7.0
|
||||
minimessage: 4.1.0-SNAPSHOT
|
||||
cloud: 1.5.0-SNAPSHOT
|
||||
@@ -162,4 +160,15 @@ dependencies:
|
||||
name: velocity-api
|
||||
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:
|
||||
+9
-19
@@ -56,23 +56,13 @@ plugins {
|
||||
|
||||
rootProject.name = "CarbonChat"
|
||||
|
||||
setupSubproject("carbonchat-api") {
|
||||
projectDir = file("api")
|
||||
}
|
||||
setupSubproject("carbonchat-common") {
|
||||
projectDir = file("common")
|
||||
}
|
||||
setupSubproject("carbonchat-bukkit") {
|
||||
projectDir = file("bukkit")
|
||||
}
|
||||
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)
|
||||
sequenceOf(
|
||||
"api",
|
||||
"common",
|
||||
"bukkit",
|
||||
"sponge",
|
||||
"velocity"
|
||||
).forEach {
|
||||
include("carbonchat-$it")
|
||||
project(":carbonchat-$it").projectDir = file(it)
|
||||
}
|
||||
@@ -40,7 +40,8 @@ tasks {
|
||||
classpath(velocityRun.asFileTree)
|
||||
workingDir = layout.projectDirectory.dir("run").asFile
|
||||
|
||||
dependsOn(shadowJar)
|
||||
val pluginJar = shadowJar.flatMap { it.archiveFile }
|
||||
inputs.file(pluginJar)
|
||||
|
||||
doFirst {
|
||||
if (!workingDir.exists()) {
|
||||
@@ -51,7 +52,7 @@ tasks {
|
||||
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