build script cleanup

This commit is contained in:
jmp committed 2021-05-20 00:43:13 -07:00
1 parent bef6eff47c
commit da4b5051ca
11 files changed
+53 -23

No files matched your search

+3
View File
@@ -28,3 +28,6 @@ indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = off
[{*.kt,*.kts,*.yml}]
indent_size = 2
@@ -1,5 +1,6 @@
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
repositories {
@@ -0,0 +1,20 @@
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
open 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 }))
@TaskAction
private fun copyFile() {
destinationDirectory.get().asFile.mkdirs()
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
}
}
Whitespace-only changes.
@@ -0,0 +1,23 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("com.github.johnrengelman.shadow")
}
tasks {
named<Jar>("jar") {
archiveClassifier.set("unshaded")
}
val shadowJar = named<ShadowJar>("shadowJar") {
archiveClassifier.set(null as String?)
configureShadowJar()
}
val copyJar = register<FileCopyTask>("copyJar") {
fileToCopy.set(shadowJar.flatMap { it.archiveFile })
destinationDirectory.set(rootProject.buildDir.resolve("libs"))
dependsOn(shadowJar)
}
named<DefaultTask>("build") {
dependsOn(copyJar)
}
}
@@ -27,16 +27,7 @@ fun ShadowJar.standardRelocations() {
fun ShadowJar.configureShadowJar() {
minimize()
standardRelocations()
doLast {
val archive = archiveFile.get().asFile
val libs = project.rootProject.buildDir.resolve("libs")
libs.mkdirs()
archive.copyTo(libs.resolve(archive.name), overwrite = true)
}
dependencies {
// not needed at runtime
exclude(dependency("com.google.code.findbugs:jsr305"))
+2 -2
View File
@@ -1,9 +1,9 @@
import net.kyori.indra.repository.sonatypeSnapshots
plugins {
id("carbon-build-logic")
id("net.kyori.indra")
id("net.kyori.indra.git")
id("net.kyori.indra.checkstyle")
}
group = "net.draycia"
@@ -45,7 +45,7 @@ subprojects {
}
dependencies {
checkstyle(rootProject.libs.stylecheck)
"checkstyle"(rootProject.libs.stylecheck)
}
configure<JavaPluginConvention> {
+1 -6
View File
@@ -1,7 +1,7 @@
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription.Permission.Default.TRUE
plugins {
id("com.github.johnrengelman.shadow")
id("carbon-shadow-subproject")
id("net.minecrell.plugin-yml.bukkit")
id("xyz.jpenilla.run-paper")
}
@@ -25,12 +25,7 @@ dependencies {
}
tasks {
build {
dependsOn(shadowJar)
}
shadowJar {
archiveFileName.set(project.name + "-" + project.version + ".jar")
configureShadowJar()
relocateDependency("io.papermc.lib")
relocateDependency("io.leangen.geantyref")
}
+2
View File
@@ -14,6 +14,8 @@ plugins {
rootProject.name = "CarbonChat"
includeBuild("build-logic")
setupSubproject("carbonchat-api") {
projectDir = file("api")
}
+1 -6
View File
@@ -3,7 +3,7 @@ import org.spongepowered.plugin.metadata.PluginDependency
import java.util.Locale
plugins {
id("com.github.johnrengelman.shadow")
id("carbon-shadow-subproject")
id("org.spongepowered.gradle.plugin")
}
@@ -17,12 +17,7 @@ tasks {
runServer {
classpath(shadowJar)
}
build {
dependsOn(shadowJar)
}
shadowJar {
archiveFileName.set(project.name + "-" + project.version + ".jar")
configureShadowJar()
dependencies {
// included in sponge
exclude(dependency("io.leangen.geantyref:geantyref"))