Improved: Default build task
This commit is contained in:
parent
8480f5a52d
commit
594d00bd93
3 changed files with 61 additions and 9 deletions
|
@ -1,9 +1,5 @@
|
|||
import java.io.ByteArrayOutputStream
|
||||
|
||||
plugins {
|
||||
entitylib.`library-conventions`
|
||||
}
|
||||
|
||||
group = "me.tofaa.entitylib"
|
||||
description = rootProject.name
|
||||
val fullVersion = "2.4.1"
|
||||
|
@ -25,3 +21,51 @@ fun getVersionMeta(): String {
|
|||
return "$commitHash-SNAPSHOT"
|
||||
}
|
||||
version = "$fullVersion${getVersionMeta()}"
|
||||
|
||||
tasks {
|
||||
wrapper {
|
||||
gradleVersion = "8.8"
|
||||
distributionType = Wrapper.DistributionType.ALL
|
||||
}
|
||||
|
||||
register("build") {
|
||||
// Filter out the 'platforms' directory itself, but include its subprojects
|
||||
val subModuleBuildTasks = subprojects
|
||||
.filter { it.name != "platforms" }
|
||||
.mapNotNull { it.tasks.findByName("build") }
|
||||
|
||||
dependsOn(subModuleBuildTasks)
|
||||
group = "build"
|
||||
|
||||
doLast {
|
||||
val buildOut = project.layout.buildDirectory.dir("libs").get().asFile.apply {
|
||||
if (!exists()) mkdirs()
|
||||
}
|
||||
|
||||
subprojects.forEach { subproject ->
|
||||
val subIn = subproject.layout.buildDirectory.dir("libs").get().asFile
|
||||
if (subIn.exists()) {
|
||||
copy {
|
||||
from(subIn) {
|
||||
include("EntityLib-*.jar")
|
||||
exclude("*-javadoc.jar", "*-sources.jar")
|
||||
}
|
||||
into(buildOut)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
register<Delete>("clean") {
|
||||
val cleanTasks = subprojects
|
||||
.filter { it.name != "platforms" }
|
||||
.mapNotNull { it.tasks.findByName("clean") }
|
||||
|
||||
dependsOn(cleanTasks)
|
||||
group = "build"
|
||||
delete(rootProject.layout.buildDirectory)
|
||||
}
|
||||
|
||||
defaultTasks("build")
|
||||
}
|
||||
|
|
|
@ -48,3 +48,14 @@ tasks {
|
|||
|
||||
defaultTasks("build")
|
||||
}
|
||||
|
||||
// So that SNAPSHOT is always the latest SNAPSHOT
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
|
||||
}
|
||||
|
||||
val taskNames = gradle.startParameter.taskNames
|
||||
if (taskNames.any { it.contains("build") }
|
||||
&& taskNames.any { it.contains("publish") }) {
|
||||
throw IllegalStateException("Cannot build and publish at the same time.")
|
||||
}
|
|
@ -1,5 +1,2 @@
|
|||
jdk:
|
||||
- temurin-21
|
||||
|
||||
install:
|
||||
- ./gradlew clean build
|
||||
|
|
Loading…
Reference in a new issue