mirror of
https://github.com/apple/pkl.git
synced 2026-04-25 09:48:41 +02:00
Fix shadow jar logic (#998)
Fix an incorrect relocation setting. Also, add tests to start the shadow jar, and also to test the shadow jar settings.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.*
|
||||
import kotlin.io.path.createDirectories
|
||||
import kotlin.io.path.writeText
|
||||
|
||||
plugins {
|
||||
pklAllProjects
|
||||
@@ -65,6 +67,63 @@ val javadocJar by
|
||||
|
||||
tasks.shadowJar { archiveBaseName.set("pkl-tools-all") }
|
||||
|
||||
private fun Exec.configureTestStartFatJar(launcher: Provider<JavaLauncher>) {
|
||||
dependsOn(tasks.shadowJar)
|
||||
group = "verification"
|
||||
|
||||
// placeholder output to satisfy up-to-date check
|
||||
val outputFile = layout.buildDirectory.file("testStartFatJar/${name}.txt")
|
||||
outputs.file(outputFile)
|
||||
|
||||
inputs.files(tasks.shadowJar)
|
||||
executable = launcher.get().executablePath.asFile.absolutePath
|
||||
|
||||
argumentProviders.add(
|
||||
CommandLineArgumentProvider {
|
||||
buildList {
|
||||
add("-cp")
|
||||
add(tasks.shadowJar.get().outputs.files.singleFile.absolutePath)
|
||||
add("org.pkl.cli.Main")
|
||||
add("eval")
|
||||
add("-x")
|
||||
add("1 + 1")
|
||||
add("pkl:base")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
doLast {
|
||||
outputFile.get().asFile.toPath().let { file ->
|
||||
file.parent.createDirectories()
|
||||
file.writeText("OK")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val testStartFatJar by
|
||||
tasks.registering(Exec::class) { configureTestStartFatJar(buildInfo.javaTestLauncher) }
|
||||
|
||||
tasks.validateFatJar { dependsOn(testStartFatJar) }
|
||||
|
||||
for (jdkTarget in buildInfo.jdkTestRange) {
|
||||
if (buildInfo.jdkToolchainVersion == jdkTarget) {
|
||||
tasks.register("testStartFatJarJdk${jdkTarget.asInt()}") {
|
||||
group = "verification"
|
||||
description = "alias for testStartFatJar"
|
||||
dependsOn(testStartFatJar)
|
||||
}
|
||||
} else {
|
||||
val task =
|
||||
tasks.register("testStartFatJarJdk${jdkTarget.asInt()}", Exec::class) {
|
||||
val launcher = project.javaToolchains.launcherFor { languageVersion = jdkTarget }
|
||||
configureTestStartFatJar(launcher)
|
||||
}
|
||||
if (buildInfo.multiJdkTesting) {
|
||||
tasks.validateFatJar { dependsOn(task) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
named<MavenPublication>("fatJar") {
|
||||
|
||||
Reference in New Issue
Block a user