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
@@ -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