* Fix Gradle deprecations By using test suites, we explicitely configure the relevant dependencies on the test sourceset. This is not done by merely configuring the test task. * Switch to maintained version of Shadow * Update to Gradle 8.14.2
37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
import org.gradle.jvm.tasks.Jar
|
|
import org.gradle.kotlin.dsl.withType
|
|
import java.io.ByteArrayOutputStream
|
|
|
|
// This interface is needed as a workaround to get an instance of ExecOperations
|
|
interface Injected {
|
|
@get:Inject
|
|
val execOps: ExecOperations
|
|
}
|
|
|
|
val currentShortRevision = ByteArrayOutputStream().use {
|
|
val execOps = objects.newInstance<Injected>().execOps
|
|
execOps.exec {
|
|
executable = "git"
|
|
args = listOf("rev-parse", "HEAD")
|
|
standardOutput = it
|
|
}
|
|
it.toString().trim().substring(0, 8)
|
|
}
|
|
|
|
tasks.withType<Jar> {
|
|
manifest {
|
|
val buildNumber = System.getenv("BUILD_NUMBER")
|
|
val velocityHumanVersion: String =
|
|
if (project.version.toString().endsWith("-SNAPSHOT")) {
|
|
if (buildNumber == null) {
|
|
"${project.version} (git-$currentShortRevision)"
|
|
} else {
|
|
"${project.version} (git-$currentShortRevision-b$buildNumber)"
|
|
}
|
|
} else {
|
|
archiveVersion.get()
|
|
}
|
|
attributes["Implementation-Version"] = velocityHumanVersion
|
|
}
|
|
}
|