mirror of
https://github.com/apple/pkl.git
synced 2026-06-09 07:12:45 +02:00
Add support for Windows (#492)
This adds support for Windows. The in-language path separator is still `/`, to ensure Pkl programs are cross-platform. Log lines are written using CRLF endings on Windows. Modules that are combined with `--module-output-separator` uses LF endings to ensure consistent rendering across platforms. `jpkl` does not work on Windows as a direct executable. However, it can work with `java -jar jpkl`. Additional details: * Adjust git settings for Windows * Add native executable for pkl cli * Add jdk17 windows Gradle check in CI * Adjust CI test reports to be staged within Gradle rather than by shell script. * Fix: encode more characters that are not safe Windows paths * Skip running tests involving symbolic links on Windows (these require administrator privileges to run). * Introduce custom implementation of `IoUtils.relativize` * Allow Gradle to initialize ExecutableJar `Property` values * Add Gradle flag to enable remote JVM debugging Co-authored-by: Philip K.F. Hölzenspies <holzensp@gmail.com>
This commit is contained in:
@@ -134,7 +134,7 @@ public abstract class ModulesTask extends BasePklTask {
|
||||
*/
|
||||
private URI parsedModuleNotationToUri(Object notation) {
|
||||
if (notation instanceof File file) {
|
||||
return IoUtils.createUri(file.getPath());
|
||||
return IoUtils.createUri(IoUtils.toNormalizedPathString(file.toPath()));
|
||||
} else if (notation instanceof URI uri) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.pkl.gradle
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.pkl.commons.readString
|
||||
import org.pkl.commons.readString
|
||||
import org.pkl.commons.test.PackageServer
|
||||
import org.pkl.commons.toNormalizedPathString
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
@@ -199,8 +201,8 @@ class EvaluatorsTest : AbstractTest() {
|
||||
|
||||
@Test
|
||||
fun `source module URIs`() {
|
||||
val pklFile = writeFile(
|
||||
"test.pkl", """
|
||||
writeFile(
|
||||
"testDir/test.pkl", """
|
||||
person {
|
||||
name = "Pigeon"
|
||||
age = 20 + 10
|
||||
@@ -218,7 +220,7 @@ class EvaluatorsTest : AbstractTest() {
|
||||
evaluators {
|
||||
evalTest {
|
||||
sourceModules = [uri("modulepath:/test.pkl")]
|
||||
modulePath.from "${pklFile.parent}"
|
||||
modulePath.from layout.projectDirectory.dir("testDir")
|
||||
outputFile = layout.projectDirectory.file("test.pcf")
|
||||
settingsModule = "pkl:settings"
|
||||
}
|
||||
@@ -387,7 +389,7 @@ class EvaluatorsTest : AbstractTest() {
|
||||
@Test
|
||||
fun `explicitly set cache dir`(@TempDir tempDir: Path) {
|
||||
writeBuildFile("pcf", """
|
||||
moduleCacheDir = file("$tempDir")
|
||||
moduleCacheDir = file("${tempDir.toUri()}")
|
||||
""".trimIndent())
|
||||
writeFile(
|
||||
"test.pkl",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.pkl.gradle
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.pkl.commons.toNormalizedPathString
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.readText
|
||||
@@ -46,8 +47,7 @@ class TestsTest : AbstractTest() {
|
||||
|
||||
val output = runTask("evalTest", expectFailure = true).output.stripFilesAndLines()
|
||||
|
||||
assertThat(output.trimStart()).startsWith("""
|
||||
> Task :evalTest FAILED
|
||||
assertThat(output).contains("""
|
||||
module test (file:///file, line x)
|
||||
test ❌
|
||||
Error:
|
||||
@@ -143,7 +143,7 @@ class TestsTest : AbstractTest() {
|
||||
val pklFile = writePklFile(contents = bigTest)
|
||||
writeFile("test.pkl-expected.pcf", bigTestExpected)
|
||||
|
||||
writeBuildFile("junitReportsDir = file('${pklFile.parent}/build')")
|
||||
writeBuildFile("junitReportsDir = file('${pklFile.parent.toNormalizedPathString()}/build')")
|
||||
|
||||
runTask("evalTest", expectFailure = true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user