mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +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
@@ -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()
|
||||
Reference in new issue
Block a user