Update Kotlin to 2.0 (#900)

- update Kotlin from 1.7.10 to 2.0.21
  - Kotlin 1.6 dependencies in Gradle lock files are expected because kotlinc,
    which is also used by some tests, internally uses some 1.6 dependencies
    for backwards compatibility reasons.
- update kotlinx-html and kotlinx-serialization
- adapt Kotlin code where necessary
- use Kotlin stdlib Path APIs where possible
- fix IntelliJ Kotlin inspection warnings
- reformat code with `./gradlew spotlessApply`
  - ktfmt adds lots of trailing commas
- Add workaround to fix IntelliJ "unresolved reference" errors
This commit is contained in:
odenix
2025-01-23 14:41:59 -08:00
committed by GitHub
parent cdd6d52642
commit 258eda8630
87 changed files with 1042 additions and 1004 deletions
+1 -1
View File
@@ -74,4 +74,4 @@
<option name="processComments" value="true" /> <option name="processComments" value="true" />
</inspection_tool> </inspection_tool>
</profile> </profile>
</component> </component>
+21 -16
View File
@@ -3,7 +3,6 @@
# This file is expected to be part of source control. # This file is expected to be part of source control.
com.tunnelvisionlabs:antlr4-runtime:4.9.0=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
net.sf.jopt-simple:jopt-simple:5.0.4=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath net.sf.jopt-simple:jopt-simple:5.0.4=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath
org.apache.commons:commons-math3:3.6.1=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath org.apache.commons:commons-math3:3.6.1=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
@@ -11,21 +10,27 @@ org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenc
org.graalvm.compiler:compiler:23.0.6=graal org.graalvm.compiler:compiler:23.0.6=graal
org.graalvm.sdk:graal-sdk:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle org.graalvm.sdk:graal-sdk:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle
org.graalvm.truffle:truffle-api:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle org.graalvm.truffle:truffle-api:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=kotlinCompilerClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathJmh,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
+4 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins { `kotlin-dsl` } plugins { `kotlin-dsl` }
dependencies { dependencies {
@@ -31,4 +33,4 @@ java {
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { target { compilations.configureEach { kotlinOptions { jvmTarget = "17" } } } } kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_17 } }
@@ -15,6 +15,7 @@
*/ */
import com.diffplug.gradle.spotless.KotlinGradleExtension import com.diffplug.gradle.spotless.KotlinGradleExtension
import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.accessors.dm.LibrariesForLibs
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { id("com.diffplug.spotless") } plugins { id("com.diffplug.spotless") }
@@ -48,9 +49,9 @@ plugins.withType(JavaPlugin::class).configureEach {
} }
tasks.withType<KotlinCompile>().configureEach { tasks.withType<KotlinCompile>().configureEach {
kotlinOptions { compilerOptions {
jvmTarget = "17" jvmTarget = JvmTarget.JVM_17
freeCompilerArgs = freeCompilerArgs + listOf("-Xjsr305=strict", "-Xjvm-default=all") freeCompilerArgs.addAll("-Xjsr305=strict", "-Xjvm-default=all")
} }
} }
+22 -16
View File
@@ -4,26 +4,32 @@
com.tunnelvisionlabs:antlr4-runtime:4.9.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:2.0.21=testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
+1 -1
View File
@@ -38,7 +38,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
private val projectDir = rootProjectDir.resolve("docs") private val projectDir = rootProjectDir.resolve("docs")
private val docsDir = projectDir.resolve("modules") private val docsDir = projectDir.resolve("modules")
companion object { private companion object {
val headingRegex = Regex("""(?u)^\s*(=++)\s*(.+)""") val headingRegex = Regex("""(?u)^\s*(=++)\s*(.+)""")
val collapsibleBlockRegex = Regex("""(?u)^\s*\[%collapsible""") val collapsibleBlockRegex = Regex("""(?u)^\s*\[%collapsible""")
val codeBlockRegex = Regex("""(?u)^\s*\[source(?:%(tested|parsed)(%error)?)?(?:,\{?([a-zA-Z-_]+)}?)?""") val codeBlockRegex = Regex("""(?u)^\s*\[source(?:%(tested|parsed)(%error)?)?(?:,\{?([a-zA-Z-_]+)}?)?""")
+4 -7
View File
@@ -29,13 +29,11 @@ jmh = "1.+"
jmhPlugin = "0.7.2" jmhPlugin = "0.7.2"
jsr305 = "3.+" jsr305 = "3.+"
junit = "5.+" junit = "5.+"
kotlin = "1.7.10" kotlin = "2.0.21"
# 1.7+ generates much more verbose code # 1.7+ generates much more verbose code
kotlinPoet = "1.6.+" kotlinPoet = "1.6.+"
# freeze until updating Kotlin version kotlinxHtml = "0.11.0"
kotlinxHtml = "0.8.1" kotlinxSerialization = "1.8.0"
# freeze until updating Kotlin version
kotlinxSerialization = "1.5.1"
ktfmt = "0.53" ktfmt = "0.53"
# replaces nuValidator's log4j dependency # replaces nuValidator's log4j dependency
# something related to log4j-1.2-api is apparently broken in 2.17.2 # something related to log4j-1.2-api is apparently broken in 2.17.2
@@ -77,8 +75,7 @@ kotlinCompilerEmbeddable = { group = "org.jetbrains.kotlin", name = "kotlin-comp
kotlinPlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } kotlinPlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinPoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinPoet" } kotlinPoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinPoet" }
kotlinReflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" } kotlinReflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
kotlinScriptingCompilerEmbeddable = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-compiler-embeddable", version.ref = "kotlin" } kotlinScripting = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-jsr223", version.ref = "kotlin" }
kotlinScriptUtil = { group = "org.jetbrains.kotlin", name = "kotlin-script-util", version.ref = "kotlin" }
kotlinStdLib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlinStdLib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlinxHtml = { group = "org.jetbrains.kotlinx", name = "kotlinx-html-jvm", version.ref = "kotlinxHtml" } kotlinxHtml = { group = "org.jetbrains.kotlinx", name = "kotlinx-html-jvm", version.ref = "kotlinxHtml" }
kotlinxSerializationJson = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerialization" } kotlinxSerializationJson = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
+22 -16
View File
@@ -23,7 +23,6 @@ com.tunnelvisionlabs:antlr4-runtime:4.9.0=runtimeClasspath,testRuntimeClasspath
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
commons-io:commons-io:2.11.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath commons-io:commons-io:2.11.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
net.javacrumbs.json-unit:json-unit-core:2.40.1=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.javacrumbs.json-unit:json-unit-core:2.40.1=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.minidev:accessors-smart:2.5.1=testRuntimeClasspath net.minidev:accessors-smart:2.5.1=testRuntimeClasspath
net.minidev:json-smart:2.5.1=testRuntimeClasspath net.minidev:json-smart:2.5.1=testRuntimeClasspath
@@ -64,21 +63,28 @@ org.graalvm.sdk:graal-sdk:23.0.6=compileClasspath,compileOnlyDependenciesMetadat
org.graalvm.truffle:truffle-api:23.0.6=compileClasspath,compileOnlyDependenciesMetadata,runtimeClasspath,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=compileClasspath,compileOnlyDependenciesMetadata,runtimeClasspath,testRuntimeClasspath
org.hamcrest:hamcrest-core:2.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.hamcrest:hamcrest-core:2.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.hamcrest:hamcrest:2.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.hamcrest:hamcrest:2.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jline:jline-native:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jline:jline-native:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jline:jline-reader:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jline:jline-reader:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jline:jline-terminal-jansi:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jline:jline-terminal-jansi:3.23.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -21,11 +21,11 @@ import java.io.Writer
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import java.nio.file.StandardOpenOption import java.nio.file.StandardOpenOption
import kotlin.io.path.createParentDirectories
import kotlin.io.path.exists import kotlin.io.path.exists
import kotlin.io.path.isDirectory import kotlin.io.path.isDirectory
import org.pkl.commons.cli.CliCommand import org.pkl.commons.cli.CliCommand
import org.pkl.commons.cli.CliException import org.pkl.commons.cli.CliException
import org.pkl.commons.createParentDirectories
import org.pkl.commons.currentWorkingDir import org.pkl.commons.currentWorkingDir
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.Closeables import org.pkl.core.Closeables
@@ -165,13 +165,13 @@ constructor(
options.moduleOutputSeparator + '\n', options.moduleOutputSeparator + '\n',
Charsets.UTF_8, Charsets.UTF_8,
StandardOpenOption.WRITE, StandardOpenOption.WRITE,
StandardOpenOption.APPEND StandardOpenOption.APPEND,
) )
outputFile.writeString( outputFile.writeString(
output, output,
Charsets.UTF_8, Charsets.UTF_8,
StandardOpenOption.WRITE, StandardOpenOption.WRITE,
StandardOpenOption.APPEND StandardOpenOption.APPEND,
) )
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -80,6 +80,6 @@ data class CliEvaluatorOptions(
) { ) {
companion object { companion object {
val defaults = CliEvaluatorOptions(CliBaseOptions()) val defaults: CliEvaluatorOptions = CliEvaluatorOptions(CliBaseOptions())
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
package org.pkl.cli package org.pkl.cli
import java.io.Writer import java.io.Writer
import kotlin.io.path.createParentDirectories
import org.pkl.commons.cli.CliCommand import org.pkl.commons.cli.CliCommand
import org.pkl.commons.createParentDirectories
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.Closeables import org.pkl.core.Closeables
import org.pkl.core.ModuleSource import org.pkl.core.ModuleSource
@@ -26,7 +26,7 @@ class CliImportAnalyzer
@JvmOverloads @JvmOverloads
constructor( constructor(
private val options: CliImportAnalyzerOptions, private val options: CliImportAnalyzerOptions,
private val consoleWriter: Writer = System.out.writer() private val consoleWriter: Writer = System.out.writer(),
) : CliCommand(options.base) { ) : CliCommand(options.base) {
override fun doRun() { override fun doRun() {
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.pkl.core.messaging.ProtocolException
import org.pkl.server.Server import org.pkl.server.Server
class CliServer(options: CliBaseOptions) : CliCommand(options) { class CliServer(options: CliBaseOptions) : CliCommand(options) {
override fun doRun() = override fun doRun(): Unit =
try { try {
val server = Server.stream(System.`in`, System.out) val server = Server.stream(System.`in`, System.out)
server.use { it.start() } server.use { it.start() }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ private val cmdRegex = Regex(":(\\p{Alpha}*)(\\p{Space}*)(.*)", RegexOption.DOT_
internal fun getMatchingCommands(input: String): List<ParsedCommand> { internal fun getMatchingCommands(input: String): List<ParsedCommand> {
val match = cmdRegex.matchEntire(input) ?: return listOf() val match = cmdRegex.matchEntire(input) ?: return listOf()
val (cmd, ws, arg) = match.destructured val (cmd, ws, arg) = match.destructured
return Command.values() return Command.entries
.filter { it.toString().lowercase().startsWith(cmd) } .filter { it.toString().lowercase().startsWith(cmd) }
.map { ParsedCommand(it, cmd, ws, arg) } .map { ParsedCommand(it, cmd, ws, arg) }
} }
@@ -29,7 +29,7 @@ internal data class ParsedCommand(
val type: Command, val type: Command,
val cmd: String, val cmd: String,
val ws: String, val ws: String,
val arg: String val arg: String,
) )
internal enum class Command { internal enum class Command {
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ internal abstract class JLineFileNameCompleter : Completer {
override fun complete( override fun complete(
reader: LineReader, reader: LineReader,
commandLine: ParsedLine, commandLine: ParsedLine,
candidates: MutableList<Candidate> candidates: MutableList<Candidate>,
) { ) {
val buffer = commandLine.word().substring(0, commandLine.wordCursor()) val buffer = commandLine.word().substring(0, commandLine.wordCursor())
val current: Path val current: Path
@@ -78,7 +78,7 @@ internal abstract class JLineFileNameCompleter : Completer {
null, null,
if (reader.isSet(LineReader.Option.AUTO_REMOVE_SLASH)) sep else null, if (reader.isSet(LineReader.Option.AUTO_REMOVE_SLASH)) sep else null,
null, null,
false false,
) )
) )
} else { } else {
@@ -90,7 +90,7 @@ internal abstract class JLineFileNameCompleter : Completer {
null, null,
null, null,
null, null,
true true,
) )
) )
} }
@@ -122,7 +122,7 @@ internal abstract class JLineFileNameCompleter : Completer {
terminal: Terminal, terminal: Terminal,
path: Path, path: Path,
resolver: StyleResolver, resolver: StyleResolver,
separator: String separator: String,
): String { ): String {
val builder = AttributedStringBuilder() val builder = AttributedStringBuilder()
val name = path.fileName.toString() val name = path.fileName.toString()
@@ -162,7 +162,7 @@ internal class FileCompleter(override val userDir: Path) : JLineFileNameComplete
override fun complete( override fun complete(
reader: LineReader, reader: LineReader,
commandLine: ParsedLine, commandLine: ParsedLine,
candidates: MutableList<Candidate> candidates: MutableList<Candidate>,
) { ) {
val loadCmd = val loadCmd =
getMatchingCommands(commandLine.line()).find { it.type == Command.Load && it.ws.isNotEmpty() } getMatchingCommands(commandLine.line()).find { it.type == Command.Load && it.ws.isNotEmpty() }
@@ -174,7 +174,7 @@ internal class FileCompleter(override val userDir: Path) : JLineFileNameComplete
internal object CommandCompleter : Completer { internal object CommandCompleter : Completer {
private val commandCandidates: List<Candidate> = private val commandCandidates: List<Candidate> =
Command.values().map { Candidate(":" + it.toString().lowercase()) } Command.entries.map { Candidate(":" + it.toString().lowercase()) }
override fun complete(reader: LineReader, line: ParsedLine, candidates: MutableList<Candidate>) { override fun complete(reader: LineReader, line: ParsedLine, candidates: MutableList<Candidate>) {
if (line.wordIndex() == 0) candidates.addAll(commandCandidates) if (line.wordIndex() == 0) candidates.addAll(commandCandidates)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -49,6 +49,7 @@ import org.pkl.core.OutputFormat
import org.pkl.core.SecurityManagers import org.pkl.core.SecurityManagers
import org.pkl.core.util.IoUtils import org.pkl.core.util.IoUtils
@OptIn(ExperimentalPathApi::class)
@WireMockTest(httpsEnabled = true, proxyMode = true) @WireMockTest(httpsEnabled = true, proxyMode = true)
class CliEvaluatorTest { class CliEvaluatorTest {
companion object { companion object {
@@ -88,19 +89,20 @@ class CliEvaluatorTest {
val sourceFiles = listOf(writePklFile("test.pkl")) val sourceFiles = listOf(writePklFile("test.pkl"))
val outputFiles = val outputFiles =
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "pcf")
CliBaseOptions(sourceModules = sourceFiles),
outputFormat = "pcf",
)
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
checkOutputFile(outputFiles[0], "test.pcf", """ checkOutputFile(
outputFiles[0],
"test.pcf",
"""
person { person {
name = "pigeon" name = "pigeon"
age = 30 age = 30
} }
""") """,
)
} }
@Test @Test
@@ -108,10 +110,7 @@ person {
val sourceFiles = listOf(writePklFile("test.pkl")) val sourceFiles = listOf(writePklFile("test.pkl"))
val outputFiles = val outputFiles =
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "json")
CliBaseOptions(sourceModules = sourceFiles),
outputFormat = "json",
)
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
@@ -125,7 +124,7 @@ person {
"age": 30 "age": 30
} }
} }
""" """,
) )
} }
@@ -134,18 +133,19 @@ person {
val sourceFiles = listOf(writePklFile("test.pkl")) val sourceFiles = listOf(writePklFile("test.pkl"))
val outputFiles = val outputFiles =
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "yaml")
CliBaseOptions(sourceModules = sourceFiles),
outputFormat = "yaml",
)
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
checkOutputFile(outputFiles[0], "test.yaml", """ checkOutputFile(
outputFiles[0],
"test.yaml",
"""
person: person:
name: pigeon name: pigeon
age: 30 age: 30
""") """,
)
} }
@Test @Test
@@ -153,10 +153,7 @@ person:
val sourceFiles = listOf(writePklFile("test.pkl")) val sourceFiles = listOf(writePklFile("test.pkl"))
val outputFiles = val outputFiles =
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "plist")
CliBaseOptions(sourceModules = sourceFiles),
outputFormat = "plist",
)
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
@@ -178,7 +175,7 @@ person:
</dict> </dict>
</dict> </dict>
</plist> </plist>
""" """,
) )
} }
@@ -187,10 +184,7 @@ person:
val sourceFiles = listOf(writePklFile("test.pkl")) val sourceFiles = listOf(writePklFile("test.pkl"))
val outputFiles = val outputFiles =
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "xml")
CliBaseOptions(sourceModules = sourceFiles),
outputFormat = "xml",
)
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
@@ -205,7 +199,7 @@ person:
<age>30</age> <age>30</age>
</person> </person>
</root> </root>
""" """,
) )
} }
@@ -229,14 +223,11 @@ person:
listOf( listOf(
writePklFile("file1.pkl", "x = 1 + 1"), writePklFile("file1.pkl", "x = 1 + 1"),
writePklFile("file2.pkl", "x = 2 + 2"), writePklFile("file2.pkl", "x = 2 + 2"),
writePklFile("file3.pkl", "x = 3 + 3") writePklFile("file3.pkl", "x = 3 + 3"),
) )
val outputFiles = val outputFiles =
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "pcf")
CliBaseOptions(sourceModules = sourceFiles),
outputFormat = "pcf",
)
) )
assertThat(outputFiles).hasSize(3) assertThat(outputFiles).hasSize(3)
@@ -269,20 +260,24 @@ person:
CliBaseOptions( CliBaseOptions(
sourceModules = sourceModules =
listOf(URI("modulepath:/foo/bar/test.pkl"), URI("modulepath:/foo/bar/test2.pkl")), listOf(URI("modulepath:/foo/bar/test.pkl"), URI("modulepath:/foo/bar/test2.pkl")),
modulePath = listOf(tempDir) modulePath = listOf(tempDir),
), ),
outputFormat = "pcf", outputFormat = "pcf",
outputPath = "$tempDir/%{moduleName}.%{outputFormat}" outputPath = "$tempDir/%{moduleName}.%{outputFormat}",
) )
) )
assertThat(outputFiles).hasSize(2) assertThat(outputFiles).hasSize(2)
checkOutputFile(outputFiles[0], "test.pcf", """ checkOutputFile(
outputFiles[0],
"test.pcf",
"""
person { person {
name = "pigeon" name = "pigeon"
age = 30 age = 30
} }
""") """,
)
checkOutputFile( checkOutputFile(
outputFiles[1], outputFiles[1],
"test2.pcf", "test2.pcf",
@@ -291,7 +286,7 @@ person {
name = "barn owl" name = "barn owl"
age = 30 age = 30
} }
""" """,
) )
} }
@@ -306,7 +301,7 @@ person {
name = read("prop:name") name = read("prop:name")
age = read("prop:age").toInt() age = read("prop:age").toInt()
} }
""" """,
) )
) )
@@ -315,19 +310,23 @@ person {
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions( CliBaseOptions(
sourceModules = sourceFiles, sourceModules = sourceFiles,
externalProperties = mapOf("name" to "pigeon", "age" to "30") externalProperties = mapOf("name" to "pigeon", "age" to "30"),
), ),
outputFormat = "pcf", outputFormat = "pcf",
) )
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
checkOutputFile(outputFiles[0], "test.pcf", """ checkOutputFile(
outputFiles[0],
"test.pcf",
"""
person { person {
name = "pigeon" name = "pigeon"
age = 30 age = 30
} }
""") """,
)
} }
@Test @Test
@@ -351,21 +350,25 @@ person {
sourceModules = listOf(file.toUri()), sourceModules = listOf(file.toUri()),
workingDir = workingDir =
if (relativePath) IoUtils.getCurrentWorkingDir().relativize(dir.parent) if (relativePath) IoUtils.getCurrentWorkingDir().relativize(dir.parent)
else dir.parent else dir.parent,
), ),
outputFormat = "pcf", outputFormat = "pcf",
outputPath = "baz/%{moduleName}.pcf" outputPath = "baz/%{moduleName}.pcf",
) )
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
assertThat(outputFiles[0].normalize()).isEqualTo(dir.parent.resolve("baz/test.pcf")) assertThat(outputFiles[0].normalize()).isEqualTo(dir.parent.resolve("baz/test.pcf"))
checkOutputFile(outputFiles[0], "test.pcf", """ checkOutputFile(
outputFiles[0],
"test.pcf",
"""
person { person {
name = "pigeon" name = "pigeon"
age = 30 age = 30
} }
""") """,
)
} }
@Test @Test
@@ -377,17 +380,21 @@ person {
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(URI("foo/test.pkl")), workingDir = tempDir), CliBaseOptions(sourceModules = listOf(URI("foo/test.pkl")), workingDir = tempDir),
outputFormat = "pcf" outputFormat = "pcf",
) )
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
checkOutputFile(outputFiles[0], "test.pcf", """ checkOutputFile(
outputFiles[0],
"test.pcf",
"""
person { person {
name = "pigeon" name = "pigeon"
age = 30 age = 30
} }
""") """,
)
} }
@Test @Test
@@ -396,10 +403,13 @@ person {
libDir.resolve("someLib.pkl").writeString("x = 1") libDir.resolve("someLib.pkl").writeString("x = 1")
val pklScript = val pklScript =
writePklFile("test.pkl", """ writePklFile(
"test.pkl",
"""
import "modulepath:/foo/someLib.pkl" import "modulepath:/foo/someLib.pkl"
result = someLib.x result = someLib.x
""") """,
)
val outputFiles = val outputFiles =
evalToFiles( evalToFiles(
@@ -407,9 +417,9 @@ result = someLib.x
CliBaseOptions( CliBaseOptions(
sourceModules = listOf(pklScript), sourceModules = listOf(pklScript),
workingDir = tempDir, workingDir = tempDir,
modulePath = listOf("lib".toPath()) modulePath = listOf("lib".toPath()),
), ),
outputFormat = "pcf" outputFormat = "pcf",
) )
) )
@@ -427,7 +437,7 @@ result = someLib.x
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(file), workingDir = workingDir), CliBaseOptions(sourceModules = listOf(file), workingDir = workingDir),
outputPath = "%{moduleDir}/result.pcf", outputPath = "%{moduleDir}/result.pcf",
outputFormat = "pcf" outputFormat = "pcf",
) )
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
@@ -449,7 +459,7 @@ result = someLib.x
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(file), workingDir = workingDir), CliBaseOptions(sourceModules = listOf(file), workingDir = workingDir),
outputFormat = "pcf" outputFormat = "pcf",
) )
) )
assertThat(outputFiles).hasSize(1) assertThat(outputFiles).hasSize(1)
@@ -465,10 +475,10 @@ result = someLib.x
CliEvaluator( CliEvaluator(
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(URI("repl:text"))), CliBaseOptions(sourceModules = listOf(URI("repl:text"))),
outputFormat = "pcf" outputFormat = "pcf",
), ),
stdin, stdin,
stdout stdout,
) )
evaluator.run() evaluator.run()
assertThat(stdout.toString().trim()).isEqualTo(defaultContents.replace("20 + 10", "30").trim()) assertThat(stdout.toString().trim()).isEqualTo(defaultContents.replace("20 + 10", "30").trim())
@@ -480,11 +490,7 @@ result = someLib.x
val module2 = writePklFile("mod2.pkl", "y = 11 + 11") val module2 = writePklFile("mod2.pkl", "y = 11 + 11")
val output = val output =
evalToConsole( evalToConsole(CliEvaluatorOptions(CliBaseOptions(sourceModules = listOf(module1, module2))))
CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(module1, module2)),
)
)
assertThat(output).isEqualTo("x = 42\n---\ny = 22\n") assertThat(output).isEqualTo("x = 42\n---\ny = 22\n")
} }
@@ -498,7 +504,7 @@ result = someLib.x
""" """
function fib(n) = if (n < 2) 0 else fib(n - 1) + fib(n - 2) function fib(n) = if (n < 2) 0 else fib(n - 1) + fib(n - 2)
x = fib(100) x = fib(100)
""" """,
) )
) )
@@ -507,7 +513,7 @@ result = someLib.x
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = sourceFiles, timeout = Duration.ofMillis(100)), CliBaseOptions(sourceModules = sourceFiles, timeout = Duration.ofMillis(100)),
outputFormat = "pcf" outputFormat = "pcf",
) )
) )
} }
@@ -516,16 +522,20 @@ result = someLib.x
@Test @Test
fun `cannot import module located outside root dir`() { fun `cannot import module located outside root dir`() {
val sourceFiles = listOf(writePklFile("test.pkl", """ val sourceFiles =
listOf(
writePklFile(
"test.pkl",
"""
amends "/non/existing.pkl" amends "/non/existing.pkl"
""")) """,
)
)
val e = val e =
assertThrows<CliException> { assertThrows<CliException> {
evalToFiles( evalToFiles(
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles, rootDir = tempDir))
CliBaseOptions(sourceModules = sourceFiles, rootDir = tempDir),
)
) )
} }
@@ -538,7 +548,7 @@ result = someLib.x
listOf( listOf(
writePklFile("test1.pkl", "x = 1"), writePklFile("test1.pkl", "x = 1"),
writePklFile("test2.pkl", "x = 2"), writePklFile("test2.pkl", "x = 2"),
writePklFile("test3.pkl", "x = 3") writePklFile("test3.pkl", "x = 3"),
) )
val outputFile = tempDir.resolve("output.yaml") val outputFile = tempDir.resolve("output.yaml")
@@ -547,7 +557,7 @@ result = someLib.x
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = sourceFiles), CliBaseOptions(sourceModules = sourceFiles),
outputFile.toString(), outputFile.toString(),
"yaml" "yaml",
) )
) )
@@ -560,18 +570,18 @@ result = someLib.x
listOf( listOf(
writePklFile( writePklFile(
"test0.pkl", "test0.pkl",
"output { value = List(); renderer = new YamlRenderer { isStream = true } }" "output { value = List(); renderer = new YamlRenderer { isStream = true } }",
), ),
writePklFile("test1.pkl", "x = 1"), writePklFile("test1.pkl", "x = 1"),
writePklFile( writePklFile(
"test2.pkl", "test2.pkl",
"output { value = List(); renderer = new YamlRenderer { isStream = true } }" "output { value = List(); renderer = new YamlRenderer { isStream = true } }",
), ),
writePklFile("test3.pkl", "x = 3"), writePklFile("test3.pkl", "x = 3"),
writePklFile( writePklFile(
"test4.pkl", "test4.pkl",
"output { value = List(); renderer = new YamlRenderer { isStream = true } }" "output { value = List(); renderer = new YamlRenderer { isStream = true } }",
) ),
) )
val outputFile = tempDir.resolve("output.yaml") val outputFile = tempDir.resolve("output.yaml")
@@ -580,7 +590,7 @@ result = someLib.x
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = sourceFiles), CliBaseOptions(sourceModules = sourceFiles),
outputFile.toString(), outputFile.toString(),
"yaml" "yaml",
) )
) )
@@ -593,7 +603,7 @@ result = someLib.x
listOf( listOf(
writePklFile("test1.pkl", "x = 1"), writePklFile("test1.pkl", "x = 1"),
writePklFile("test2.pkl", "x = 2"), writePklFile("test2.pkl", "x = 2"),
writePklFile("test3.pkl", "x = 3") writePklFile("test3.pkl", "x = 3"),
) )
val outputFile = tempDir.resolve("output.pcf") val outputFile = tempDir.resolve("output.pcf")
@@ -603,7 +613,7 @@ result = someLib.x
CliBaseOptions(sourceModules = sourceFiles), CliBaseOptions(sourceModules = sourceFiles),
outputFile.toString(), outputFile.toString(),
outputFormat = "pcf", outputFormat = "pcf",
moduleOutputSeparator = "// my module separator" moduleOutputSeparator = "// my module separator",
) )
) )
@@ -617,7 +627,7 @@ result = someLib.x
// my module separator // my module separator
x = 3 x = 3
""" """
.trimIndent() .trimIndent(),
) )
} }
@@ -627,7 +637,7 @@ result = someLib.x
listOf( listOf(
writePklFile("test1.pkl", "x = 1"), writePklFile("test1.pkl", "x = 1"),
writePklFile("test2.pkl", "y = 2"), writePklFile("test2.pkl", "y = 2"),
writePklFile("test3.pkl", "z = 3") writePklFile("test3.pkl", "z = 3"),
) )
val outputFile = tempDir.resolve("output.pcf") val outputFile = tempDir.resolve("output.pcf")
@@ -637,7 +647,7 @@ result = someLib.x
CliBaseOptions(sourceModules = sourceFiles), CliBaseOptions(sourceModules = sourceFiles),
outputFile.toString(), outputFile.toString(),
outputFormat = "pcf", outputFormat = "pcf",
moduleOutputSeparator = "" moduleOutputSeparator = "",
) )
) )
@@ -651,7 +661,7 @@ result = someLib.x
z = 3 z = 3
""" """
.trimIndent() .trimIndent(),
) )
} }
@@ -661,11 +671,13 @@ result = someLib.x
listOf( listOf(
writePklFile("test1.pkl", "x = 1"), writePklFile("test1.pkl", "x = 1"),
writePklFile("test2.pkl", "x = 2"), writePklFile("test2.pkl", "x = 2"),
writePklFile("test3.pkl", "x = 3") writePklFile("test3.pkl", "x = 3"),
) )
val output = val output =
evalToConsole(CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), null, "yaml")) evalToConsole(
CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "yaml")
)
assertThat(output).isEqualTo("x: 1\n---\nx: 2\n---\nx: 3\n") assertThat(output).isEqualTo("x: 1\n---\nx: 2\n---\nx: 3\n")
} }
@@ -676,22 +688,24 @@ result = someLib.x
listOf( listOf(
writePklFile( writePklFile(
"test0.pkl", "test0.pkl",
"output { value = List(); renderer = new YamlRenderer { isStream = true } }" "output { value = List(); renderer = new YamlRenderer { isStream = true } }",
), ),
writePklFile("test1.pkl", "x = 1"), writePklFile("test1.pkl", "x = 1"),
writePklFile( writePklFile(
"test2.pkl", "test2.pkl",
"output { value = List(); renderer = new YamlRenderer { isStream = true } }" "output { value = List(); renderer = new YamlRenderer { isStream = true } }",
), ),
writePklFile("test3.pkl", "x = 3"), writePklFile("test3.pkl", "x = 3"),
writePklFile( writePklFile(
"test4.pkl", "test4.pkl",
"output { value = List(); renderer = new YamlRenderer { isStream = true } }" "output { value = List(); renderer = new YamlRenderer { isStream = true } }",
) ),
) )
val output = val output =
evalToConsole(CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), null, "yaml")) evalToConsole(
CliEvaluatorOptions(CliBaseOptions(sourceModules = sourceFiles), outputFormat = "yaml")
)
assertThat(output).isEqualTo("x: 1\n---\nx: 3\n") assertThat(output).isEqualTo("x: 1\n---\nx: 3\n")
} }
@@ -705,8 +719,7 @@ result = someLib.x
evalToConsole( evalToConsole(
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = sourceFiles), CliBaseOptions(sourceModules = sourceFiles),
null, outputFormat = outputFormat.toString(),
outputFormat.toString()
) )
) )
assertThat(output).endsWith("\n") assertThat(output).endsWith("\n")
@@ -750,7 +763,7 @@ result = someLib.x
""" """
["bar"] = "baz" ["bar"] = "baz"
""" """
.trimIndent() .trimIndent(),
) )
checkOutputFile( checkOutputFile(
tempDir.resolve(".my-output/bar/baz.pcf"), tempDir.resolve(".my-output/bar/baz.pcf"),
@@ -758,7 +771,7 @@ result = someLib.x
""" """
["baz"] = "biz" ["baz"] = "biz"
""" """
.trimIndent() .trimIndent(),
) )
checkOutputFile(tempDir.resolve(".my-output/buz.txt"), "buz.txt", "buz") checkOutputFile(tempDir.resolve(".my-output/buz.txt"), "buz.txt", "buz")
} }
@@ -796,7 +809,7 @@ result = someLib.x
} }
""" """
.trimIndent(), .trimIndent(),
) ),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
@@ -823,7 +836,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
), ),
writePklFile( writePklFile(
"foo.pkl", "foo.pkl",
@@ -836,7 +849,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
), ),
) )
val options = val options =
@@ -849,11 +862,7 @@ result = someLib.x
@Test @Test
fun `multiple file output writes nothing if output files is null`() { fun `multiple file output writes nothing if output files is null`() {
val moduleUri = val moduleUri = writePklFile("test.pkl", "")
writePklFile(
"test.pkl",
"",
)
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir), CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir),
@@ -878,12 +887,12 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir), CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir),
multipleFileOutputPath = ".output" multipleFileOutputPath = ".output",
) )
assertThatCode { evalToConsole(options) } assertThatCode { evalToConsole(options) }
.hasMessageStartingWith("Output file conflict:") .hasMessageStartingWith("Output file conflict:")
@@ -904,7 +913,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
), ),
writePklFile( writePklFile(
"test2.pkl", "test2.pkl",
@@ -915,14 +924,14 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) ),
) )
for (moduleUri in moduleUris) { for (moduleUri in moduleUris) {
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir), CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir),
multipleFileOutputPath = ".output" multipleFileOutputPath = ".output",
) )
assertThatCode { evalToConsole(options) } assertThatCode { evalToConsole(options) }
.hasMessageStartingWith("Output file conflict:") .hasMessageStartingWith("Output file conflict:")
@@ -943,7 +952,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
), ),
writePklFile( writePklFile(
"test2.pkl", "test2.pkl",
@@ -954,13 +963,13 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) ),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = moduleUris, workingDir = tempDir), CliBaseOptions(sourceModules = moduleUris, workingDir = tempDir),
multipleFileOutputPath = ".output" multipleFileOutputPath = ".output",
) )
assertThatCode { evalToConsole(options) } assertThatCode { evalToConsole(options) }
.hasMessageContaining("Output file conflict:") .hasMessageContaining("Output file conflict:")
@@ -980,12 +989,12 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir), CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir),
multipleFileOutputPath = ".output" multipleFileOutputPath = ".output",
) )
assertThatCode { evalToConsole(options) } assertThatCode { evalToConsole(options) }
.hasMessageContaining("Output file conflict:") .hasMessageContaining("Output file conflict:")
@@ -1005,13 +1014,13 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir), CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir),
multipleFileOutputPath = ".output" multipleFileOutputPath = ".output",
) )
assertThatCode { evalToConsole(options) } assertThatCode { evalToConsole(options) }
.hasMessageContaining("Path spec `foo:bar` contains illegal character `:`.") .hasMessageContaining("Path spec `foo:bar` contains illegal character `:`.")
@@ -1030,13 +1039,13 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir), CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir),
multipleFileOutputPath = ".output" multipleFileOutputPath = ".output",
) )
assertThatCode { evalToConsole(options) } assertThatCode { evalToConsole(options) }
.hasMessageContaining("Path spec `foo\\bar` contains illegal character `\\`.") .hasMessageContaining("Path spec `foo\\bar` contains illegal character `\\`.")
@@ -1052,7 +1061,7 @@ result = someLib.x
bar = 1 bar = 1
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
@@ -1083,7 +1092,7 @@ result = someLib.x
} }
person: Person = new { name = "Frodo" } person: Person = new { name = "Frodo" }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
@@ -1105,7 +1114,7 @@ result = someLib.x
friend { name = "Bilbo" } friend { name = "Bilbo" }
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
@@ -1125,7 +1134,7 @@ result = someLib.x
""" """
res = 1 res = 1
""" """
.trimIndent() .trimIndent(),
) )
writePklFile( writePklFile(
"PklProject", "PklProject",
@@ -1134,11 +1143,11 @@ result = someLib.x
package = throw("invalid project package") package = throw("invalid project package")
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir, noProject = true), CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir, noProject = true)
) )
val buffer = StringWriter() val buffer = StringWriter()
CliEvaluator(options, consoleWriter = buffer).run() CliEvaluator(options, consoleWriter = buffer).run()
@@ -1154,7 +1163,7 @@ result = someLib.x
""" """
res = read*("env:**") res = read*("env:**")
""" """
.trimIndent() .trimIndent(),
) )
writePklFile( writePklFile(
"PklProject", "PklProject",
@@ -1169,12 +1178,10 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir))
CliBaseOptions(sourceModules = listOf(moduleUri), workingDir = tempDir),
)
val buffer = StringWriter() val buffer = StringWriter()
CliEvaluator(options, consoleWriter = buffer).run() CliEvaluator(options, consoleWriter = buffer).run()
assertThat(buffer.toString()) assertThat(buffer.toString())
@@ -1200,7 +1207,7 @@ result = someLib.x
res = Swallow res = Swallow
""" """
.trimIndent() .trimIndent(),
) )
val buffer = StringWriter() val buffer = StringWriter()
val options = val options =
@@ -1211,8 +1218,8 @@ result = someLib.x
moduleCacheDir = tempDir, moduleCacheDir = tempDir,
noCache = true, noCache = true,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = packageServer.port testPort = packageServer.port,
), )
) )
CliEvaluator(options, consoleWriter = buffer).run() CliEvaluator(options, consoleWriter = buffer).run()
assertThat(buffer.toString()) assertThat(buffer.toString())
@@ -1278,7 +1285,7 @@ result = someLib.x
sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")), sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")),
httpProxy = URI("http://localhost:${wwRuntimeInfo.httpPort}"), httpProxy = URI("http://localhost:${wwRuntimeInfo.httpPort}"),
allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"), allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"),
), )
) )
val output = evalToConsole(options) val output = evalToConsole(options)
assertThat(output).isEqualTo("foo = 1\n") assertThat(output).isEqualTo("foo = 1\n")
@@ -1317,7 +1324,7 @@ result = someLib.x
noCache = true, noCache = true,
httpProxy = URI(wwRuntimeInfo.httpBaseUrl), httpProxy = URI(wwRuntimeInfo.httpBaseUrl),
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:") allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"),
) )
) )
val output = evalToConsole(options) val output = evalToConsole(options)
@@ -1340,7 +1347,7 @@ result = someLib.x
@Test @Test
fun `eval http module from proxy -- configured in settings`( fun `eval http module from proxy -- configured in settings`(
@TempDir tempDir: Path, @TempDir tempDir: Path,
wwRuntimeInfo: WireMockRuntimeInfo wwRuntimeInfo: WireMockRuntimeInfo,
) { ) {
val settingsModule = val settingsModule =
tempDir.writeFile( tempDir.writeFile(
@@ -1354,7 +1361,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
stubFor( stubFor(
@@ -1366,7 +1373,7 @@ result = someLib.x
sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")), sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")),
settings = settingsModule.toUri(), settings = settingsModule.toUri(),
allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"), allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"),
), )
) )
val output = evalToConsole(options) val output = evalToConsole(options)
assertThat(output).isEqualTo("foo = 1\n") assertThat(output).isEqualTo("foo = 1\n")
@@ -1375,7 +1382,7 @@ result = someLib.x
@Test @Test
fun `eval http module from proxy -- configured in PklProject`( fun `eval http module from proxy -- configured in PklProject`(
@TempDir tempDir: Path, @TempDir tempDir: Path,
wwRuntimeInfo: WireMockRuntimeInfo wwRuntimeInfo: WireMockRuntimeInfo,
) { ) {
tempDir.writeFile( tempDir.writeFile(
"PklProject", "PklProject",
@@ -1390,7 +1397,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
stubFor( stubFor(
@@ -1401,8 +1408,8 @@ result = someLib.x
CliBaseOptions( CliBaseOptions(
sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")), sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")),
allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"), allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"),
projectDir = tempDir projectDir = tempDir,
), )
) )
val output = evalToConsole(options) val output = evalToConsole(options)
assertThat(output).isEqualTo("foo = 1\n") assertThat(output).isEqualTo("foo = 1\n")
@@ -1411,7 +1418,7 @@ result = someLib.x
@Test @Test
fun `eval http module from proxy -- PklProject beats user settings`( fun `eval http module from proxy -- PklProject beats user settings`(
@TempDir tempDir: Path, @TempDir tempDir: Path,
wwRuntimeInfo: WireMockRuntimeInfo wwRuntimeInfo: WireMockRuntimeInfo,
) { ) {
val projectDir = tempDir.resolve("my-project") val projectDir = tempDir.resolve("my-project")
projectDir.writeFile( projectDir.writeFile(
@@ -1427,7 +1434,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
val homeDir = tempDir.resolve("my-home") val homeDir = tempDir.resolve("my-home")
homeDir.writeFile( homeDir.writeFile(
@@ -1441,7 +1448,7 @@ result = someLib.x
} }
} }
""" """
.trimIndent() .trimIndent(),
) )
val options = val options =
CliEvaluatorOptions( CliEvaluatorOptions(
@@ -1449,8 +1456,8 @@ result = someLib.x
sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")), sourceModules = listOf(URI("http://not.a.valid.host/bar.pkl")),
allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"), allowedModules = SecurityManagers.defaultAllowedModules + Pattern.compile("http:"),
projectDir = projectDir, projectDir = projectDir,
settings = homeDir.resolve("settings.pkl").toUri() settings = homeDir.resolve("settings.pkl").toUri(),
), )
) )
stubFor(get(anyUrl()).willReturn(ok("result = 1"))) stubFor(get(anyUrl()).willReturn(ok("result = 1")))
val output = evalToConsole(options) val output = evalToConsole(options)
@@ -1477,14 +1484,9 @@ result = someLib.x
importGlob = import*("./日*.pkl").keys importGlob = import*("./日*.pkl").keys
importGlobFile = import*("$tempDirUri**/*.pkl").keys.map((it) -> it.replaceAll("$tempDirUri".replaceAll("///", "/"), "")) importGlobFile = import*("$tempDirUri**/*.pkl").keys.map((it) -> it.replaceAll("$tempDirUri".replaceAll("///", "/"), ""))
""" """
.trimIndent() .trimIndent(),
)
val output =
evalToConsole(
CliEvaluatorOptions(
CliBaseOptions(sourceModules = listOf(file)),
)
) )
val output = evalToConsole(CliEvaluatorOptions(CliBaseOptions(sourceModules = listOf(file))))
val tripleQuote = "\"\"\"" val tripleQuote = "\"\"\""
assertThat(output) assertThat(output)
@@ -1521,7 +1523,7 @@ result = someLib.x
import "package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl" import "package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"
res = Swallow res = Swallow
""" """,
) )
val options = val options =
@@ -1531,8 +1533,8 @@ result = someLib.x
caCertificates = buildList { if (certsFile != null) add(certsFile) }, caCertificates = buildList { if (certsFile != null) add(certsFile) },
workingDir = tempDir, workingDir = tempDir,
noCache = true, noCache = true,
testPort = testPort testPort = testPort,
), )
) )
CliEvaluator(options).run() CliEvaluator(options).run()
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.pkl.core.packages.PackageUri
class CliPackageDownloaderTest { class CliPackageDownloaderTest {
companion object { companion object {
val server = PackageServer() private val server = PackageServer()
@AfterAll @AfterAll
@JvmStatic @JvmStatic
@@ -45,15 +45,15 @@ class CliPackageDownloaderTest {
CliBaseOptions( CliBaseOptions(
moduleCacheDir = tempDir, moduleCacheDir = tempDir,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = server.port testPort = server.port,
), ),
packageUris = packageUris =
listOf( listOf(
PackageUri("package://localhost:0/birds@0.5.0"), PackageUri("package://localhost:0/birds@0.5.0"),
PackageUri("package://localhost:0/fruit@1.0.5"), PackageUri("package://localhost:0/fruit@1.0.5"),
PackageUri("package://localhost:0/fruit@1.1.0") PackageUri("package://localhost:0/fruit@1.1.0"),
), ),
noTransitive = true noTransitive = true,
) )
cmd.run() cmd.run()
assertThat(tempDir.resolve("package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip")).exists() assertThat(tempDir.resolve("package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip")).exists()
@@ -75,7 +75,7 @@ class CliPackageDownloaderTest {
moduleCacheDir = ".my-cache" moduleCacheDir = ".my-cache"
} }
""" """
.trimIndent() .trimIndent(),
) )
val cmd = val cmd =
@@ -84,10 +84,10 @@ class CliPackageDownloaderTest {
CliBaseOptions( CliBaseOptions(
workingDir = tempDir, workingDir = tempDir,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = server.port testPort = server.port,
), ),
packageUris = listOf(PackageUri("package://localhost:0/birds@0.5.0")), packageUris = listOf(PackageUri("package://localhost:0/birds@0.5.0")),
noTransitive = true noTransitive = true,
) )
cmd.run() cmd.run()
assertThat(tempDir.resolve(".my-cache/package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip")) assertThat(tempDir.resolve(".my-cache/package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip"))
@@ -104,13 +104,13 @@ class CliPackageDownloaderTest {
CliBaseOptions( CliBaseOptions(
moduleCacheDir = tempDir, moduleCacheDir = tempDir,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = server.port testPort = server.port,
), ),
packageUris = packageUris =
listOf( listOf(
PackageUri("package://localhost:0/birds@0.5.0::sha256:${PackageServer.BIRDS_SHA}"), PackageUri("package://localhost:0/birds@0.5.0::sha256:${PackageServer.BIRDS_SHA}")
), ),
noTransitive = true noTransitive = true,
) )
cmd.run() cmd.run()
assertThat(tempDir.resolve("package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip")).exists() assertThat(tempDir.resolve("package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip")).exists()
@@ -125,13 +125,13 @@ class CliPackageDownloaderTest {
CliBaseOptions( CliBaseOptions(
moduleCacheDir = tempDir, moduleCacheDir = tempDir,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = server.port testPort = server.port,
), ),
packageUris = packageUris =
listOf( listOf(
PackageUri("package://localhost:0/birds@0.5.0::sha256:intentionallyBogusChecksum"), PackageUri("package://localhost:0/birds@0.5.0::sha256:intentionallyBogusChecksum")
), ),
noTransitive = true noTransitive = true,
) )
assertThatCode { cmd.run() } assertThatCode { cmd.run() }
.hasMessage( .hasMessage(
@@ -152,7 +152,7 @@ class CliPackageDownloaderTest {
CliPackageDownloader( CliPackageDownloader(
baseOptions = CliBaseOptions(workingDir = tempDir, noCache = true), baseOptions = CliBaseOptions(workingDir = tempDir, noCache = true),
packageUris = listOf(PackageUri("package://localhost:0/birds@0.5.0")), packageUris = listOf(PackageUri("package://localhost:0/birds@0.5.0")),
noTransitive = true noTransitive = true,
) )
assertThatCode { cmd.run() } assertThatCode { cmd.run() }
.hasMessage("Cannot download packages because no cache directory is specified.") .hasMessage("Cannot download packages because no cache directory is specified.")
@@ -166,10 +166,10 @@ class CliPackageDownloaderTest {
CliBaseOptions( CliBaseOptions(
moduleCacheDir = tempDir, moduleCacheDir = tempDir,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = server.port testPort = server.port,
), ),
packageUris = listOf(PackageUri("package://localhost:0/badChecksum@1.0.0")), packageUris = listOf(PackageUri("package://localhost:0/badChecksum@1.0.0")),
noTransitive = true noTransitive = true,
) )
assertThatCode { cmd.run() } assertThatCode { cmd.run() }
.hasMessageStartingWith( .hasMessageStartingWith(
@@ -185,14 +185,14 @@ class CliPackageDownloaderTest {
CliBaseOptions( CliBaseOptions(
moduleCacheDir = tempDir, moduleCacheDir = tempDir,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = server.port testPort = server.port,
), ),
packageUris = packageUris =
listOf( listOf(
PackageUri("package://localhost:0/badChecksum@1.0.0"), PackageUri("package://localhost:0/badChecksum@1.0.0"),
PackageUri("package://bogus.domain/notAPackage@1.0.0") PackageUri("package://bogus.domain/notAPackage@1.0.0"),
), ),
noTransitive = true noTransitive = true,
) )
assertThatCode { cmd.run() } assertThatCode { cmd.run() }
.hasMessage( .hasMessage(
@@ -222,10 +222,10 @@ class CliPackageDownloaderTest {
CliBaseOptions( CliBaseOptions(
moduleCacheDir = tempDir, moduleCacheDir = tempDir,
caCertificates = listOf(FileTestUtils.selfSignedCertificate), caCertificates = listOf(FileTestUtils.selfSignedCertificate),
testPort = server.port testPort = server.port,
), ),
packageUris = listOf(PackageUri("package://localhost:0/birds@0.5.0")), packageUris = listOf(PackageUri("package://localhost:0/birds@0.5.0")),
noTransitive = false noTransitive = false,
) )
.run() .run()
assertThat(tempDir.resolve("package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip")).exists() assertThat(tempDir.resolve("package-2/localhost(3a)0/birds@0.5.0/birds@0.5.0.zip")).exists()
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ package org.pkl.cli
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.nio.file.Path import java.nio.file.Path
import org.pkl.commons.createParentDirectories import kotlin.io.path.createParentDirectories
import org.pkl.commons.writeString import org.pkl.commons.writeString
fun Path.writeFile(fileName: String, contents: String): Path { fun Path.writeFile(fileName: String, contents: String): Path {
+22 -16
View File
@@ -7,26 +7,32 @@ com.palantir.javapoet:javapoet:0.6.0=compileClasspath,implementationDependencies
com.tunnelvisionlabs:antlr4-runtime:4.9.0=runtimeClasspath,testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=runtimeClasspath,testRuntimeClasspath
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
package org.pkl.codegen.java package org.pkl.codegen.java
import java.io.IOException import java.io.IOException
import kotlin.io.path.createParentDirectories
import org.pkl.commons.cli.CliCommand import org.pkl.commons.cli.CliCommand
import org.pkl.commons.cli.CliException import org.pkl.commons.cli.CliException
import org.pkl.commons.createParentDirectories
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.Closeables import org.pkl.core.Closeables
import org.pkl.core.ModuleSource import org.pkl.core.ModuleSource
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.pkl.codegen.java
import com.palantir.javapoet.* import com.palantir.javapoet.*
import java.io.StringWriter import java.io.StringWriter
import java.lang.Deprecated import java.lang.Deprecated
import java.net.URI
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
import javax.lang.model.element.Modifier import javax.lang.model.element.Modifier
@@ -91,13 +90,13 @@ data class JavaCodeGeneratorOptions(
* Can be used when the class or package name in the generated source code should be different * Can be used when the class or package name in the generated source code should be different
* from the corresponding name derived from the Pkl module declaration . * from the corresponding name derived from the Pkl module declaration .
*/ */
val renames: Map<String, String> = emptyMap() val renames: Map<String, String> = emptyMap(),
) )
/** Entrypoint for the Java code generator API. */ /** Entrypoint for the Java code generator API. */
class JavaCodeGenerator( class JavaCodeGenerator(
private val schema: ModuleSchema, private val schema: ModuleSchema,
private val codegenOptions: JavaCodeGeneratorOptions private val codegenOptions: JavaCodeGeneratorOptions,
) { ) {
companion object { companion object {
@@ -115,7 +114,7 @@ class JavaCodeGenerator(
private val PMODULE = ClassName.get(PModule::class.java) private val PMODULE = ClassName.get(PModule::class.java)
private val PCLASS = ClassName.get(PClass::class.java) private val PCLASS = ClassName.get(PClass::class.java)
private val PATTERN = ClassName.get(Pattern::class.java) private val PATTERN = ClassName.get(Pattern::class.java)
private val URI = ClassName.get(URI::class.java) private val URI = ClassName.get(java.net.URI::class.java)
private val VERSION = ClassName.get(Version::class.java) private val VERSION = ClassName.get(Version::class.java)
private const val PROPERTY_PREFIX: String = "org.pkl.config.java.mapper." private const val PROPERTY_PREFIX: String = "org.pkl.config.java.mapper."
@@ -241,7 +240,7 @@ class JavaCodeGenerator(
fun addCtorParameter( fun addCtorParameter(
builder: MethodSpec.Builder, builder: MethodSpec.Builder,
propJavaName: String, propJavaName: String,
property: PClass.Property property: PClass.Property,
) { ) {
val paramBuilder = ParameterSpec.builder(property.type.toJavaPoetName(), propJavaName) val paramBuilder = ParameterSpec.builder(property.type.toJavaPoetName(), propJavaName)
if (paramsAnnotationName != null) { if (paramsAnnotationName != null) {
@@ -305,7 +304,7 @@ class JavaCodeGenerator(
"if (!\$T.equals(this.$accessor, other.$accessor)) return false", "if (!\$T.equals(this.$accessor, other.$accessor)) return false",
Objects::class.java, Objects::class.java,
propertyName, propertyName,
propertyName propertyName,
) )
} }
@@ -326,7 +325,7 @@ class JavaCodeGenerator(
builder.addStatement( builder.addStatement(
"result = 31 * result + \$T.hashCode($accessor)", "result = 31 * result + \$T.hashCode($accessor)",
Objects::class.java, Objects::class.java,
propertyName propertyName,
) )
} }
@@ -348,7 +347,7 @@ class JavaCodeGenerator(
appendBuilder.addStatement( appendBuilder.addStatement(
"appendProperty(builder, \$S, this.\$N)", "appendProperty(builder, \$S, this.\$N)",
propertyName, propertyName,
propertyName propertyName,
) )
} }
@@ -357,7 +356,7 @@ class JavaCodeGenerator(
"\$T builder = new \$T(\$L)", "\$T builder = new \$T(\$L)",
StringBuilder::class.java, StringBuilder::class.java,
StringBuilder::class.java, StringBuilder::class.java,
builderSize builderSize,
) )
.addStatement("builder.append(\$T.class.getSimpleName()).append(\" {\")", javaPoetClassName) .addStatement("builder.append(\$T.class.getSimpleName()).append(\" {\")", javaPoetClassName)
.addCode(appendBuilder.build()) .addCode(appendBuilder.build())
@@ -381,7 +380,7 @@ class JavaCodeGenerator(
annotations: Collection<PObject>, annotations: Collection<PObject>,
hasJavadoc: Boolean, hasJavadoc: Boolean,
addAnnotation: (Class<*>) -> Unit, addAnnotation: (Class<*>) -> Unit,
addJavadoc: (String) -> Unit addJavadoc: (String) -> Unit,
) { ) {
annotations annotations
.firstOrNull { it.classInfo == PClassInfo.Deprecated } .firstOrNull { it.classInfo == PClassInfo.Deprecated }
@@ -417,7 +416,7 @@ class JavaCodeGenerator(
property.annotations, property.annotations,
hasJavadoc, hasJavadoc,
{ builder.addAnnotation(it) }, { builder.addAnnotation(it) },
{ builder.addJavadoc(it) } { builder.addJavadoc(it) },
) )
builder.addModifiers(Modifier.PUBLIC) builder.addModifiers(Modifier.PUBLIC)
} }
@@ -430,7 +429,7 @@ class JavaCodeGenerator(
fun generateGetter( fun generateGetter(
propertyName: String, propertyName: String,
property: PClass.Property, property: PClass.Property,
isOverridden: Boolean isOverridden: Boolean,
): MethodSpec { ): MethodSpec {
val propertyType = property.type val propertyType = property.type
val isBooleanProperty = val isBooleanProperty =
@@ -460,7 +459,7 @@ class JavaCodeGenerator(
property.annotations, property.annotations,
hasJavadoc, hasJavadoc,
{ builder.addAnnotation(it) }, { builder.addAnnotation(it) },
{ builder.addJavadoc(it) } { builder.addJavadoc(it) },
) )
return builder.build() return builder.build()
@@ -479,7 +478,7 @@ class JavaCodeGenerator(
property.annotations, property.annotations,
false, false,
{ methodBuilder.addAnnotation(it) }, { methodBuilder.addAnnotation(it) },
{ methodBuilder.addJavadoc(it) } { methodBuilder.addJavadoc(it) },
) )
val codeBuilder = CodeBlock.builder() val codeBuilder = CodeBlock.builder()
@@ -535,7 +534,7 @@ class JavaCodeGenerator(
AnnotationSpec.builder( AnnotationSpec.builder(
ClassName.get( ClassName.get(
"org.springframework.boot.context.properties", "org.springframework.boot.context.properties",
"ConfigurationProperties" "ConfigurationProperties",
) )
) )
// use "value" instead of "prefix" to entice JavaPoet to generate a single-line // use "value" instead of "prefix" to entice JavaPoet to generate a single-line
@@ -572,7 +571,7 @@ class JavaCodeGenerator(
pClass.annotations, pClass.annotations,
hasJavadoc, hasJavadoc,
{ builder.addAnnotation(it) }, { builder.addAnnotation(it) },
{ builder.addJavadoc(it) } { builder.addJavadoc(it) },
) )
if (!isModuleClass) { if (!isModuleClass) {
@@ -632,7 +631,7 @@ class JavaCodeGenerator(
private fun generateEnumTypeSpec( private fun generateEnumTypeSpec(
typeAlias: TypeAlias, typeAlias: TypeAlias,
stringLiterals: Set<String> stringLiterals: Set<String>,
): TypeSpec.Builder { ): TypeSpec.Builder {
val enumConstantToPklNames = val enumConstantToPklNames =
stringLiterals stringLiterals
@@ -674,7 +673,7 @@ class JavaCodeGenerator(
for ((enumConstantName, pklName) in enumConstantToPklNames) { for ((enumConstantName, pklName) in enumConstantToPklNames) {
builder.addEnumConstant( builder.addEnumConstant(
enumConstantName, enumConstantName,
TypeSpec.anonymousClassBuilder("\$S", pklName).build() TypeSpec.anonymousClassBuilder("\$S", pklName).build(),
) )
} }
@@ -694,7 +693,7 @@ class JavaCodeGenerator(
.addStatement( .addStatement(
"\$T lines = \$T.toString(value).split(\"\\n\")", "\$T lines = \$T.toString(value).split(\"\\n\")",
ArrayTypeName.of(String::class.java), ArrayTypeName.of(String::class.java),
Objects::class.java Objects::class.java,
) )
.addStatement("builder.append(lines[0])") .addStatement("builder.append(lines[0])")
.beginControlFlow("for (int i = 1; i < lines.length; i++)") .beginControlFlow("for (int i = 1; i < lines.length; i++)")
@@ -718,7 +717,7 @@ class JavaCodeGenerator(
/** Generate `List<? extends Foo>` if `Foo` is `abstract` or `open`, to allow subclassing. */ /** Generate `List<? extends Foo>` if `Foo` is `abstract` or `open`, to allow subclassing. */
private fun PType.toJavaPoetTypeArgumentName(): TypeName { private fun PType.toJavaPoetTypeArgumentName(): TypeName {
val baseName = toJavaPoetName(nullable = false, boxed = true) val baseName = toJavaPoetName(boxed = true)
return if (this is PType.Class && (pClass.isAbstract || pClass.isOpen)) { return if (this is PType.Class && (pClass.isAbstract || pClass.isOpen)) {
WildcardTypeName.subtypeOf(baseName) WildcardTypeName.subtypeOf(baseName)
} else { } else {
@@ -757,7 +756,7 @@ class JavaCodeGenerator(
OBJECT OBJECT
} else { } else {
typeArguments[1].toJavaPoetTypeArgumentName() typeArguments[1].toJavaPoetTypeArgumentName()
} },
) )
.nullableIf(nullable) .nullableIf(nullable)
PClassInfo.Collection -> PClassInfo.Collection ->
@@ -767,7 +766,7 @@ class JavaCodeGenerator(
OBJECT OBJECT
} else { } else {
typeArguments[0].toJavaPoetTypeArgumentName() typeArguments[0].toJavaPoetTypeArgumentName()
} },
) )
.nullableIf(nullable) .nullableIf(nullable)
PClassInfo.List, PClassInfo.List,
@@ -778,7 +777,7 @@ class JavaCodeGenerator(
OBJECT OBJECT
} else { } else {
typeArguments[0].toJavaPoetTypeArgumentName() typeArguments[0].toJavaPoetTypeArgumentName()
} },
) )
.nullableIf(nullable) .nullableIf(nullable)
} }
@@ -789,7 +788,7 @@ class JavaCodeGenerator(
OBJECT OBJECT
} else { } else {
typeArguments[0].toJavaPoetTypeArgumentName() typeArguments[0].toJavaPoetTypeArgumentName()
} },
) )
.nullableIf(nullable) .nullableIf(nullable)
PClassInfo.Map, PClassInfo.Map,
@@ -805,7 +804,7 @@ class JavaCodeGenerator(
OBJECT OBJECT
} else { } else {
typeArguments[1].toJavaPoetTypeArgumentName() typeArguments[1].toJavaPoetTypeArgumentName()
} },
) )
.nullableIf(nullable) .nullableIf(nullable)
PClassInfo.Module -> PMODULE.nullableIf(nullable) PClassInfo.Module -> PMODULE.nullableIf(nullable)
@@ -942,5 +941,5 @@ internal val javaReservedWords =
"try", "try",
"void", "void",
"volatile", "volatile",
"while" "while",
) )
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.pkl.codegen.java package org.pkl.codegen.java
import java.nio.file.Path import java.nio.file.Path
import org.pkl.commons.createParentDirectories import kotlin.io.path.createParentDirectories
import org.pkl.commons.writeString import org.pkl.commons.writeString
data class PklModule(val name: String, val content: String) { data class PklModule(val name: String, val content: String) {
+34 -19
View File
@@ -7,29 +7,44 @@ com.squareup:kotlinpoet:1.6.0=compileClasspath,implementationDependenciesMetadat
com.tunnelvisionlabs:antlr4-runtime:4.9.0=runtimeClasspath,testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=runtimeClasspath,testRuntimeClasspath
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-client:1.7.10=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-daemon-client:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-script-util:1.7.10=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-reflect:2.0.21=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-script-util:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-jsr223:2.0.21=testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm-host:2.0.21=testRuntimeClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=testRuntimeOnlyDependenciesMetadata
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,testRuntimeClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -43,12 +43,13 @@ dependencies {
api(projects.pklCommonsCli) api(projects.pklCommonsCli)
api(projects.pklCore) api(projects.pklCore)
implementation(libs.kotlinPoet) implementation(libs.kotlinPoet) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
}
implementation(libs.kotlinReflect) implementation(libs.kotlinReflect)
testImplementation(projects.pklConfigKotlin) testImplementation(projects.pklConfigKotlin)
testImplementation(projects.pklCommonsTest) testImplementation(projects.pklCommonsTest)
testImplementation(libs.kotlinCompilerEmbeddable) testRuntimeOnly(libs.kotlinScripting)
testRuntimeOnly(libs.kotlinScriptingCompilerEmbeddable)
testRuntimeOnly(libs.kotlinScriptUtil)
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
package org.pkl.codegen.kotlin package org.pkl.codegen.kotlin
import java.io.IOException import java.io.IOException
import kotlin.io.path.createParentDirectories
import org.pkl.commons.cli.CliCommand import org.pkl.commons.cli.CliCommand
import org.pkl.commons.cli.CliException import org.pkl.commons.cli.CliException
import org.pkl.commons.createParentDirectories
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.Closeables import org.pkl.core.Closeables
import org.pkl.core.ModuleSource import org.pkl.core.ModuleSource
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.pkl.codegen.kotlin
import com.squareup.kotlinpoet.* import com.squareup.kotlinpoet.*
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import java.io.StringWriter import java.io.StringWriter
import java.net.URI
import java.util.* import java.util.*
import org.pkl.commons.NameMapper import org.pkl.commons.NameMapper
import org.pkl.core.* import org.pkl.core.*
@@ -76,7 +75,7 @@ class KotlinCodeGenerator(
private val PMODULE = PModule::class.asClassName() private val PMODULE = PModule::class.asClassName()
private val PCLASS = PClass::class.asClassName() private val PCLASS = PClass::class.asClassName()
private val REGEX = Regex::class.asClassName() private val REGEX = Regex::class.asClassName()
private val URI = URI::class.asClassName() private val URI = java.net.URI::class.asClassName()
private val VERSION = Version::class.asClassName() private val VERSION = Version::class.asClassName()
private const val PROPERTY_PREFIX: String = "org.pkl.config.java.mapper." private const val PROPERTY_PREFIX: String = "org.pkl.config.java.mapper."
@@ -134,7 +133,7 @@ class KotlinCodeGenerator(
fun generateCompanionRelatedCode( fun generateCompanionRelatedCode(
builder: TypeSpec.Builder, builder: TypeSpec.Builder,
isModuleType: Boolean = false isModuleType: Boolean = false,
): TypeSpec.Builder { ): TypeSpec.Builder {
// ensure that at most one companion object is generated for this type // ensure that at most one companion object is generated for this type
val companionObjectBuilder: Lazy<TypeSpec.Builder> = lazy { val companionObjectBuilder: Lazy<TypeSpec.Builder> = lazy {
@@ -153,7 +152,7 @@ class KotlinCodeGenerator(
"serialVersionUID", "serialVersionUID",
Long::class.java, Long::class.java,
KModifier.PRIVATE, KModifier.PRIVATE,
KModifier.CONST KModifier.CONST,
) )
.initializer("0L") .initializer("0L")
.build() .build()
@@ -307,7 +306,7 @@ class KotlinCodeGenerator(
builder.addStatement( builder.addStatement(
"if (this.$accessor != other.$accessor) return false", "if (this.$accessor != other.$accessor) return false",
propertyName, propertyName,
propertyName propertyName,
) )
} }
@@ -329,7 +328,7 @@ class KotlinCodeGenerator(
builder.addStatement( builder.addStatement(
"result = 31 * result + %T.hashCode($accessor)", "result = 31 * result + %T.hashCode($accessor)",
Objects::class, Objects::class,
propertyName propertyName,
) )
} }
@@ -355,14 +354,14 @@ class KotlinCodeGenerator(
} }
add(")") add(")")
} }
.build() .build(),
) )
.build() .build()
} }
fun generateDeprecation( fun generateDeprecation(
annotations: Collection<PObject>, annotations: Collection<PObject>,
addAnnotation: (AnnotationSpec) -> Unit addAnnotation: (AnnotationSpec) -> Unit,
) { ) {
annotations annotations
.firstOrNull { it.classInfo == PClassInfo.Deprecated } .firstOrNull { it.classInfo == PClassInfo.Deprecated }
@@ -511,7 +510,7 @@ class KotlinCodeGenerator(
private fun generateEnumTypeSpec( private fun generateEnumTypeSpec(
typeAlias: TypeAlias, typeAlias: TypeAlias,
stringLiterals: Set<String> stringLiterals: Set<String>,
): TypeSpec.Builder { ): TypeSpec.Builder {
val enumConstantToPklNames = val enumConstantToPklNames =
stringLiterals stringLiterals
@@ -545,7 +544,7 @@ class KotlinCodeGenerator(
for ((enumConstantName, pklName) in enumConstantToPklNames) { for ((enumConstantName, pklName) in enumConstantToPklNames) {
builder.addEnumConstant( builder.addEnumConstant(
enumConstantName, enumConstantName,
TypeSpec.anonymousClassBuilder().addSuperclassConstructorParameter("%S", pklName).build() TypeSpec.anonymousClassBuilder().addSuperclassConstructorParameter("%S", pklName).build(),
) )
} }
@@ -636,7 +635,7 @@ class KotlinCodeGenerator(
PClassInfo.Pair -> PClassInfo.Pair ->
KOTLIN_PAIR.parameterizedBy( KOTLIN_PAIR.parameterizedBy(
if (typeArguments.isEmpty()) ANY_NULL else typeArguments[0].toKotlinPoetName(), if (typeArguments.isEmpty()) ANY_NULL else typeArguments[0].toKotlinPoetName(),
if (typeArguments.isEmpty()) ANY_NULL else typeArguments[1].toKotlinPoetName() if (typeArguments.isEmpty()) ANY_NULL else typeArguments[1].toKotlinPoetName(),
) )
PClassInfo.Collection -> PClassInfo.Collection ->
COLLECTION.parameterizedBy( COLLECTION.parameterizedBy(
@@ -655,7 +654,7 @@ class KotlinCodeGenerator(
PClassInfo.Mapping -> PClassInfo.Mapping ->
MAP.parameterizedBy( MAP.parameterizedBy(
if (typeArguments.isEmpty()) ANY_NULL else typeArguments[0].toKotlinPoetName(), if (typeArguments.isEmpty()) ANY_NULL else typeArguments[0].toKotlinPoetName(),
if (typeArguments.isEmpty()) ANY_NULL else typeArguments[1].toKotlinPoetName() if (typeArguments.isEmpty()) ANY_NULL else typeArguments[1].toKotlinPoetName(),
) )
PClassInfo.Module -> PMODULE PClassInfo.Module -> PMODULE
PClassInfo.Class -> PCLASS PClassInfo.Class -> PCLASS
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,17 +20,11 @@ import javax.script.ScriptException
import kotlin.reflect.KClass import kotlin.reflect.KClass
import kotlin.text.RegexOption.MULTILINE import kotlin.text.RegexOption.MULTILINE
import kotlin.text.RegexOption.UNIX_LINES import kotlin.text.RegexOption.UNIX_LINES
import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback
class CompilationFailedException(msg: String?, cause: Throwable? = null) : class CompilationFailedException(msg: String?, cause: Throwable? = null) :
RuntimeException(msg, cause) RuntimeException(msg, cause)
object InMemoryKotlinCompiler { object InMemoryKotlinCompiler {
init {
// prevent "Unable to load JNA library" warning
setIdeaIoUseFallback()
}
// Implementation notes: // Implementation notes:
// * all [sourceFiles] are currently combined into a single file // * all [sourceFiles] are currently combined into a single file
// * implementation makes assumptions about structure of generated source files // * implementation makes assumptions about structure of generated source files
@@ -43,14 +37,16 @@ object InMemoryKotlinCompiler {
"^(data |open |enum )?class\\s+(\\w+) *(\\([^)]*\\))?.*$\\n((^ .*\\n|^$\\n)*)", "^(data |open |enum )?class\\s+(\\w+) *(\\([^)]*\\))?.*$\\n((^ .*\\n|^$\\n)*)",
transform: (String, String) -> Sequence<Pair<String, String>> = { name, body -> transform: (String, String) -> Sequence<Pair<String, String>> = { name, body ->
sequenceOf(Pair(name, prefix + name)) + body.findClasses("$prefix$name.") sequenceOf(Pair(name, prefix + name)) + body.findClasses("$prefix$name.")
} },
): Sequence<Pair<String, String>> = // (simpleName1, qualifiedName1), ... ): Sequence<Pair<String, String>> = // (simpleName1, qualifiedName1), ...
Regex(regex, setOf(MULTILINE, UNIX_LINES)).findAll(this).flatMap { Regex(regex, setOf(MULTILINE, UNIX_LINES)).findAll(this).flatMap {
transform(it.groupValues[nameGroup], it.groupValues[bodyGroup].trimIndent()) transform(it.groupValues[nameGroup], it.groupValues[bodyGroup].trimIndent())
} }
fun String.findOuterObjects(): Sequence<Pair<String, String>> = // (simpleName, qualifiedName) fun String.findOuterObjects(): Sequence<Pair<String, String>> = // (simpleName, qualifiedName)
findClasses("", 1, 2, "^object\\s+(\\w+).*$\n((^ .*$\n|^$\n)*)") { name, body -> findClasses(nameGroup = 1, bodyGroup = 2, regex = "^object\\s+(\\w+).*$\n((^ .*$\n|^$\n)*)") {
name,
body ->
body.findClasses("$name.") body.findClasses("$name.")
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.assertAll
import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.test.ReflectionUtils.enumValues
import org.pkl.core.* import org.pkl.core.*
import org.pkl.core.util.IoUtils import org.pkl.core.util.IoUtils
@@ -67,7 +68,7 @@ class KotlinCodeGeneratorTest {
"do", "do",
"when", "when",
"interface", "interface",
"typeof" "typeof",
) )
private val simpleClass: KClass<*> by lazy { private val simpleClass: KClass<*> by lazy {
@@ -139,7 +140,7 @@ class KotlinCodeGeneratorTest {
pklCode: String, pklCode: String,
generateKdoc: Boolean = false, generateKdoc: Boolean = false,
generateSpringBootConfig: Boolean = false, generateSpringBootConfig: Boolean = false,
implementSerializable: Boolean = false implementSerializable: Boolean = false,
): KotlinSourceCode { ): KotlinSourceCode {
val module = Evaluator.preconfigured().evaluateSchema(ModuleSource.text(pklCode)) val module = Evaluator.preconfigured().evaluateSchema(ModuleSource.text(pklCode))
@@ -150,8 +151,8 @@ class KotlinCodeGeneratorTest {
KotlinCodeGeneratorOptions( KotlinCodeGeneratorOptions(
generateKdoc = generateKdoc, generateKdoc = generateKdoc,
generateSpringBootConfig = generateSpringBootConfig, generateSpringBootConfig = generateSpringBootConfig,
implementSerializable = implementSerializable implementSerializable = implementSerializable,
) ),
) )
return KotlinSourceCode(generator.kotlinFile) return KotlinSourceCode(generator.kotlinFile)
} }
@@ -435,7 +436,7 @@ class KotlinCodeGeneratorTest {
"digit-1" to "DIGIT_1", "digit-1" to "DIGIT_1",
"42" to "_42", "42" to "_42",
"àœü" to "ÀŒÜ", "àœü" to "ÀŒÜ",
"日本-つくば" to "日本_つくば" "日本-つくば" to "日本_つくば",
) )
val kotlinCode = val kotlinCode =
generateKotlinCode( generateKotlinCode(
@@ -445,27 +446,16 @@ class KotlinCodeGeneratorTest {
""" """
.trimIndent() .trimIndent()
) )
val kotlinClass = kotlinCode.compile().getValue("MyTypeAlias").java val kotlinClass = kotlinCode.compile().getValue("MyTypeAlias")
assertThat(kotlinClass.enumConstants.size) assertThat(kotlinClass.enumValues().size)
.isEqualTo(cases.size) // make sure zip doesn't drop cases .isEqualTo(cases.size) // make sure zip doesn't drop cases
assertAll( assertAll(
"generated enum constants have correct names", kotlinClass.enumValues().zip(cases) { enumValue, (pklName, kotlinName) ->
kotlinClass.declaredFields.zip(cases) { field, (_, kotlinName) ->
{ {
assertThat(field.name).isEqualTo(kotlinName) assertThat(enumValue.name).isEqualTo(kotlinName)
Unit assertThat(enumValue.toString()).isEqualTo(pklName)
}
}
)
assertAll(
"toString() returns Pkl name",
kotlinClass.enumConstants.zip(cases) { enumConstant, (pklName, _) ->
{
assertThat(enumConstant.toString()).isEqualTo(pklName)
Unit
} }
} }
) )
@@ -1048,7 +1038,7 @@ class KotlinCodeGeneratorTest {
typealias Email = String(contains("@")) typealias Email = String(contains("@"))
""" """
.trimIndent(), .trimIndent(),
generateKdoc = true generateKdoc = true,
) )
assertThat(kotlinCode).compilesSuccessfully().isEqualToResourceFile("Kdoc.kotlin") assertThat(kotlinCode).compilesSuccessfully().isEqualToResourceFile("Kdoc.kotlin")
@@ -1066,7 +1056,7 @@ class KotlinCodeGeneratorTest {
class Product class Product
""" """
.trimIndent(), .trimIndent(),
generateKdoc = true generateKdoc = true,
) )
assertThat(kotlinCode) assertThat(kotlinCode)
@@ -1428,7 +1418,7 @@ class KotlinCodeGeneratorTest {
} }
""" """
.trimIndent(), .trimIndent(),
generateSpringBootConfig = true generateSpringBootConfig = true,
) )
assertThat(kotlinCode) assertThat(kotlinCode)
@@ -1470,7 +1460,7 @@ class KotlinCodeGeneratorTest {
pigeon: Person pigeon: Person
""" """
.trimIndent() .trimIndent(),
) )
val client = val client =
@@ -1485,7 +1475,7 @@ class KotlinCodeGeneratorTest {
parrot: library.Person parrot: library.Person
""" """
.trimIndent() .trimIndent(),
) )
val kotlinSourceFiles = generateFiles(library, client) val kotlinSourceFiles = generateFiles(library, client)
@@ -1520,7 +1510,7 @@ class KotlinCodeGeneratorTest {
pigeon: Person pigeon: Person
""" """
.trimIndent() .trimIndent(),
) )
val derived = val derived =
@@ -1535,7 +1525,7 @@ class KotlinCodeGeneratorTest {
person1: Person person1: Person
person2: Person2 person2: Person2
""" """
.trimIndent() .trimIndent(),
) )
val kotlinSourceFiles = generateFiles(base, derived) val kotlinSourceFiles = generateFiles(base, derived)
@@ -1584,7 +1574,7 @@ class KotlinCodeGeneratorTest {
typealias Version = "LATEST"|String typealias Version = "LATEST"|String
""" """
.trimIndent() .trimIndent(),
) )
val moduleTwo = val moduleTwo =
@@ -1597,7 +1587,7 @@ class KotlinCodeGeneratorTest {
v: Version = "1.2.3" v: Version = "1.2.3"
""" """
.trimIndent() .trimIndent(),
) )
val kotlinSourceFiles = generateFiles(moduleOne, moduleTwo) val kotlinSourceFiles = generateFiles(moduleOne, moduleTwo)
@@ -1638,7 +1628,7 @@ class KotlinCodeGeneratorTest {
prop: Int prop: Int
} }
""" """
.trimIndent() .trimIndent(),
) )
val generated = generateFiles(pklModule) val generated = generateFiles(pklModule)
val expectedPropertyFile = val expectedPropertyFile =
@@ -1692,7 +1682,7 @@ class KotlinCodeGeneratorTest {
abstract class NotSerializable abstract class NotSerializable
""" """
.trimIndent(), .trimIndent(),
implementSerializable = true implementSerializable = true,
) )
assertThat(kotlinCode) assertThat(kotlinCode)
@@ -1731,7 +1721,7 @@ class KotlinCodeGeneratorTest {
smallStruct, smallStruct,
Regex("(i?)\\w*"), Regex("(i?)\\w*"),
smallStruct, smallStruct,
enumValue enumValue,
) )
fun confirmSerDe(instance: Any) { fun confirmSerDe(instance: Any) {
@@ -1777,7 +1767,7 @@ class KotlinCodeGeneratorTest {
street: String street: String
} }
""", """,
implementSerializable = true implementSerializable = true,
) )
assertThat(kotlinCode) assertThat(kotlinCode)
@@ -1814,7 +1804,7 @@ class KotlinCodeGeneratorTest {
someProp: String someProp: String
""" """
.trimIndent() .trimIndent(),
) )
) )
assertThat(kotlinCode).containsKey("kotlin/Foo(2a)Bar.kt") assertThat(kotlinCode).containsKey("kotlin/Foo(2a)Bar.kt")
@@ -1840,7 +1830,7 @@ class KotlinCodeGeneratorTest {
bar: Int = 123 bar: Int = 123
""" """
.trimIndent() .trimIndent(),
) )
.toMutableMap() .toMutableMap()
@@ -1882,7 +1872,7 @@ class KotlinCodeGeneratorTest {
baz: String baz: String
""" """
.trimIndent() .trimIndent(),
) )
.toMutableMap() .toMutableMap()
@@ -1897,7 +1887,7 @@ class KotlinCodeGeneratorTest {
// --- // ---
"kotlin/w/org/baz/Module3.kt" to listOf("package w.org.baz", "data class Module3("), "kotlin/w/org/baz/Module3.kt" to listOf("package w.org.baz", "data class Module3("),
"$MAPPER_PREFIX/org.baz.Module3.properties" to "$MAPPER_PREFIX/org.baz.Module3.properties" to
listOf("org.pkl.config.java.mapper.org.baz.Module3\\#ModuleClass=w.org.baz.Module3") listOf("org.pkl.config.java.mapper.org.baz.Module3\\#ModuleClass=w.org.baz.Module3"),
) )
} }
@@ -1909,7 +1899,7 @@ class KotlinCodeGeneratorTest {
mapOf( mapOf(
"org.foo" to "com.foo.x", "org.foo" to "com.foo.x",
"org.bar.Module2" to "org.bar.RenamedModule", "org.bar.Module2" to "org.bar.RenamedModule",
"org.baz" to "com.baz.a.b" "org.baz" to "com.baz.a.b",
) )
) )
.generateFiles( .generateFiles(
@@ -1944,7 +1934,7 @@ class KotlinCodeGeneratorTest {
owner: Module2.Group owner: Module2.Group
} }
""" """
.trimIndent() .trimIndent(),
) )
files.validateContents( files.validateContents(
@@ -1961,7 +1951,7 @@ class KotlinCodeGeneratorTest {
"package org.bar", "package org.bar",
"import com.foo.x.Module1", "import com.foo.x.Module1",
"object RenamedModule {", "object RenamedModule {",
"val owner: Module1.Person" "val owner: Module1.Person",
), ),
"$MAPPER_PREFIX/org.bar.Module2.properties" to "$MAPPER_PREFIX/org.bar.Module2.properties" to
listOf( listOf(
@@ -1974,7 +1964,7 @@ class KotlinCodeGeneratorTest {
"package com.baz.a.b", "package com.baz.a.b",
"import org.bar.RenamedModule", "import org.bar.RenamedModule",
"object Module3 {", "object Module3 {",
"val owner: RenamedModule.Group" "val owner: RenamedModule.Group",
), ),
"$MAPPER_PREFIX/org.baz.Module3.properties" to "$MAPPER_PREFIX/org.baz.Module3.properties" to
listOf( listOf(
@@ -2004,7 +1994,7 @@ class KotlinCodeGeneratorTest {
bar: Int = 123 bar: Int = 123
""" """
.trimIndent() .trimIndent(),
) )
files.validateContents( files.validateContents(
@@ -2087,7 +2077,7 @@ class KotlinCodeGeneratorTest {
Regex("(i?)\\w*"), Regex("(i?)\\w*"),
other, other,
other, other,
enumValue enumValue,
) )
return other to propertyTypes return other to propertyTypes
@@ -2099,7 +2089,7 @@ class KotlinCodeGeneratorTest {
private class KotlinSourceCodeAssert(actual: KotlinSourceCode) : private class KotlinSourceCodeAssert(actual: KotlinSourceCode) :
AbstractAssert<KotlinSourceCodeAssert, KotlinSourceCode>( AbstractAssert<KotlinSourceCodeAssert, KotlinSourceCode>(
actual, actual,
KotlinSourceCodeAssert::class.java KotlinSourceCodeAssert::class.java,
) { ) {
fun contains(expected: String): KotlinSourceCodeAssert { fun contains(expected: String): KotlinSourceCodeAssert {
if (!actual.text.contains(expected)) { if (!actual.text.contains(expected)) {
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.pkl.codegen.kotlin package org.pkl.codegen.kotlin
import java.nio.file.Path import java.nio.file.Path
import org.pkl.commons.createParentDirectories import kotlin.io.path.createParentDirectories
import org.pkl.commons.writeString import org.pkl.commons.writeString
data class PklModule(val name: String, val content: String) { data class PklModule(val name: String, val content: String) {
@@ -1 +0,0 @@
org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory
+22 -16
View File
@@ -5,26 +5,32 @@ com.github.ajalt.clikt:clikt-jvm:3.5.4=compileClasspath,runtimeClasspath,testCom
com.github.ajalt.clikt:clikt:3.5.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath com.github.ajalt.clikt:clikt:3.5.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.tunnelvisionlabs:antlr4-runtime:4.9.0=runtimeClasspath,testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=runtimeClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
+2 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ dependencies {
api(libs.clikt) { api(libs.clikt) {
// force clikt to use our version of the kotlin stdlib // force clikt to use our version of the kotlin stdlib
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8") exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common") exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
} }
implementation(projects.pklCommons) implementation(projects.pklCommons)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,10 +19,6 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.groups.provideDelegate import com.github.ajalt.clikt.parameters.groups.provideDelegate
abstract class BaseCommand(name: String, helpLink: String, help: String = "") : abstract class BaseCommand(name: String, helpLink: String, help: String = "") :
CliktCommand( CliktCommand(name = name, help = help, epilog = "For more information, visit $helpLink") {
name = name, val baseOptions: BaseOptions by BaseOptions()
help = help,
epilog = "For more information, visit $helpLink",
) {
val baseOptions by BaseOptions()
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -82,7 +82,9 @@ class BaseOptions : OptionGroup() {
fun OptionWithValues<String?, String, String>.parseExternalReader( fun OptionWithValues<String?, String, String>.parseExternalReader(
delimiter: String delimiter: String
): OptionWithValues< ): OptionWithValues<
Pair<String, ExternalReader>?, Pair<String, ExternalReader>, Pair<String, ExternalReader> Pair<String, ExternalReader>?,
Pair<String, ExternalReader>,
Pair<String, ExternalReader>,
> { > {
return splitPair(delimiter).convert { return splitPair(delimiter).convert {
val cmd = shlex(it.second) val cmd = shlex(it.second)
@@ -99,24 +101,24 @@ class BaseOptions : OptionGroup() {
val allowedModules: List<Pattern> by val allowedModules: List<Pattern> by
option( option(
names = arrayOf("--allowed-modules"), names = arrayOf("--allowed-modules"),
help = "URI patterns that determine which modules can be loaded and evaluated." help = "URI patterns that determine which modules can be loaded and evaluated.",
) )
.convert("<pattern1,pattern2>") { Pattern.compile(it) } .convert("<pattern1,pattern2>") { Pattern.compile(it) }
.splitAll(",") .splitAll()
val allowedResources: List<Pattern> by val allowedResources: List<Pattern> by
option( option(
names = arrayOf("--allowed-resources"), names = arrayOf("--allowed-resources"),
help = "URI patterns that determine which external resources can be read." help = "URI patterns that determine which external resources can be read.",
) )
.convert("<pattern1,pattern2>") { Pattern.compile(it) } .convert("<pattern1,pattern2>") { Pattern.compile(it) }
.splitAll(",") .splitAll()
val rootDir: Path? by val rootDir: Path? by
option( option(
names = arrayOf("--root-dir"), names = arrayOf("--root-dir"),
help = help =
"Restricts access to file-based modules and resources to those located under the root directory." "Restricts access to file-based modules and resources to those located under the root directory.",
) )
.single() .single()
.path() .path()
@@ -129,7 +131,7 @@ class BaseOptions : OptionGroup() {
val workingDir: Path by val workingDir: Path by
option( option(
names = arrayOf("-w", "--working-dir"), names = arrayOf("-w", "--working-dir"),
help = "Base path that relative module paths are resolved against." help = "Base path that relative module paths are resolved against.",
) )
.single() .single()
.path() .path()
@@ -139,7 +141,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("-p", "--property"), names = arrayOf("-p", "--property"),
metavar = "<name=value>", metavar = "<name=value>",
help = "External property to set (repeatable)." help = "External property to set (repeatable).",
) )
.associateProps() .associateProps()
@@ -148,7 +150,7 @@ class BaseOptions : OptionGroup() {
names = arrayOf("--color"), names = arrayOf("--color"),
metavar = "<when>", metavar = "<when>",
help = help =
"Whether to format messages in ANSI color. Possible values of <when> are 'never', 'auto', and 'always'." "Whether to format messages in ANSI color. Possible values of <when> are 'never', 'auto', and 'always'.",
) )
.enum<Color> { it.name.lowercase() } .enum<Color> { it.name.lowercase() }
.single() .single()
@@ -162,7 +164,7 @@ class BaseOptions : OptionGroup() {
val format: String? by val format: String? by
option( option(
names = arrayOf("-f", "--format"), names = arrayOf("-f", "--format"),
help = "Output format to generate. <${output.joinToString()}>" help = "Output format to generate. <${output.joinToString()}>",
) )
.single() .single()
@@ -170,7 +172,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("-e", "--env-var"), names = arrayOf("-e", "--env-var"),
metavar = "<name=value>", metavar = "<name=value>",
help = "Environment variable to set (repeatable)." help = "Environment variable to set (repeatable).",
) )
.associate() .associate()
@@ -179,7 +181,7 @@ class BaseOptions : OptionGroup() {
names = arrayOf("--module-path"), names = arrayOf("--module-path"),
metavar = "<path1${File.pathSeparator}path2>", metavar = "<path1${File.pathSeparator}path2>",
help = help =
"Directories, ZIP archives, or JAR archives to search when resolving `modulepath:` URIs." "Directories, ZIP archives, or JAR archives to search when resolving `modulepath:` URIs.",
) )
.path() .path()
.splitAll(File.pathSeparator) .splitAll(File.pathSeparator)
@@ -193,7 +195,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("-t", "--timeout"), names = arrayOf("-t", "--timeout"),
metavar = "<number>", metavar = "<number>",
help = "Duration, in seconds, after which evaluation of a source module will be timed out." help = "Duration, in seconds, after which evaluation of a source module will be timed out.",
) )
.single() .single()
.long() .long()
@@ -203,7 +205,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("--ca-certificates"), names = arrayOf("--ca-certificates"),
metavar = "<path>", metavar = "<path>",
help = "Only trust CA certificates from the provided file(s)." help = "Only trust CA certificates from the provided file(s).",
) )
.path() .path()
.multiple() .multiple()
@@ -212,7 +214,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("--http-proxy"), names = arrayOf("--http-proxy"),
metavar = "<address>", metavar = "<address>",
help = "Proxy to use for HTTP(S) connections." help = "Proxy to use for HTTP(S) connections.",
) )
.single() .single()
.convert { URI(it) } .convert { URI(it) }
@@ -228,7 +230,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("--http-no-proxy"), names = arrayOf("--http-no-proxy"),
metavar = "<pattern1,pattern2>", metavar = "<pattern1,pattern2>",
help = "Hostnames that should not be connected to via a proxy." help = "Hostnames that should not be connected to via a proxy.",
) )
.single() .single()
.split(",") .split(",")
@@ -237,7 +239,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("--external-module-reader"), names = arrayOf("--external-module-reader"),
metavar = "<scheme>='<executable>[ <arguments>]'", metavar = "<scheme>='<executable>[ <arguments>]'",
help = "External reader registrations for module URI schemes" help = "External reader registrations for module URI schemes",
) )
.parseExternalReader("=") .parseExternalReader("=")
.multiple() .multiple()
@@ -247,7 +249,7 @@ class BaseOptions : OptionGroup() {
option( option(
names = arrayOf("--external-resource-reader"), names = arrayOf("--external-resource-reader"),
metavar = "<scheme>='<executable>[ <arguments>]'", metavar = "<scheme>='<executable>[ <arguments>]'",
help = "External reader registrations for resource URI schemes" help = "External reader registrations for resource URI schemes",
) )
.parseExternalReader("=") .parseExternalReader("=")
.multiple() .multiple()
@@ -263,7 +265,7 @@ class BaseOptions : OptionGroup() {
fun baseOptions( fun baseOptions(
modules: List<URI>, modules: List<URI>,
projectOptions: ProjectOptions? = null, projectOptions: ProjectOptions? = null,
testMode: Boolean = false testMode: Boolean = false,
): CliBaseOptions { ): CliBaseOptions {
return CliBaseOptions( return CliBaseOptions(
sourceModules = modules, sourceModules = modules,
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,15 +22,11 @@ import com.github.ajalt.clikt.parameters.groups.provideDelegate
import java.net.URI import java.net.URI
abstract class ModulesCommand(name: String, helpLink: String, help: String = "") : abstract class ModulesCommand(name: String, helpLink: String, help: String = "") :
BaseCommand( BaseCommand(name = name, help = help, helpLink = helpLink) {
name = name,
help = help,
helpLink = helpLink,
) {
open val modules: List<URI> by open val modules: List<URI> by
argument(name = "<modules>", help = "Module paths or URIs to evaluate.") argument(name = "<modules>", help = "Module paths or URIs to evaluate.")
.convert { BaseOptions.parseModuleName(it) } .convert { BaseOptions.parseModuleName(it) }
.multiple(required = true) .multiple(required = true)
protected val projectOptions by ProjectOptions() protected val projectOptions: ProjectOptions by ProjectOptions()
} }
+21 -16
View File
@@ -2,24 +2,29 @@
# Manual edits can break the build and are not advised. # Manual edits can break the build and are not advised.
# This file is expected to be part of source control. # This file is expected to be part of source control.
net.bytebuddy:byte-buddy:1.15.11=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import javax.net.ssl.SSLSession
class FakeHttpResponse<T : Any> : HttpResponse<T> { class FakeHttpResponse<T : Any> : HttpResponse<T> {
companion object { companion object {
@Suppress("unused")
fun <T : Any> withBody(block: FakeHttpResponse<T>.() -> Unit): FakeHttpResponse<T> = fun <T : Any> withBody(block: FakeHttpResponse<T>.() -> Unit): FakeHttpResponse<T> =
FakeHttpResponse<T>().apply(block) FakeHttpResponse<T>().apply(block)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.pkl.commons.toNormalizedPathString
abstract class InputOutputTestEngine : abstract class InputOutputTestEngine :
HierarchicalTestEngine<InputOutputTestEngine.ExecutionContext>() { HierarchicalTestEngine<InputOutputTestEngine.ExecutionContext>() {
protected val rootProjectDir = FileTestUtils.rootProjectDir protected val rootProjectDir: Path = FileTestUtils.rootProjectDir
protected abstract val testClass: KClass<*> protected abstract val testClass: KClass<*>
@@ -67,7 +67,7 @@ abstract class InputOutputTestEngine :
override fun discover( override fun discover(
discoveryRequest: EngineDiscoveryRequest, discoveryRequest: EngineDiscoveryRequest,
uniqueId: UniqueId uniqueId: UniqueId,
): TestDescriptor { ): TestDescriptor {
val packageSelectors = discoveryRequest.getSelectorsByType(PackageSelector::class.java) val packageSelectors = discoveryRequest.getSelectorsByType(PackageSelector::class.java)
val classSelectors = discoveryRequest.getSelectorsByType(ClassSelector::class.java) val classSelectors = discoveryRequest.getSelectorsByType(ClassSelector::class.java)
@@ -103,7 +103,7 @@ abstract class InputOutputTestEngine :
private fun doDiscover( private fun doDiscover(
dirNode: InputDirNode, dirNode: InputDirNode,
uniqueIdSelectors: List<UniqueIdSelector> uniqueIdSelectors: List<UniqueIdSelector>,
): TestDescriptor { ): TestDescriptor {
dirNode.inputDir.useDirectoryEntries { children -> dirNode.inputDir.useDirectoryEntries { children ->
for (child in children) { for (child in children) {
@@ -128,7 +128,7 @@ abstract class InputOutputTestEngine :
dirNode.addChild( dirNode.addChild(
doDiscover( doDiscover(
InputDirNode(childId, child, DirectorySource.from(child.toFile())), InputDirNode(childId, child, DirectorySource.from(child.toFile())),
uniqueIdSelectors uniqueIdSelectors,
) )
) )
} }
@@ -137,12 +137,13 @@ abstract class InputOutputTestEngine :
return dirNode return dirNode
} }
override fun createExecutionContext(request: ExecutionRequest) = ExecutionContext() override fun createExecutionContext(request: ExecutionRequest): ExecutionContext =
ExecutionContext()
private open inner class InputDirNode( private open inner class InputDirNode(
uniqueId: UniqueId, uniqueId: UniqueId,
val inputDir: Path, val inputDir: Path,
source: TestSource source: TestSource,
) : ) :
AbstractTestDescriptor(uniqueId, inputDir.fileName.toString(), source), Node<ExecutionContext> { AbstractTestDescriptor(uniqueId, inputDir.fileName.toString(), source), Node<ExecutionContext> {
override fun getType() = Type.CONTAINER override fun getType() = Type.CONTAINER
@@ -152,7 +153,7 @@ abstract class InputOutputTestEngine :
AbstractTestDescriptor( AbstractTestDescriptor(
uniqueId, uniqueId,
inputFile.fileName.toString(), inputFile.fileName.toString(),
FileSource.from(inputFile.toFile()) FileSource.from(inputFile.toFile()),
), ),
Node<ExecutionContext> { Node<ExecutionContext> {
@@ -160,7 +161,7 @@ abstract class InputOutputTestEngine :
override fun execute( override fun execute(
context: ExecutionContext, context: ExecutionContext,
dynamicTestExecutor: DynamicTestExecutor dynamicTestExecutor: DynamicTestExecutor,
): ExecutionContext { ): ExecutionContext {
val (success, actualOutput) = generateOutputFor(inputFile) val (success, actualOutput) = generateOutputFor(inputFile)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,10 +22,7 @@ import java.security.KeyStore
import java.util.concurrent.Executors import java.util.concurrent.Executors
import javax.net.ssl.KeyManagerFactory import javax.net.ssl.KeyManagerFactory
import javax.net.ssl.SSLContext import javax.net.ssl.SSLContext
import kotlin.io.path.inputStream import kotlin.io.path.*
import kotlin.io.path.isRegularFile
import org.pkl.commons.createParentDirectories
import org.pkl.commons.deleteRecursively
/** /**
* A test HTTP server that serves the Pkl packages defined under * A test HTTP server that serves the Pkl packages defined under
@@ -44,6 +41,7 @@ import org.pkl.commons.deleteRecursively
* 4. Use port `0` in your test. `HttpClient` will replace this port with the server port. * 4. Use port `0` in your test. `HttpClient` will replace this port with the server port.
* 4. [Close][close] the server, for example in [AfterAll][org.junit.jupiter.api.AfterAll]. * 4. [Close][close] the server, for example in [AfterAll][org.junit.jupiter.api.AfterAll].
*/ */
@OptIn(ExperimentalPathApi::class)
class PackageServer : AutoCloseable { class PackageServer : AutoCloseable {
companion object { companion object {
const val BIRDS_SHA = "6f18af649b47986530cd6dc39abe17888db2701bc5381c385fb86a32fda2685e" const val BIRDS_SHA = "6f18af649b47986530cd6dc39abe17888db2701bc5381c385fb86a32fda2685e"
@@ -0,0 +1,24 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pkl.commons.test
import kotlin.reflect.KClass
object ReflectionUtils {
// https://youtrack.jetbrains.com/issue/KT-14743/Reflection-Access-enum-values-and-valueOf-via-KClass#focus=Comments-27-1745309.0-0
@Suppress("UNCHECKED_CAST")
fun KClass<*>.enumValues(): Array<Enum<*>> = java.enumConstants as Array<Enum<*>>
}
+21 -16
View File
@@ -2,24 +2,29 @@
# Manual edits can break the build and are not advised. # Manual edits can break the build and are not advised.
# This file is expected to be part of source control. # This file is expected to be part of source control.
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,10 +20,6 @@ import java.nio.charset.Charset
import java.nio.file.* import java.nio.file.*
import java.nio.file.attribute.FileAttribute import java.nio.file.attribute.FileAttribute
import java.util.stream.Stream import java.util.stream.Stream
import kotlin.io.path.createDirectories
import kotlin.io.path.deleteIfExists
import kotlin.io.path.exists
import kotlin.io.path.isSymbolicLink
// not stored to avoid build-time initialization by native-image // not stored to avoid build-time initialization by native-image
val currentWorkingDir: Path val currentWorkingDir: Path
@@ -40,38 +36,21 @@ fun Path.walk(maxDepth: Int = Int.MAX_VALUE, vararg options: FileVisitOption): S
fun Path.createTempFile( fun Path.createTempFile(
prefix: String? = null, prefix: String? = null,
suffix: String? = null, suffix: String? = null,
vararg attributes: FileAttribute<*> vararg attributes: FileAttribute<*>,
): Path = Files.createTempFile(this, prefix, suffix, *attributes) ): Path = Files.createTempFile(this, prefix, suffix, *attributes)
@Throws(IOException::class)
fun Path.createParentDirectories(vararg attributes: FileAttribute<*>): Path = apply {
// Files.createDirectories will throw a FileAlreadyExistsException
// if the file exists and is not a directory and symlinks are never
// directories
if (parent?.isSymbolicLink() != true) {
parent?.createDirectories(*attributes)
}
}
/** [Files.writeString] seems more efficient than [kotlin.io.path.writeText]. */ /** [Files.writeString] seems more efficient than [kotlin.io.path.writeText]. */
@Throws(IOException::class) @Throws(IOException::class)
fun Path.writeString( fun Path.writeString(
text: String, text: String,
charset: Charset = Charsets.UTF_8, charset: Charset = Charsets.UTF_8,
vararg options: OpenOption vararg options: OpenOption,
): Path = Files.writeString(this, text, charset, *options) ): Path = Files.writeString(this, text, charset, *options)
/** [Files.readString] seems more efficient than [kotlin.io.path.readText]. */ /** [Files.readString] seems more efficient than [kotlin.io.path.readText]. */
@Throws(IOException::class) @Throws(IOException::class)
fun Path.readString(charset: Charset = Charsets.UTF_8): String = Files.readString(this, charset) fun Path.readString(charset: Charset = Charsets.UTF_8): String = Files.readString(this, charset)
@Throws(IOException::class)
fun Path.deleteRecursively() {
if (exists()) {
walk().use { paths -> paths.sorted(Comparator.reverseOrder()).forEach { it.deleteIfExists() } }
}
}
private val isWindows by lazy { System.getProperty("os.name").contains("Windows") } private val isWindows by lazy { System.getProperty("os.name").contains("Windows") }
/** Copy implementation from IoUtils.toNormalizedPathString */ /** Copy implementation from IoUtils.toNormalizedPathString */
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.pkl.commons
import java.io.File import java.io.File
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
fun String.toPath(): Path = Path.of(this) fun String.toPath(): Path = Path.of(this)
+22 -16
View File
@@ -8,26 +8,32 @@ com.tunnelvisionlabs:antlr4-runtime:4.9.0=pklCodegenJava,runtimeClasspath,testRu
io.leangen.geantyref:geantyref:1.3.16=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath io.leangen.geantyref:geantyref:1.3.16=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
javax.inject:javax.inject:1=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath javax.inject:javax.inject:1=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=pklCodegenJava,runtimeClasspath,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=pklCodegenJava,runtimeClasspath,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=pklCodegenJava,runtimeClasspath,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=pklCodegenJava,runtimeClasspath,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=pklCodegenJava
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenJava,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenJava,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
+23 -16
View File
@@ -7,26 +7,33 @@ com.squareup:kotlinpoet:1.6.0=pklCodegenKotlin
com.tunnelvisionlabs:antlr4-runtime:4.9.0=pklCodegenKotlin,pklConfigJava,runtimeClasspath,testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=pklCodegenKotlin,pklConfigJava,runtimeClasspath,testRuntimeClasspath
io.leangen.geantyref:geantyref:1.3.16=pklConfigJava,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath io.leangen.geantyref:geantyref:1.3.16=pklConfigJava,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=pklCodegenKotlin,pklConfigJava,runtimeClasspath,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=pklCodegenKotlin,pklConfigJava,runtimeClasspath,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=pklCodegenKotlin,pklConfigJava,runtimeClasspath,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=pklCodegenKotlin,pklConfigJava,runtimeClasspath,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:2.0.21=compileClasspath,implementationDependenciesMetadata,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=pklCodegenKotlin
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,pklCodegenKotlin,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -38,14 +38,15 @@ import org.pkl.config.kotlin.mapper.KotlinConverterFactories
*/ */
inline fun <reified T> Config.to(): T { inline fun <reified T> Config.to(): T {
val javaType = object : JavaType<T>() {} val javaType = object : JavaType<T>() {}
val result = `as`<T>(javaType.type) // `as T?` may no longer be required after switching to JSpecify
val result = `as`<T>(javaType.type) as T?
if (result == null && null !is T) { if (result == null && null !is T) {
throw ConversionException( throw ConversionException(
"Expected a non-null value but got `null`. " + "Expected a non-null value but got `null`. " +
"To allow null values, convert to a nullable Kotlin type, for example `String?`." "To allow null values, convert to a nullable Kotlin type, for example `String?`."
) )
} }
return result return result as T
} }
/** /**
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -171,7 +171,7 @@ class ConfigExtensionsTest {
mapOf( mapOf(
"l" to SimplePerson("lilly"), "l" to SimplePerson("lilly"),
"b" to SimplePerson("bob"), "b" to SimplePerson("bob"),
"s" to SimplePerson("susan") "s" to SimplePerson("susan"),
) )
) )
} }
@@ -189,14 +189,14 @@ class ConfigExtensionsTest {
mapOf( mapOf(
"l" to SimplePerson("lilly"), "l" to SimplePerson("lilly"),
"b" to SimplePerson("bob"), "b" to SimplePerson("bob"),
"s" to SimplePerson("susan") "s" to SimplePerson("susan"),
) )
) )
} }
@Test @Test
fun `convert enum with mangled names`() { fun `convert enum with mangled names`() {
val values = MangledNameEnum.values().map { "\"$it\"" } val values = MangledNameEnum.entries.map { "\"$it\"" }
val config = val config =
evaluator.evaluate( evaluator.evaluate(
text( text(
@@ -208,7 +208,7 @@ class ConfigExtensionsTest {
) )
) )
val allEnumValues = config["allEnumValues"].to<Set<MangledNameEnum>>() val allEnumValues = config["allEnumValues"].to<Set<MangledNameEnum>>()
assertThat(allEnumValues).isEqualTo(MangledNameEnum.values().toSet()) assertThat(allEnumValues).isEqualTo(MangledNameEnum.entries.toSet())
} }
data class SimplePerson(val name: String) data class SimplePerson(val name: String)
@@ -218,7 +218,7 @@ class ConfigExtensionsTest {
enum class Hobby { enum class Hobby {
SWIMMING, SWIMMING,
@Suppress("unused") SURFING, @Suppress("unused") SURFING,
READING READING,
} }
data class Address<out T>(val street: T) data class Address<out T>(val street: T)
@@ -240,7 +240,7 @@ class ConfigExtensionsTest {
class PersonWithDefaults( class PersonWithDefaults(
val name: String = "Pigeon", val name: String = "Pigeon",
val age: Int = 42, val age: Int = 42,
val hobbies: List<String> val hobbies: List<String>,
) )
@Suppress("NonAsciiCharacters", "EnumEntryName") @Suppress("NonAsciiCharacters", "EnumEntryName")
@@ -252,6 +252,6 @@ class ConfigExtensionsTest {
_42_FROM_INVALID_START("42-from-invalid-start"), _42_FROM_INVALID_START("42-from-invalid-start"),
__EMOJI__("❎Emoji✅✅"), __EMOJI__("❎Emoji✅✅"),
ÀŒÜ("àœü"), ÀŒÜ("àœü"),
日本_つくば("日本-つくば") 日本_つくば("日本-つくば"),
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -42,19 +42,19 @@ class KotlinConversionsTest {
@Test @Test
fun pIntToULong() { fun pIntToULong() {
assertThat(KotlinConversions.pIntToULong.converter.convert(0, mapper)).isEqualTo(0UL) assertThat(KotlinConversions.pIntToULong.converter.convert(0L, mapper)).isEqualTo(0UL)
assertThat(KotlinConversions.pIntToULong.converter.convert(Long.MAX_VALUE, mapper)) assertThat(KotlinConversions.pIntToULong.converter.convert(Long.MAX_VALUE, mapper))
.isEqualTo(Long.MAX_VALUE.toULong()) .isEqualTo(Long.MAX_VALUE.toULong())
assertThrows<ConversionException> { assertThrows<ConversionException> {
KotlinConversions.pIntToULong.converter.convert(-1, mapper) KotlinConversions.pIntToULong.converter.convert(-1L, mapper)
} }
} }
@Test @Test
fun pIntToUInt() { fun pIntToUInt() {
assertThat(KotlinConversions.pIntToUInt.converter.convert(0, mapper)).isEqualTo(0u) assertThat(KotlinConversions.pIntToUInt.converter.convert(0L, mapper)).isEqualTo(0u)
assertThat(KotlinConversions.pIntToUInt.converter.convert(UInt.MAX_VALUE.toLong(), mapper)) assertThat(KotlinConversions.pIntToUInt.converter.convert(UInt.MAX_VALUE.toLong(), mapper))
.isEqualTo(UInt.MAX_VALUE) .isEqualTo(UInt.MAX_VALUE)
@@ -63,12 +63,14 @@ class KotlinConversionsTest {
KotlinConversions.pIntToUInt.converter.convert(UInt.MAX_VALUE.toLong() + 1, mapper) KotlinConversions.pIntToUInt.converter.convert(UInt.MAX_VALUE.toLong() + 1, mapper)
} }
assertThrows<ConversionException> { KotlinConversions.pIntToUInt.converter.convert(-1, mapper) } assertThrows<ConversionException> {
KotlinConversions.pIntToUInt.converter.convert(-1L, mapper)
}
} }
@Test @Test
fun pIntToUShort() { fun pIntToUShort() {
assertThat(KotlinConversions.pIntToUShort.converter.convert(0, mapper)).isEqualTo(0.toUShort()) assertThat(KotlinConversions.pIntToUShort.converter.convert(0L, mapper)).isEqualTo(0.toUShort())
assertThat(KotlinConversions.pIntToUShort.converter.convert(UShort.MAX_VALUE.toLong(), mapper)) assertThat(KotlinConversions.pIntToUShort.converter.convert(UShort.MAX_VALUE.toLong(), mapper))
.isEqualTo(UShort.MAX_VALUE) .isEqualTo(UShort.MAX_VALUE)
@@ -78,7 +80,7 @@ class KotlinConversionsTest {
} }
assertThrows<ConversionException> { assertThrows<ConversionException> {
KotlinConversions.pIntToUShort.converter.convert(-1, mapper) KotlinConversions.pIntToUShort.converter.convert(-1L, mapper)
} }
} }
} }
+21 -16
View File
@@ -7,7 +7,6 @@ com.tunnelvisionlabs:antlr4-annotations:4.9.0=antlr
com.tunnelvisionlabs:antlr4-runtime:4.9.0=antlr,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=antlr,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.tunnelvisionlabs:antlr4:4.9.0=antlr com.tunnelvisionlabs:antlr4:4.9.0=antlr
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.abego.treelayout:org.abego.treelayout.core:1.0.1=antlr org.abego.treelayout:org.abego.treelayout.core:1.0.1=antlr
org.antlr:ST4:4.3=antlr org.antlr:ST4:4.3=antlr
org.antlr:antlr-runtime:3.5.2=antlr org.antlr:antlr-runtime:3.5.2=antlr
@@ -16,21 +15,27 @@ org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenc
org.graalvm.sdk:graal-sdk:23.0.6=compileClasspath,generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=compileClasspath,generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=compileClasspath,generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=compileClasspath,generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.truffle:truffle-dsl-processor:23.0.6=annotationProcessor org.graalvm.truffle:truffle-dsl-processor:23.0.6=annotationProcessor
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=generatorCompileClasspath,generatorImplementationDependenciesMetadata,generatorRuntimeClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=generatorCompileClasspath,generatorRuntimeClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathGenerator,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -17,10 +17,10 @@ package org.pkl.core
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.test.PackageServer import org.pkl.commons.test.PackageServer
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.http.HttpClient import org.pkl.core.http.HttpClient
@@ -36,7 +36,7 @@ class AnalyzerTest {
listOf(ModuleKeyFactories.file, ModuleKeyFactories.standardLibrary, ModuleKeyFactories.pkg), listOf(ModuleKeyFactories.file, ModuleKeyFactories.standardLibrary, ModuleKeyFactories.pkg),
null, null,
null, null,
HttpClient.dummyClient() HttpClient.dummyClient(),
) )
@Test @Test
@@ -62,8 +62,8 @@ class AnalyzerTest {
setOf( setOf(
ImportGraph.Import(URI("pkl:base")), ImportGraph.Import(URI("pkl:base")),
ImportGraph.Import(URI("pkl:json")), ImportGraph.Import(URI("pkl:json")),
ImportGraph.Import(URI("pkl:xml")) ImportGraph.Import(URI("pkl:xml")),
) ),
) )
} }
@@ -88,8 +88,8 @@ class AnalyzerTest {
file1 to file1 to
setOf(ImportGraph.Import(file1), ImportGraph.Import(file2), ImportGraph.Import(file3)), setOf(ImportGraph.Import(file1), ImportGraph.Import(file2), ImportGraph.Import(file3)),
file2 to emptySet(), file2 to emptySet(),
file3 to emptySet() file3 to emptySet(),
), )
) )
} }
@@ -129,7 +129,7 @@ class AnalyzerTest {
file1 to setOf(ImportGraph.Import(URI("package://localhost:0/birds@0.5.0#/Bird.pkl"))), file1 to setOf(ImportGraph.Import(URI("package://localhost:0/birds@0.5.0#/Bird.pkl"))),
URI("package://localhost:0/birds@0.5.0#/Bird.pkl") to URI("package://localhost:0/birds@0.5.0#/Bird.pkl") to
setOf(ImportGraph.Import(URI("package://localhost:0/fruit@1.0.5#/Fruit.pkl"))), setOf(ImportGraph.Import(URI("package://localhost:0/fruit@1.0.5#/Fruit.pkl"))),
URI("package://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet() URI("package://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet(),
) )
) )
} }
@@ -185,11 +185,11 @@ class AnalyzerTest {
ModuleKeyFactories.file, ModuleKeyFactories.file,
ModuleKeyFactories.standardLibrary, ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg, ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage ModuleKeyFactories.projectpackage,
), ),
tempDir.resolve("packages"), tempDir.resolve("packages"),
project.dependencies, project.dependencies,
HttpClient.dummyClient() HttpClient.dummyClient(),
) )
val file1 = val file1 =
tempDir tempDir
@@ -209,7 +209,7 @@ class AnalyzerTest {
setOf(ImportGraph.Import(URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl"))), setOf(ImportGraph.Import(URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl"))),
URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl") to URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl") to
setOf(ImportGraph.Import(URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl"))), setOf(ImportGraph.Import(URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl"))),
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet() URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet(),
) )
) )
assertThat(result.resolvedImports) assertThat(result.resolvedImports)
@@ -219,7 +219,7 @@ class AnalyzerTest {
URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl") to URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl") to
URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl"), URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl"),
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") to URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") to
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl"),
) )
) )
} }
@@ -297,23 +297,23 @@ class AnalyzerTest {
ModuleKeyFactories.file, ModuleKeyFactories.file,
ModuleKeyFactories.standardLibrary, ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg, ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage ModuleKeyFactories.projectpackage,
), ),
tempDir.resolve("packages"), tempDir.resolve("packages"),
project.dependencies, project.dependencies,
HttpClient.dummyClient() HttpClient.dummyClient(),
) )
val result = analyzer.importGraph(mainPkl.toUri()) val result = analyzer.importGraph(mainPkl.toUri())
val birdUri = URI("projectpackage://localhost:0/birds@1.0.0#/bird.pkl") val birdUri = URI("projectpackage://localhost:0/birds@1.0.0#/bird.pkl")
assertThat(result.imports) assertThat(result.imports)
.isEqualTo( .isEqualTo(
mapOf(mainPkl.toUri() to setOf(ImportGraph.Import(birdUri)), birdUri to emptySet()), mapOf(mainPkl.toUri() to setOf(ImportGraph.Import(birdUri)), birdUri to emptySet())
) )
assertThat(result.resolvedImports) assertThat(result.resolvedImports)
.isEqualTo( .isEqualTo(
mapOf( mapOf(
mainPkl.toUri() to mainPkl.toRealPath().toUri(), mainPkl.toUri() to mainPkl.toRealPath().toUri(),
birdUri to birdModule.toRealPath().toUri() birdUri to birdModule.toRealPath().toUri(),
) )
) )
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -120,6 +120,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofNanos(999999999999)) .isEqualTo(java.time.Duration.ofNanos(999999999999))
assertThat(Duration(999999999999999.0, NANOS).toJavaDuration()) assertThat(Duration(999999999999999.0, NANOS).toJavaDuration())
.isEqualTo(java.time.Duration.ofNanos(999999999999999)) .isEqualTo(java.time.Duration.ofNanos(999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(9999999999999999.0, NANOS).toJavaDuration()) assertThat(Duration(9999999999999999.0, NANOS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofNanos(9999999999999999)) .isNotEqualTo(java.time.Duration.ofNanos(9999999999999999))
@@ -133,6 +134,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofSeconds(999999999999)) .isEqualTo(java.time.Duration.ofSeconds(999999999999))
assertThat(Duration(999999999999999.0, SECONDS).toJavaDuration()) assertThat(Duration(999999999999999.0, SECONDS).toJavaDuration())
.isEqualTo(java.time.Duration.ofSeconds(999999999999999)) .isEqualTo(java.time.Duration.ofSeconds(999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(9999999999999999.0, SECONDS).toJavaDuration()) assertThat(Duration(9999999999999999.0, SECONDS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofSeconds(9999999999999999)) .isNotEqualTo(java.time.Duration.ofSeconds(9999999999999999))
@@ -146,6 +148,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofMinutes(999999999999)) .isEqualTo(java.time.Duration.ofMinutes(999999999999))
assertThat(Duration(999999999999999.0, MINUTES).toJavaDuration()) assertThat(Duration(999999999999999.0, MINUTES).toJavaDuration())
.isEqualTo(java.time.Duration.ofMinutes(999999999999999)) .isEqualTo(java.time.Duration.ofMinutes(999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(9999999999999999.0, MINUTES).toJavaDuration()) assertThat(Duration(9999999999999999.0, MINUTES).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofMinutes(9999999999999999)) .isNotEqualTo(java.time.Duration.ofMinutes(9999999999999999))
@@ -158,7 +161,10 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofHours(999999999999)) .isEqualTo(java.time.Duration.ofHours(999999999999))
assertThat(Duration(999999999999999.0, HOURS).toJavaDuration()) assertThat(Duration(999999999999999.0, HOURS).toJavaDuration())
.isEqualTo(java.time.Duration.ofHours(999999999999999)) .isEqualTo(java.time.Duration.ofHours(999999999999999))
assertThrows<ArithmeticException> { Duration(9999999999999999.0, HOURS).toJavaDuration() } assertThrows<ArithmeticException> {
@Suppress("FloatingPointLiteralPrecision")
Duration(9999999999999999.0, HOURS).toJavaDuration()
}
assertThat(Duration(999.0, DAYS).toJavaDuration()).isEqualTo(java.time.Duration.ofDays(999)) assertThat(Duration(999.0, DAYS).toJavaDuration()).isEqualTo(java.time.Duration.ofDays(999))
assertThat(Duration(999999.0, DAYS).toJavaDuration()) assertThat(Duration(999999.0, DAYS).toJavaDuration())
@@ -181,6 +187,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofNanos(-999999999999)) .isEqualTo(java.time.Duration.ofNanos(-999999999999))
assertThat(Duration(-999999999999999.0, NANOS).toJavaDuration()) assertThat(Duration(-999999999999999.0, NANOS).toJavaDuration())
.isEqualTo(java.time.Duration.ofNanos(-999999999999999)) .isEqualTo(java.time.Duration.ofNanos(-999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(-9999999999999999.0, NANOS).toJavaDuration()) assertThat(Duration(-9999999999999999.0, NANOS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofNanos(-9999999999999999)) .isNotEqualTo(java.time.Duration.ofNanos(-9999999999999999))
@@ -194,6 +201,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofSeconds(-999999999999)) .isEqualTo(java.time.Duration.ofSeconds(-999999999999))
assertThat(Duration(-999999999999999.0, SECONDS).toJavaDuration()) assertThat(Duration(-999999999999999.0, SECONDS).toJavaDuration())
.isEqualTo(java.time.Duration.ofSeconds(-999999999999999)) .isEqualTo(java.time.Duration.ofSeconds(-999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(-9999999999999999.0, SECONDS).toJavaDuration()) assertThat(Duration(-9999999999999999.0, SECONDS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofSeconds(-9999999999999999)) .isNotEqualTo(java.time.Duration.ofSeconds(-9999999999999999))
@@ -207,6 +215,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofMinutes(-999999999999)) .isEqualTo(java.time.Duration.ofMinutes(-999999999999))
assertThat(Duration(-999999999999999.0, MINUTES).toJavaDuration()) assertThat(Duration(-999999999999999.0, MINUTES).toJavaDuration())
.isEqualTo(java.time.Duration.ofMinutes(-999999999999999)) .isEqualTo(java.time.Duration.ofMinutes(-999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(-9999999999999999.0, MINUTES).toJavaDuration()) assertThat(Duration(-9999999999999999.0, MINUTES).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofMinutes(-9999999999999999)) .isNotEqualTo(java.time.Duration.ofMinutes(-9999999999999999))
@@ -219,7 +228,10 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofHours(-999999999999)) .isEqualTo(java.time.Duration.ofHours(-999999999999))
assertThat(Duration(-999999999999999.0, HOURS).toJavaDuration()) assertThat(Duration(-999999999999999.0, HOURS).toJavaDuration())
.isEqualTo(java.time.Duration.ofHours(-999999999999999)) .isEqualTo(java.time.Duration.ofHours(-999999999999999))
assertThrows<ArithmeticException> { Duration(-9999999999999999.0, HOURS).toJavaDuration() } assertThrows<ArithmeticException> {
@Suppress("FloatingPointLiteralPrecision")
Duration(-9999999999999999.0, HOURS).toJavaDuration()
}
assertThat(Duration(-999.0, DAYS).toJavaDuration()).isEqualTo(java.time.Duration.ofDays(-999)) assertThat(Duration(-999.0, DAYS).toJavaDuration()).isEqualTo(java.time.Duration.ofDays(-999))
assertThat(Duration(-999999.0, DAYS).toJavaDuration()) assertThat(Duration(-999999.0, DAYS).toJavaDuration())
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.assertThrows
class EvaluateExpressionTest { class EvaluateExpressionTest {
companion object { companion object {
val evaluator by lazy { Evaluator.preconfigured() } private val evaluator by lazy { Evaluator.preconfigured() }
@AfterAll @AfterAll
@JvmStatic @JvmStatic
@@ -64,7 +64,7 @@ class EvaluateExpressionTest {
} }
""" """
.trimIndent(), .trimIndent(),
"foo.bar" "foo.bar",
) )
assertThat(resp).isEqualTo(2L) assertThat(resp).isEqualTo(2L)
@@ -84,7 +84,7 @@ class EvaluateExpressionTest {
} }
""" """
.trimIndent(), .trimIndent(),
"output.text" "output.text",
) )
assertThat(result) assertThat(result)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
import kotlin.io.path.createParentDirectories
import kotlin.io.path.writeText import kotlin.io.path.writeText
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatCode import org.assertj.core.api.Assertions.assertThatCode
@@ -30,7 +31,6 @@ import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.createTempFile import org.pkl.commons.createTempFile
import org.pkl.commons.test.PackageServer import org.pkl.commons.test.PackageServer
import org.pkl.commons.toPath import org.pkl.commons.toPath
@@ -47,7 +47,7 @@ class EvaluatorTest {
companion object { companion object {
private val evaluator = Evaluator.preconfigured() private val evaluator = Evaluator.preconfigured()
private const val sourceText = "name = \"pigeon\"; age = 10 + 20" @Suppress("ConstPropertyName") private const val sourceText = "name = \"pigeon\"; age = 10 + 20"
private object CustomModuleKeyFactory : ModuleKeyFactory { private object CustomModuleKeyFactory : ModuleKeyFactory {
override fun create(uri: URI): Optional<ModuleKey> { override fun create(uri: URI): Optional<ModuleKey> {
@@ -275,7 +275,7 @@ class EvaluatorTest {
SecurityManagers.defaultAllowedModules, SecurityManagers.defaultAllowedModules,
SecurityManagers.defaultAllowedResources, SecurityManagers.defaultAllowedResources,
SecurityManagers.defaultTrustLevels, SecurityManagers.defaultTrustLevels,
tempDir tempDir,
) )
) )
.build() .build()
@@ -315,7 +315,7 @@ class EvaluatorTest {
} }
""" """
.trimIndent() .trimIndent()
val output = evaluator.evaluateOutputFiles(ModuleSource.text(program)) val output = evaluator.evaluateOutputFiles(text(program))
assertThat(output.keys).isEqualTo(setOf("foo.yml", "bar.yml", "bar/biz.yml", "bar/../bark.yml")) assertThat(output.keys).isEqualTo(setOf("foo.yml", "bar.yml", "bar/biz.yml", "bar/../bark.yml"))
assertThat(output["foo.yml"]?.text).isEqualTo("foo: foo text") assertThat(output["foo.yml"]?.text).isEqualTo("foo: foo text")
assertThat(output["bar.yml"]?.text).isEqualTo("bar: bar text") assertThat(output["bar.yml"]?.text).isEqualTo("bar: bar text")
@@ -361,7 +361,7 @@ class EvaluatorTest {
ModuleKeyFactories.standardLibrary, ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg, ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage, ModuleKeyFactories.projectpackage,
ModuleKeyFactories.file ModuleKeyFactories.file,
) )
) )
} }
@@ -430,7 +430,7 @@ class EvaluatorTest {
ModuleKeyFactories.standardLibrary, ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg, ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage, ModuleKeyFactories.projectpackage,
ModuleKeyFactories.file ModuleKeyFactories.file,
) )
) )
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -94,17 +94,17 @@ abstract class AbstractLanguageSnippetTestsEngine : InputOutputTestEngine() {
protected fun String.stripFilePaths(): String = protected fun String.stripFilePaths(): String =
replace(IoUtils.toNormalizedPathString(snippetsDir), replacement) replace(IoUtils.toNormalizedPathString(snippetsDir), replacement)
protected fun String.stripLineNumbers() = protected fun String.stripLineNumbers(): String =
replace(lineNumberRegex) { result -> replace(lineNumberRegex) { result ->
// replace line number with equivalent number of 'x' characters to keep formatting intact // replace line number with equivalent number of 'x' characters to keep formatting intact
(result.groups[1]!!.value) + "x".repeat(result.groups[3]!!.value.length) + " |" (result.groups[1]!!.value) + "x".repeat(result.groups[3]!!.value.length) + " |"
} }
protected fun String.stripWebsite() = protected fun String.stripWebsite(): String =
replace(Release.current().documentation().homepage(), "https://\$pklWebsite/") replace(Release.current().documentation().homepage(), "https://\$pklWebsite/")
// can't think of a better solution right now // can't think of a better solution right now
protected fun String.stripVersionCheckErrorMessage() = protected fun String.stripVersionCheckErrorMessage(): String =
replace("Pkl version is ${Release.current().version()}", "Pkl version is xxx") replace("Pkl version is ${Release.current().version()}", "Pkl version is xxx")
protected fun String.stripStdlibLocationSha(): String { protected fun String.stripStdlibLocationSha(): String {
@@ -114,7 +114,7 @@ abstract class AbstractLanguageSnippetTestsEngine : InputOutputTestEngine() {
else Release.current().commitId() else Release.current().commitId()
return replace( return replace(
"https://github.com/apple/pkl/blob/${commitIsh}/stdlib/", "https://github.com/apple/pkl/blob/${commitIsh}/stdlib/",
"https://github.com/apple/pkl/blob/\$commitId/stdlib/" "https://github.com/apple/pkl/blob/\$commitId/stdlib/",
) )
} }
@@ -135,7 +135,7 @@ class LanguageSnippetTestsEngine : AbstractLanguageSnippetTestsEngine() {
"NAME2" to "value2", "NAME2" to "value2",
"/foo/bar" to "foobar", "/foo/bar" to "foobar",
"foo bar" to "foo bar", "foo bar" to "foo bar",
"file:///foo/bar" to "file:///foo/bar" "file:///foo/bar" to "file:///foo/bar",
) )
) )
.setExternalProperties( .setExternalProperties(
@@ -169,7 +169,7 @@ class LanguageSnippetTestsEngine : AbstractLanguageSnippetTestsEngine() {
SecurityManagers.defaultManager, SecurityManagers.defaultManager,
null, null,
StackFrameTransformers.empty, StackFrameTransformers.empty,
mapOf() mapOf(),
) )
securityManager = null securityManager = null
applyFromProject(project) applyFromProject(project)
@@ -200,13 +200,13 @@ abstract class AbstractNativeLanguageSnippetTestsEngine : AbstractLanguageSnippe
// on the other hand, don't exclude /native/ // on the other hand, don't exclude /native/
Regex(".*/import1b\\.pkl"), Regex(".*/import1b\\.pkl"),
// URIs get rendered slightly differently (percent-encoded vs raw) // URIs get rendered slightly differently (percent-encoded vs raw)
Regex(".*日本語_error\\.pkl") Regex(".*日本語_error\\.pkl"),
) )
/** Avoid running tests for native binaries when those native binaries have not been built. */ /** Avoid running tests for native binaries when those native binaries have not been built. */
override fun discover( override fun discover(
discoveryRequest: EngineDiscoveryRequest, discoveryRequest: EngineDiscoveryRequest,
uniqueId: UniqueId uniqueId: UniqueId,
): TestDescriptor { ): TestDescriptor {
if (!pklExecutablePath.exists()) { if (!pklExecutablePath.exists()) {
// return empty descriptor w/o children // return empty descriptor w/o children
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@ class TestExternalReaderProcess(private val transport: MessageTransport) : Exter
companion object { companion object {
fun initializeTestHarness( fun initializeTestHarness(
moduleReaders: List<ExternalModuleReader>, moduleReaders: List<ExternalModuleReader>,
resourceReaders: List<ExternalResourceReader> resourceReaders: List<ExternalResourceReader>,
): Pair<TestExternalReaderProcess, ExternalReaderRuntime> { ): Pair<TestExternalReaderProcess, ExternalReaderRuntime> {
val rxIn = PipedInputStream(10240) val rxIn = PipedInputStream(10240)
val rxOut = PipedOutputStream(rxIn) val rxOut = PipedOutputStream(rxIn)
@@ -108,14 +108,12 @@ class TestExternalReaderProcess(private val transport: MessageTransport) : Exter
MessageTransports.stream( MessageTransports.stream(
ExternalReaderMessagePackDecoder(rxIn), ExternalReaderMessagePackDecoder(rxIn),
ExternalReaderMessagePackEncoder(txOut), ExternalReaderMessagePackEncoder(txOut),
{} ) {}
)
val clientTransport = val clientTransport =
MessageTransports.stream( MessageTransports.stream(
ExternalReaderMessagePackDecoder(txIn), ExternalReaderMessagePackDecoder(txIn),
ExternalReaderMessagePackEncoder(rxOut), ExternalReaderMessagePackEncoder(rxOut),
{} ) {}
)
val runtime = ExternalReaderRuntime(moduleReaders, resourceReaders, clientTransport) val runtime = ExternalReaderRuntime(moduleReaders, resourceReaders, clientTransport)
val proc = TestExternalReaderProcess(serverTransport) val proc = TestExternalReaderProcess(serverTransport)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,11 +18,11 @@ package org.pkl.core.module
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createDirectories import kotlin.io.path.createDirectories
import kotlin.io.path.createParentDirectories
import kotlin.io.path.outputStream import kotlin.io.path.outputStream
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.toPath import org.pkl.commons.toPath
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.SecurityManagers import org.pkl.core.SecurityManagers
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -21,11 +21,11 @@ import java.net.URI
import java.net.URISyntaxException import java.net.URISyntaxException
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createFile import kotlin.io.path.createFile
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.toPath import org.pkl.commons.toPath
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.SecurityManagers import org.pkl.core.SecurityManagers
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ package org.pkl.core.packages
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.io.IOException import java.io.IOException
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.deleteRecursively
import kotlin.io.path.exists import kotlin.io.path.exists
import kotlin.io.path.readBytes import kotlin.io.path.readBytes
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
@@ -25,7 +27,6 @@ import org.assertj.core.api.Assertions.assertThatCode
import org.junit.jupiter.api.* import org.junit.jupiter.api.*
import org.junit.jupiter.api.parallel.Execution import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode import org.junit.jupiter.api.parallel.ExecutionMode
import org.pkl.commons.deleteRecursively
import org.pkl.commons.readString import org.pkl.commons.readString
import org.pkl.commons.test.FileTestUtils import org.pkl.commons.test.FileTestUtils
import org.pkl.commons.test.PackageServer import org.pkl.commons.test.PackageServer
@@ -118,7 +119,7 @@ class PackageResolversTest {
PathElement("catalog", true), PathElement("catalog", true),
PathElement("Bird.pkl", false), PathElement("Bird.pkl", false),
PathElement("allFruit.pkl", false), PathElement("allFruit.pkl", false),
PathElement("catalog.pkl", false) PathElement("catalog.pkl", false),
) )
) )
} }
@@ -129,13 +130,13 @@ class PackageResolversTest {
resolver.getBytes( resolver.getBytes(
PackageAssetUri("package://localhost:0/birds@0.5.0#/Bird.pkl"), PackageAssetUri("package://localhost:0/birds@0.5.0#/Bird.pkl"),
false, false,
null null,
) )
val swallow = val swallow =
resolver.getBytes( resolver.getBytes(
PackageAssetUri("package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"), PackageAssetUri("package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"),
false, false,
null null,
) )
assertThat(bird).isEqualTo(packageRoot.resolve("birds@0.5.0/package/Bird.pkl").readBytes()) assertThat(bird).isEqualTo(packageRoot.resolve("birds@0.5.0/package/Bird.pkl").readBytes())
assertThat(swallow) assertThat(swallow)
@@ -150,12 +151,7 @@ class PackageResolversTest {
.listElements(PackageAssetUri("package://localhost:0/birds@0.5.0#/catalog/"), null) .listElements(PackageAssetUri("package://localhost:0/birds@0.5.0#/catalog/"), null)
.toSet() .toSet()
assertThat(elements) assertThat(elements)
.isEqualTo( .isEqualTo(setOf(PathElement("Ostrich.pkl", false), PathElement("Swallow.pkl", false)))
setOf(
PathElement("Ostrich.pkl", false),
PathElement("Swallow.pkl", false),
)
)
} }
@Test @Test
@@ -174,7 +170,7 @@ class PackageResolversTest {
.getBytes( .getBytes(
PackageAssetUri("package://localhost:0/not-a-package@0.5.0#/Horse.pkl"), PackageAssetUri("package://localhost:0/not-a-package@0.5.0#/Horse.pkl"),
false, false,
null null,
) )
.toString(StandardCharsets.UTF_8) .toString(StandardCharsets.UTF_8)
} }
@@ -186,7 +182,7 @@ class PackageResolversTest {
resolver.getBytes( resolver.getBytes(
PackageAssetUri("package://localhost:0/badPackageZipUrl@1.0.0#/Bug.pkl"), PackageAssetUri("package://localhost:0/badPackageZipUrl@1.0.0#/Bug.pkl"),
false, false,
null null,
) )
} }
.hasMessage( .hasMessage(
@@ -201,7 +197,7 @@ class PackageResolversTest {
resolver.getBytes( resolver.getBytes(
PackageAssetUri("package://localhost:0/badChecksum@1.0.0#/Bug.pkl"), PackageAssetUri("package://localhost:0/badChecksum@1.0.0#/Bug.pkl"),
false, false,
null null,
) )
} }
assertThat(error) assertThat(error)
@@ -215,6 +211,7 @@ class PackageResolversTest {
} }
} }
@ExperimentalPathApi
class DiskCachedPackageResolverTest : AbstractPackageResolverTest() { class DiskCachedPackageResolverTest : AbstractPackageResolverTest() {
private val cacheDir = FileTestUtils.rootProjectDir.resolve("pkl-core/build/test-cache") private val cacheDir = FileTestUtils.rootProjectDir.resolve("pkl-core/build/test-cache")
@@ -233,7 +230,7 @@ class PackageResolversTest {
PackageResolvers.DiskCachedPackageResolver( PackageResolvers.DiskCachedPackageResolver(
SecurityManagers.defaultManager, SecurityManagers.defaultManager,
httpClient, httpClient,
cacheDir cacheDir,
) )
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -17,11 +17,11 @@ package org.pkl.core.settings
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatCode import org.assertj.core.api.Assertions.assertThatCode
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.Evaluator import org.pkl.core.Evaluator
import org.pkl.core.ModuleSource import org.pkl.core.ModuleSource
@@ -71,7 +71,7 @@ class PklSettingsTest {
PklEvaluatorSettings.Http( PklEvaluatorSettings.Http(
PklEvaluatorSettings.Proxy( PklEvaluatorSettings.Proxy(
URI("http://localhost:8080"), URI("http://localhost:8080"),
listOf("example.com", "pkg.pkl-lang.org") listOf("example.com", "pkg.pkl-lang.org"),
) )
) )
assertThat(settings).isEqualTo(PklSettings(Editor.SYSTEM, expectedHttp)) assertThat(settings).isEqualTo(PklSettings(Editor.SYSTEM, expectedHttp))
@@ -95,12 +95,7 @@ class PklSettingsTest {
val settings = PklSettings.loadFromPklHomeDir(tempDir) val settings = PklSettings.loadFromPklHomeDir(tempDir)
val expectedHttp = val expectedHttp =
PklEvaluatorSettings.Http( PklEvaluatorSettings.Http(PklEvaluatorSettings.Proxy(URI("http://localhost:8080"), listOf()))
PklEvaluatorSettings.Proxy(
URI("http://localhost:8080"),
listOf(),
)
)
assertThat(settings).isEqualTo(PklSettings(Editor.SYSTEM, expectedHttp)) assertThat(settings).isEqualTo(PklSettings(Editor.SYSTEM, expectedHttp))
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,12 +20,12 @@ import java.net.URI
import java.net.URISyntaxException import java.net.URISyntaxException
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createFile import kotlin.io.path.createFile
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatExceptionOfType import org.assertj.core.api.Assertions.assertThatExceptionOfType
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.toPath import org.pkl.commons.toPath
import org.pkl.core.SecurityManager import org.pkl.core.SecurityManager
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
@@ -49,7 +49,7 @@ class IoUtilsTest {
ModuleKeyFactories.pkg, ModuleKeyFactories.pkg,
ModuleKeyFactories.file, ModuleKeyFactories.file,
ModuleKeyFactories.standardLibrary, ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.genericUrl ModuleKeyFactories.genericUrl,
) )
) )
@@ -174,7 +174,7 @@ class IoUtilsTest {
assertThat( assertThat(
IoUtils.relativize( IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl?query"), URI("https://foo.com/bar/baz.pkl?query"),
URI("https://foo.com/bar/qux.pkl") URI("https://foo.com/bar/qux.pkl"),
) )
) )
.isEqualTo(URI("baz.pkl?query")) .isEqualTo(URI("baz.pkl?query"))
@@ -182,7 +182,7 @@ class IoUtilsTest {
assertThat( assertThat(
IoUtils.relativize( IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl#fragment"), URI("https://foo.com/bar/baz.pkl#fragment"),
URI("https://foo.com/bar/qux.pkl") URI("https://foo.com/bar/qux.pkl"),
) )
) )
.isEqualTo(URI("baz.pkl#fragment")) .isEqualTo(URI("baz.pkl#fragment"))
@@ -190,7 +190,7 @@ class IoUtilsTest {
assertThat( assertThat(
IoUtils.relativize( IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl?query#fragment"), URI("https://foo.com/bar/baz.pkl?query#fragment"),
URI("https://foo.com/bar/qux.pkl") URI("https://foo.com/bar/qux.pkl"),
) )
) )
.isEqualTo(URI("baz.pkl?query#fragment")) .isEqualTo(URI("baz.pkl?query#fragment"))
@@ -198,7 +198,7 @@ class IoUtilsTest {
assertThat( assertThat(
IoUtils.relativize( IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl?query#fragment"), URI("https://foo.com/bar/baz.pkl?query#fragment"),
URI("https://foo.com/bar/qux.pkl?query2#fragment2") URI("https://foo.com/bar/qux.pkl?query2#fragment2"),
) )
) )
.isEqualTo(URI("baz.pkl?query#fragment")) .isEqualTo(URI("baz.pkl?query#fragment"))
@@ -211,7 +211,7 @@ class IoUtilsTest {
assertThat( assertThat(
IoUtils.relativize( IoUtils.relativize(
URI("https://foo.com:80/bar/baz.pkl"), URI("https://foo.com:80/bar/baz.pkl"),
URI("https://bar.com:80/bar/baz.pkl") URI("https://bar.com:80/bar/baz.pkl"),
) )
) )
.isEqualTo(URI("https://foo.com:80/bar/baz.pkl")) .isEqualTo(URI("https://foo.com:80/bar/baz.pkl"))
@@ -219,7 +219,7 @@ class IoUtilsTest {
assertThat( assertThat(
IoUtils.relativize( IoUtils.relativize(
URI("https://foo:bar@foo.com:80/bar/baz.pkl"), URI("https://foo:bar@foo.com:80/bar/baz.pkl"),
URI("https://foo:baz@bar.com:80/bar/baz.pkl") URI("https://foo:baz@bar.com:80/bar/baz.pkl"),
) )
) )
.isEqualTo(URI("https://foo:bar@foo.com:80/bar/baz.pkl")) .isEqualTo(URI("https://foo:bar@foo.com:80/bar/baz.pkl"))
@@ -282,7 +282,7 @@ class IoUtilsTest {
"modulepath:/foo.pkl" to "foo", "modulepath:/foo.pkl" to "foo",
"modulepath:/foo/bar/baz.pkl" to "baz", "modulepath:/foo/bar/baz.pkl" to "baz",
"package://example.com/foo/bar@1.0.0#/baz.pkl" to "baz", "package://example.com/foo/bar@1.0.0#/baz.pkl" to "baz",
"package://example.com/foo/bar@1.0.0#/baz/biz/qux.pkl" to "qux" "package://example.com/foo/bar@1.0.0#/baz/biz/qux.pkl" to "qux",
) )
for ((uriStr, name) in assertions) { for ((uriStr, name) in assertions) {
val uri = URI(uriStr) val uri = URI(uriStr)
@@ -356,7 +356,7 @@ class IoUtilsTest {
IoUtils.resolve( IoUtils.resolve(
FakeSecurityManager, FakeSecurityManager,
key, key,
URI(".../core/module/NamedModuleResolversTest.pkl") URI(".../core/module/NamedModuleResolversTest.pkl"),
) )
) )
.isEqualTo(URI("modulepath:/org/pkl/core/module/NamedModuleResolversTest.pkl")) .isEqualTo(URI("modulepath:/org/pkl/core/module/NamedModuleResolversTest.pkl"))
@@ -365,7 +365,7 @@ class IoUtilsTest {
IoUtils.resolve( IoUtils.resolve(
FakeSecurityManager, FakeSecurityManager,
key, key,
URI(".../org/pkl/core/module/NamedModuleResolversTest.pkl") URI(".../org/pkl/core/module/NamedModuleResolversTest.pkl"),
) )
) )
.isEqualTo(URI("modulepath:/org/pkl/core/module/NamedModuleResolversTest.pkl")) .isEqualTo(URI("modulepath:/org/pkl/core/module/NamedModuleResolversTest.pkl"))
+29 -28
View File
@@ -19,7 +19,6 @@ commons-io:commons-io:2.4=validator
commons-logging:commons-logging:1.2=validator commons-logging:commons-logging:1.2=validator
isorelax:isorelax:20030108=validator isorelax:isorelax:20030108=validator
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
net.sf.saxon:Saxon-HE:9.6.0-4=validator net.sf.saxon:Saxon-HE:9.6.0-4=validator
nu.validator:cssvalidator:1.0.8=validator nu.validator:cssvalidator:1.0.8=validator
nu.validator:galimatias:0.1.3=validator nu.validator:galimatias:0.1.3=validator
@@ -42,33 +41,35 @@ org.graalvm.js:js:23.0.6=testCompileClasspath,testImplementationDependenciesMeta
org.graalvm.regex:regex:23.0.6=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.graalvm.regex:regex:23.0.6=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-native-utils:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-project-model:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-serialization:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-serialization-compiler-plugin-embeddable:2.0.21=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-tooling-core:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-util-io:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.1=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-bom:1.5.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.5.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-html-jvm:0.11.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core:1.5.1=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-bom:1.8.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.5.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.8.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-core:1.8.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.8.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,11 +18,7 @@ package org.pkl.doc
import java.io.IOException import java.io.IOException
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createSymbolicLinkPointingTo import kotlin.io.path.*
import kotlin.io.path.deleteIfExists
import kotlin.io.path.exists
import kotlin.io.path.isSameFileAs
import org.pkl.commons.deleteRecursively
import org.pkl.core.ModuleSchema import org.pkl.core.ModuleSchema
import org.pkl.core.PClassInfo import org.pkl.core.PClassInfo
import org.pkl.core.Version import org.pkl.core.Version
@@ -33,6 +29,7 @@ import org.pkl.core.util.IoUtils
* *
* For the high-level Pkldoc API, see [CliDocGenerator]. * For the high-level Pkldoc API, see [CliDocGenerator].
*/ */
@OptIn(ExperimentalPathApi::class)
class DocGenerator( class DocGenerator(
/** /**
* The documentation website to generate. * The documentation website to generate.
@@ -62,7 +59,7 @@ class DocGenerator(
* Generates source URLs with fixed line numbers `#L123-L456` to avoid churn in expected output * Generates source URLs with fixed line numbers `#L123-L456` to avoid churn in expected output
* files (e.g., when stdlib line numbers change). * files (e.g., when stdlib line numbers change).
*/ */
private val isTestMode: Boolean = false private val isTestMode: Boolean = false,
) { ) {
companion object { companion object {
internal fun List<PackageData>.current( internal fun List<PackageData>.current(
@@ -147,7 +144,7 @@ internal class DocPackage(val docPackageInfo: DocPackageInfo, val modules: List<
val minPklVersion: Version? by lazy { docModules.mapNotNull { it.minPklVersion }.maxOrNull() } val minPklVersion: Version? by lazy { docModules.mapNotNull { it.minPklVersion }.maxOrNull() }
val deprecation: String? = docPackageInfo.annotations.deprecation @Suppress("unused") val deprecation: String? = docPackageInfo.annotations.deprecation
val isUnlisted: Boolean = docPackageInfo.annotations.isUnlisted val isUnlisted: Boolean = docPackageInfo.annotations.isUnlisted
@@ -181,7 +178,7 @@ internal class DocPackage(val docPackageInfo: DocPackageInfo, val modules: List<
docPackageInfo.version, docPackageInfo.version,
docPackageInfo.getModuleImportUri(mod.moduleName), docPackageInfo.getModuleImportUri(mod.moduleName),
docPackageInfo.getModuleSourceCode(mod.moduleName), docPackageInfo.getModuleSourceCode(mod.moduleName),
exampleModulesBySubject[mod.moduleName] ?: listOf() exampleModulesBySubject[mod.moduleName] ?: listOf(),
) )
} }
} }
@@ -193,7 +190,7 @@ internal class DocModule(
val version: String, val version: String,
val importUri: URI, val importUri: URI,
val sourceUrl: URI?, val sourceUrl: URI?,
val examples: List<ModuleSchema> val examples: List<ModuleSchema>,
) { ) {
val name: String val name: String
get() = schema.moduleName get() = schema.moduleName
@@ -212,7 +209,7 @@ internal class DocModule(
version?.let { Version.parse(it) } version?.let { Version.parse(it) }
} }
val deprecation: String? = schema.annotations.deprecation @Suppress("unused") val deprecation: String? = schema.annotations.deprecation
val isUnlisted: Boolean = schema.annotations.isUnlisted val isUnlisted: Boolean = schema.annotations.isUnlisted
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -101,14 +101,14 @@ data class DocPackageInfo(
version = dependency["version"] as String, version = dependency["version"] as String,
sourceCode = (dependency["sourceCode"] as String?)?.toUri(), sourceCode = (dependency["sourceCode"] as String?)?.toUri(),
sourceCodeUrlScheme = dependency["sourceCodeUrlScheme"] as String?, sourceCodeUrlScheme = dependency["sourceCodeUrlScheme"] as String?,
documentation = (dependency["documentation"] as String?)?.toUri() documentation = (dependency["documentation"] as String?)?.toUri(),
) )
}, },
overview = module["overview"] as String, overview = module["overview"] as String,
overviewImports = overviewImports =
(module["overviewImports"] as Map<String, String>).mapValues { it.value.toUri() }, (module["overviewImports"] as Map<String, String>).mapValues { it.value.toUri() },
annotations = module["annotations"] as List<PObject>, annotations = module["annotations"] as List<PObject>,
extraAttributes = module["extraAttributes"] as Map<String, String> extraAttributes = module["extraAttributes"] as Map<String, String>,
) )
} }
@@ -122,7 +122,7 @@ data class DocPackageInfo(
dependency.name, dependency.name,
dependency.uri, dependency.uri,
dependency.version, dependency.version,
getModulePath(moduleName, dependency.prefix) getModulePath(moduleName, dependency.prefix),
) )
} }
} }
@@ -138,7 +138,7 @@ data class DocPackageInfo(
version, version,
getModulePath(moduleName, moduleNamePrefix), getModulePath(moduleName, moduleNamePrefix),
type.simpleName, type.simpleName,
isTypeAlias = type is TypeAlias isTypeAlias = type is TypeAlias,
) )
} }
for (dependency in dependencies) { for (dependency in dependencies) {
@@ -149,7 +149,7 @@ data class DocPackageInfo(
dependency.version, dependency.version,
getModulePath(moduleName, dependency.prefix), getModulePath(moduleName, dependency.prefix),
type.simpleName, type.simpleName,
isTypeAlias = type is TypeAlias isTypeAlias = type is TypeAlias,
) )
} }
} }
@@ -212,6 +212,7 @@ data class DocPackageInfo(
} }
} }
@Suppress("unused")
internal fun getModuleSourceCode(moduleName: String): URI? = internal fun getModuleSourceCode(moduleName: String): URI? =
when { when {
!moduleName.startsWith(prefix) -> null !moduleName.startsWith(prefix) -> null
@@ -223,7 +224,7 @@ data class DocPackageInfo(
internal fun getModuleSourceCodeWithSourceLocation( internal fun getModuleSourceCodeWithSourceLocation(
moduleName: String, moduleName: String,
sourceLocation: SourceLocation sourceLocation: SourceLocation,
): URI? { ): URI? {
return when { return when {
!moduleName.startsWith(prefix) -> null !moduleName.startsWith(prefix) -> null
+5 -12
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -38,12 +38,12 @@ internal fun main(args: Array<String>) {
} }
class DocCommand : class DocCommand :
BaseCommand(name = "pkldoc", helpLink = Release.current().documentation().homepage(), help = "") { BaseCommand(name = "pkldoc", helpLink = Release.current().documentation().homepage()) {
private val modules: List<URI> by private val modules: List<URI> by
argument( argument(
name = "<modules>", name = "<modules>",
help = "Module paths/uris, or package uris to generate documentation for" help = "Module paths/uris, or package uris to generate documentation for",
) )
.convert { parseModuleName(it) } .convert { parseModuleName(it) }
.multiple(required = true) .multiple(required = true)
@@ -52,7 +52,7 @@ class DocCommand :
option( option(
names = arrayOf("-o", "--output-dir"), names = arrayOf("-o", "--output-dir"),
metavar = "<directory>", metavar = "<directory>",
help = "Directory where generated documentation is placed." help = "Directory where generated documentation is placed.",
) )
.path() .path()
.required() .required()
@@ -61,14 +61,7 @@ class DocCommand :
override fun run() { override fun run() {
val options = val options =
CliDocGeneratorOptions( CliDocGeneratorOptions(baseOptions.baseOptions(modules, projectOptions), outputDir, true)
baseOptions.baseOptions(
modules,
projectOptions,
),
outputDir,
true
)
CliDocGenerator(options).run() CliDocGenerator(options).run()
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import kotlinx.html.*
internal class MainPageGenerator( internal class MainPageGenerator(
docsiteInfo: DocsiteInfo, docsiteInfo: DocsiteInfo,
private val packagesData: List<PackageData>, private val packagesData: List<PackageData>,
pageScope: SiteScope pageScope: SiteScope,
) : MainOrPackagePageGenerator<SiteScope>(docsiteInfo, pageScope, pageScope) { ) : MainOrPackagePageGenerator<SiteScope>(docsiteInfo, pageScope, pageScope) {
override val html: HTML.() -> Unit = { override val html: HTML.() -> Unit = {
renderHtmlHead() renderHtmlHead()
@@ -41,7 +41,7 @@ internal class MainPageGenerator(
renderMemberGroupLinks( renderMemberGroupLinks(
Triple("Overview", "#_overview", memberDocs.isExpandable), Triple("Overview", "#_overview", memberDocs.isExpandable),
Triple("Packages", "#_packages", packagesData.isNotEmpty()) Triple("Packages", "#_packages", packagesData.isNotEmpty()),
) )
if (docsiteInfo.overview != null) { if (docsiteInfo.overview != null) {
@@ -90,12 +90,12 @@ internal class MainPageGenerator(
for (pkg in sortedPackages) { for (pkg in sortedPackages) {
val packageScope = val packageScope =
pageScope.packageScopes[pkg.ref.pkg] pageScope.packageScopes[pkg.ref.pkg]
// create scope for previously generated package // create scope for previously generated package
?: pageScope.createEmptyPackageScope( ?: pageScope.createEmptyPackageScope(
pkg.ref.pkg, pkg.ref.pkg,
pkg.ref.version, pkg.ref.version,
pkg.sourceCodeUrlScheme, pkg.sourceCodeUrlScheme,
pkg.sourceCode pkg.sourceCode,
) )
val memberDocs = val memberDocs =
@@ -103,7 +103,6 @@ internal class MainPageGenerator(
pkg.summary, pkg.summary,
packageScope, packageScope,
listOfNotNull(pkg.deprecation?.let { createDeprecatedAnnotation(it) }), listOfNotNull(pkg.deprecation?.let { createDeprecatedAnnotation(it) }),
isDeclaration = false
) )
renderModuleOrPackage(pkg.ref.pkg, packageScope, memberDocs) renderModuleOrPackage(pkg.ref.pkg, packageScope, memberDocs)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ internal class MarkdownParserFactory(private val pageScope: DocScope) : InlinePa
internal class MarkdownParserContext( internal class MarkdownParserContext(
private val docScope: DocScope, private val docScope: DocScope,
private val pageScope: DocScope, private val pageScope: DocScope,
private val delegate: InlineParserContext private val delegate: InlineParserContext,
) : InlineParserContext { ) : InlineParserContext {
companion object { companion object {
private val keywords = setOf("null", "true", "false", "this", "unknown", "nothing") private val keywords = setOf("null", "true", "false", "this", "unknown", "nothing")
@@ -54,7 +54,7 @@ internal class MarkdownParserContext(
} }
override fun <D : Any> getDefinition(type: Class<D>, label: String): D? { override fun <D : Any> getDefinition(type: Class<D>, label: String): D? {
@Suppress("UNCHECKED_CAST", "DEPRECATION") @Suppress("UNCHECKED_CAST")
return when (type) { return when (type) {
LinkReferenceDefinition::class.java -> getLinkReferenceDefinition(label) as D LinkReferenceDefinition::class.java -> getLinkReferenceDefinition(label) as D
else -> null else -> null
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,14 +22,14 @@ internal class ModulePageGenerator(
docPackage: DocPackage, docPackage: DocPackage,
docModule: DocModule, docModule: DocModule,
pageScope: ModuleScope, pageScope: ModuleScope,
isTestMode: Boolean isTestMode: Boolean,
) : ) :
ModuleOrClassPageGenerator<ModuleScope>( ModuleOrClassPageGenerator<ModuleScope>(
docsiteInfo, docsiteInfo,
docModule, docModule,
docModule.schema.moduleClass, docModule.schema.moduleClass,
pageScope, pageScope,
isTestMode isTestMode,
) { ) {
private val module = docModule.schema private val module = docModule.schema
@@ -61,7 +61,7 @@ internal class ModulePageGenerator(
pageScope, pageScope,
clazz.annotations, clazz.annotations,
isDeclaration = true, isDeclaration = true,
collectMemberInfo(docModule) collectMemberInfo(docModule),
) )
renderMemberGroupLinks( renderMemberGroupLinks(
@@ -69,7 +69,7 @@ internal class ModulePageGenerator(
Triple("Properties", "#_properties", clazz.hasListedProperty), Triple("Properties", "#_properties", clazz.hasListedProperty),
Triple("Methods", "#_methods", clazz.hasListedMethod), Triple("Methods", "#_methods", clazz.hasListedMethod),
Triple("Classes", "#_classes", module.hasListedClass), Triple("Classes", "#_classes", module.hasListedClass),
Triple("Type Aliases", "#_type-aliases", module.hasListedTypeAlias) Triple("Type Aliases", "#_type-aliases", module.hasListedTypeAlias),
) )
renderAnchor("_overview") renderAnchor("_overview")
@@ -234,13 +234,12 @@ internal class ModulePageGenerator(
"inherited", "inherited",
"expandable", "expandable",
"hidden", "hidden",
"collapsed" "collapsed",
) )
} else setOf("member", "with-page-link") } else setOf("member", "with-page-link")
val classScope = ClassScope(clazz, pageScope.url, pageScope) val classScope = ClassScope(clazz, pageScope.url, pageScope)
val memberDocs = val memberDocs = MemberDocs(clazz.docComment, classScope, clazz.annotations)
MemberDocs(clazz.docComment, classScope, clazz.annotations, isDeclaration = false)
memberDocs.renderExpandIcon(this) memberDocs.renderExpandIcon(this)
renderSelfLink(className) renderSelfLink(className)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,11 +18,10 @@ package org.pkl.doc
import java.io.IOException import java.io.IOException
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createParentDirectories
import kotlin.io.path.writer import kotlin.io.path.writer
import kotlin.streams.toList
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import org.pkl.commons.createParentDirectories
import org.pkl.commons.readString import org.pkl.commons.readString
import org.pkl.commons.toUri import org.pkl.commons.toUri
import org.pkl.commons.walk import org.pkl.commons.walk
@@ -88,7 +87,7 @@ internal data class PackageRef(
override val pkgUri: @Contextual URI?, override val pkgUri: @Contextual URI?,
/** The package version. */ /** The package version. */
override val version: String override val version: String,
) : ElementRef() { ) : ElementRef() {
override val pageUrl: URI by lazy { "$pkg/$version/index.html".toUri() } override val pageUrl: URI by lazy { "$pkg/$version/index.html".toUri() }
} }
@@ -106,7 +105,7 @@ internal data class ModuleRef(
override val version: String, override val version: String,
/** The module path. */ /** The module path. */
val module: String val module: String,
) : ElementRef() { ) : ElementRef() {
override val pageUrl: URI by lazy { "$pkg/$version/$module/index.html".toUri() } override val pageUrl: URI by lazy { "$pkg/$version/$module/index.html".toUri() }
@@ -138,7 +137,7 @@ internal data class TypeRef(
val type: String, val type: String,
/** Whether this is a type alias rather than a class. */ /** Whether this is a type alias rather than a class. */
val isTypeAlias: Boolean = false val isTypeAlias: Boolean = false,
) : ElementRef() { ) : ElementRef() {
val id: TypeId by lazy { TypeId(pkg, module, type) } val id: TypeId by lazy { TypeId(pkg, module, type) }
@@ -191,7 +190,7 @@ internal class PackageData(
val dependencies: List<DependencyData> = listOf(), val dependencies: List<DependencyData> = listOf(),
/** The modules in this package. */ /** The modules in this package. */
val modules: List<ModuleData> = listOf() val modules: List<ModuleData> = listOf(),
) { ) {
companion object { companion object {
val json = Json { serializersModule = serializers } val json = Json { serializersModule = serializers }
@@ -221,7 +220,7 @@ internal class PackageData(
pkg.docPackageInfo.sourceCode, pkg.docPackageInfo.sourceCode,
pkg.docPackageInfo.sourceCodeUrlScheme, pkg.docPackageInfo.sourceCodeUrlScheme,
pkg.docPackageInfo.dependencies.map { DependencyData(PackageRef(it.name, it.uri, it.version)) }, pkg.docPackageInfo.dependencies.map { DependencyData(PackageRef(it.name, it.uri, it.version)) },
pkg.docModules.mapNotNull { if (it.isUnlisted) null else ModuleData(pkg, it) } pkg.docModules.mapNotNull { if (it.isUnlisted) null else ModuleData(pkg, it) },
) )
fun write(path: Path) { fun write(path: Path) {
@@ -255,7 +254,7 @@ internal class ModuleData(
val ref: ModuleRef, val ref: ModuleRef,
/** The first paragraph of the overview documentation for this module. */ /** The first paragraph of the overview documentation for this module. */
val summary: String? = null, @Suppress("unused") val summary: String? = null,
/** The deprecation message, or `null` if this module isn't deprecated. */ /** The deprecation message, or `null` if this module isn't deprecated. */
val deprecation: String? = null, val deprecation: String? = null,
@@ -270,11 +269,11 @@ internal class ModuleData(
val classes: List<ClassData> = listOf(), val classes: List<ClassData> = listOf(),
/** The type aliases declared in this module. */ /** The type aliases declared in this module. */
val typeAliases: List<TypeAliasData> = listOf() @Suppress("unused") val typeAliases: List<TypeAliasData> = listOf(),
) { ) {
constructor( constructor(
pkg: DocPackage, pkg: DocPackage,
module: DocModule module: DocModule,
) : this( ) : this(
ModuleRef(pkg.name, pkg.uri, pkg.version, module.path), ModuleRef(pkg.name, pkg.uri, pkg.version, module.path),
getDocCommentSummary(module.overview), getDocCommentSummary(module.overview),
@@ -289,7 +288,7 @@ internal class ModuleData(
}, },
module.schema.typeAliases.mapNotNull { module.schema.typeAliases.mapNotNull {
if (it.value.isUnlisted) null else TypeAliasData(pkg, module, it.value) if (it.value.isUnlisted) null else TypeAliasData(pkg, module, it.value)
} },
) )
} }
@@ -321,14 +320,14 @@ internal class ClassData(
constructor( constructor(
pkg: DocPackage, pkg: DocPackage,
module: DocModule, module: DocModule,
clazz: PClass clazz: PClass,
) : this( ) : this(
TypeRef(pkg.name, pkg.uri, pkg.version, module.path, clazz.simpleName), TypeRef(pkg.name, pkg.uri, pkg.version, module.path, clazz.simpleName),
generateSequence(clazz.superclass) { it.superclass } generateSequence(clazz.superclass) { it.superclass }
.map { pkg.docPackageInfo.getTypeRef(it) } .map { pkg.docPackageInfo.getTypeRef(it) }
.filterNotNull() .filterNotNull()
.toList(), .toList(),
findTypesUsedBy(clazz, pkg.docPackageInfo).toList() findTypesUsedBy(clazz, pkg.docPackageInfo).toList(),
) )
} }
@@ -339,15 +338,15 @@ internal class TypeAliasData(
override val ref: TypeRef, override val ref: TypeRef,
/** The types used by this type alias. */ /** The types used by this type alias. */
override val usedTypes: List<TypeRef> = listOf() override val usedTypes: List<TypeRef> = listOf(),
) : TypeData() { ) : TypeData() {
constructor( constructor(
pkg: DocPackage, pkg: DocPackage,
module: DocModule, module: DocModule,
alias: TypeAlias alias: TypeAlias,
) : this( ) : this(
TypeRef(pkg.name, pkg.uri, pkg.version, module.path, alias.simpleName, isTypeAlias = true), TypeRef(pkg.name, pkg.uri, pkg.version, module.path, alias.simpleName, isTypeAlias = true),
findTypesUsedBy(alias, pkg.docPackageInfo).toList() findTypesUsedBy(alias, pkg.docPackageInfo).toList(),
) )
} }
@@ -381,7 +380,7 @@ private fun findTypesUsedBy(
type: PType, type: PType,
enclosingType: Member /* PClass|TypeAlias */, enclosingType: Member /* PClass|TypeAlias */,
enclosingPackage: DocPackageInfo, enclosingPackage: DocPackageInfo,
result: MutableSet<TypeRef> result: MutableSet<TypeRef>,
) { ) {
when (type) { when (type) {
is PType.Class -> { is PType.Class -> {
@@ -416,7 +415,7 @@ private fun findTypesUsedBy(
enclosingPackage.uri, enclosingPackage.uri,
enclosingPackage.version, enclosingPackage.version,
enclosingType.moduleName.substring(enclosingPackage.name.length + 1).replace('.', '/'), enclosingType.moduleName.substring(enclosingPackage.name.length + 1).replace('.', '/'),
PClassInfo.MODULE_CLASS_NAME PClassInfo.MODULE_CLASS_NAME,
) )
) )
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import kotlinx.html.*
internal class PackagePageGenerator( internal class PackagePageGenerator(
docsiteInfo: DocsiteInfo, docsiteInfo: DocsiteInfo,
private val docPackage: DocPackage, private val docPackage: DocPackage,
pageScope: PackageScope pageScope: PackageScope,
) : MainOrPackagePageGenerator<PackageScope>(docsiteInfo, pageScope, pageScope.parent) { ) : MainOrPackagePageGenerator<PackageScope>(docsiteInfo, pageScope, pageScope.parent) {
override val html: HTML.() -> Unit = { override val html: HTML.() -> Unit = {
renderHtmlHead() renderHtmlHead()
@@ -50,12 +50,12 @@ internal class PackagePageGenerator(
pageScope, pageScope,
packageInfo.annotations, packageInfo.annotations,
isDeclaration = true, isDeclaration = true,
collectMemberInfoForPackage(docPackage) collectMemberInfoForPackage(docPackage),
) )
renderMemberGroupLinks( renderMemberGroupLinks(
Triple("Overview", "#_overview", memberDocs.isExpandable), Triple("Overview", "#_overview", memberDocs.isExpandable),
Triple("Modules", "#_modules", docPackage.hasListedModule) Triple("Modules", "#_modules", docPackage.hasListedModule),
) )
renderAnchor("_overview") renderAnchor("_overview")
@@ -120,8 +120,7 @@ internal class PackagePageGenerator(
module.docComment, module.docComment,
moduleScope, moduleScope,
module.annotations, module.annotations,
isDeclaration = false, extraMemberInfo = collectMemberInfo(docModule),
collectMemberInfo(docModule)
) )
renderModuleOrPackage(module.moduleName, moduleScope, memberDocs) renderModuleOrPackage(module.moduleName, moduleScope, memberDocs)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,19 +16,19 @@
package org.pkl.doc package org.pkl.doc
import kotlin.io.path.bufferedWriter import kotlin.io.path.bufferedWriter
import kotlin.io.path.createParentDirectories
import kotlinx.html.* import kotlinx.html.*
import kotlinx.html.stream.appendHTML import kotlinx.html.stream.appendHTML
import org.commonmark.ext.gfm.tables.TablesExtension import org.commonmark.ext.gfm.tables.TablesExtension
import org.commonmark.parser.Parser import org.commonmark.parser.Parser
import org.commonmark.renderer.html.HtmlRenderer import org.commonmark.renderer.html.HtmlRenderer
import org.pkl.commons.createParentDirectories
import org.pkl.commons.toPath import org.pkl.commons.toPath
import org.pkl.core.* import org.pkl.core.*
import org.pkl.core.util.IoUtils import org.pkl.core.util.IoUtils
internal abstract class PageGenerator<out S>( internal abstract class PageGenerator<out S>(
protected val docsiteInfo: DocsiteInfo, protected val docsiteInfo: DocsiteInfo,
protected val pageScope: S protected val pageScope: S,
) where S : PageScope { ) where S : PageScope {
private val markdownInlineParserFactory = MarkdownParserFactory(pageScope) private val markdownInlineParserFactory = MarkdownParserFactory(pageScope)
@@ -110,7 +110,7 @@ internal abstract class PageGenerator<out S>(
packageName: String?, packageName: String?,
packageVersion: String?, packageVersion: String?,
moduleName: String?, moduleName: String?,
className: String? className: String?,
) { ) {
header { header {
if (docsiteInfo.title != null) { if (docsiteInfo.title != null) {
@@ -227,11 +227,11 @@ internal abstract class PageGenerator<out S>(
) { ) {
ul { ul {
classes = setOf("member-group-links") classes = setOf("member-group-links")
for ((name, _href, show) in groups) { for ((name, href, show) in groups) {
if (show) { if (show) {
li { li {
a { a {
href = _href this.href = href
+name +name
} }
} }
@@ -280,7 +280,7 @@ internal abstract class PageGenerator<out S>(
protected fun HtmlBlockTag.renderTypeAliasName( protected fun HtmlBlockTag.renderTypeAliasName(
typeAlias: TypeAlias, typeAlias: TypeAlias,
cssClass: String = "name-ref" cssClass: String = "name-ref",
) { ) {
val moduleDocUrl = pageScope.resolveModuleNameToDocUrl(typeAlias.moduleName) val moduleDocUrl = pageScope.resolveModuleNameToDocUrl(typeAlias.moduleName)
@@ -302,7 +302,7 @@ internal abstract class PageGenerator<out S>(
protected fun HtmlBlockTag.renderType( protected fun HtmlBlockTag.renderType(
type: PType, type: PType,
currScope: DocScope, currScope: DocScope,
isNested: Boolean = false isNested: Boolean = false,
) { ) {
when (type) { when (type) {
PType.UNKNOWN -> { PType.UNKNOWN -> {
@@ -390,7 +390,7 @@ internal abstract class PageGenerator<out S>(
private fun HtmlBlockTag.renderTypeVariable( private fun HtmlBlockTag.renderTypeVariable(
typeVariable: PType.TypeVariable, typeVariable: PType.TypeVariable,
currentScope: DocScope currentScope: DocScope,
) { ) {
val parameterScope = currentScope.resolveVariable(typeVariable.name) as? ParameterScope val parameterScope = currentScope.resolveVariable(typeVariable.name) as? ParameterScope
@@ -634,7 +634,7 @@ internal abstract class PageGenerator<out S>(
annotations: List<PObject>, annotations: List<PObject>,
/** Whether these member docs are for the main declaration at the top of a page. */ /** Whether these member docs are for the main declaration at the top of a page. */
private val isDeclaration: Boolean = false, private val isDeclaration: Boolean = false,
private val extraMemberInfo: Map<MemberInfoKey, HtmlBlockTag.() -> Unit> = mapOf() private val extraMemberInfo: Map<MemberInfoKey, HtmlBlockTag.() -> Unit> = mapOf(),
) { ) {
init { init {
markdownInlineParserFactory.docScope = docScope markdownInlineParserFactory.docScope = docScope
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,13 +16,15 @@
package org.pkl.doc package org.pkl.doc
import java.nio.file.Path import java.nio.file.Path
import org.pkl.commons.deleteRecursively import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.deleteRecursively
import org.pkl.core.util.json.JsonWriter import org.pkl.core.util.json.JsonWriter
// Note: we don't currently make use of persisted type alias data (needs more thought). // Note: we don't currently make use of persisted type alias data (needs more thought).
@OptIn(ExperimentalPathApi::class)
internal class RuntimeDataGenerator( internal class RuntimeDataGenerator(
private val descendingVersionComparator: Comparator<String>, private val descendingVersionComparator: Comparator<String>,
private val outputDir: Path private val outputDir: Path,
) { ) {
private val packageVersions = mutableMapOf<PackageId, MutableSet<String>>() private val packageVersions = mutableMapOf<PackageId, MutableSet<String>>()
@@ -95,7 +97,7 @@ internal class RuntimeDataGenerator(
packageVersions.getOrDefault(ref.pkg, setOf()).sortedWith(descendingVersionComparator), packageVersions.getOrDefault(ref.pkg, setOf()).sortedWith(descendingVersionComparator),
{ it }, { it },
{ if (it == ref.version) null else ref.copy(version = it).pageUrlRelativeTo(ref) }, { if (it == ref.version) null else ref.copy(version = it).pageUrlRelativeTo(ref) },
{ if (it == ref.version) CssConstants.CURRENT_VERSION else null } { if (it == ref.version) CssConstants.CURRENT_VERSION else null },
) )
writer.writeLinks( writer.writeLinks(
HtmlConstants.KNOWN_USAGES, HtmlConstants.KNOWN_USAGES,
@@ -104,7 +106,7 @@ internal class RuntimeDataGenerator(
}, },
PackageRef::pkg, PackageRef::pkg,
{ it.pageUrlRelativeTo(ref) }, { it.pageUrlRelativeTo(ref) },
{ null } { null },
) )
} }
} }
@@ -122,7 +124,7 @@ internal class RuntimeDataGenerator(
moduleVersions.getOrDefault(ref.id, setOf()).sortedWith(descendingVersionComparator), moduleVersions.getOrDefault(ref.id, setOf()).sortedWith(descendingVersionComparator),
{ it }, { it },
{ if (it == ref.version) null else ref.copy(version = it).pageUrlRelativeTo(ref) }, { if (it == ref.version) null else ref.copy(version = it).pageUrlRelativeTo(ref) },
{ if (it == ref.version) CssConstants.CURRENT_VERSION else null } { if (it == ref.version) CssConstants.CURRENT_VERSION else null },
) )
writer.writeLinks( writer.writeLinks(
HtmlConstants.KNOWN_USAGES, HtmlConstants.KNOWN_USAGES,
@@ -131,7 +133,7 @@ internal class RuntimeDataGenerator(
}, },
TypeRef::displayName, TypeRef::displayName,
{ it.pageUrlRelativeTo(ref) }, { it.pageUrlRelativeTo(ref) },
{ null } { null },
) )
writer.writeLinks( writer.writeLinks(
HtmlConstants.KNOWN_SUBTYPES, HtmlConstants.KNOWN_SUBTYPES,
@@ -140,7 +142,7 @@ internal class RuntimeDataGenerator(
}, },
TypeRef::displayName, TypeRef::displayName,
{ it.pageUrlRelativeTo(ref) }, { it.pageUrlRelativeTo(ref) },
{ null } { null },
) )
} }
} }
@@ -158,7 +160,7 @@ internal class RuntimeDataGenerator(
classVersions.getOrDefault(ref.id, setOf()).sortedWith(descendingVersionComparator), classVersions.getOrDefault(ref.id, setOf()).sortedWith(descendingVersionComparator),
{ it }, { it },
{ if (it == ref.version) null else ref.copy(version = it).pageUrlRelativeTo(ref) }, { if (it == ref.version) null else ref.copy(version = it).pageUrlRelativeTo(ref) },
{ if (it == ref.version) CssConstants.CURRENT_VERSION else null } { if (it == ref.version) CssConstants.CURRENT_VERSION else null },
) )
writer.writeLinks( writer.writeLinks(
HtmlConstants.KNOWN_USAGES, HtmlConstants.KNOWN_USAGES,
@@ -167,7 +169,7 @@ internal class RuntimeDataGenerator(
}, },
TypeRef::displayName, TypeRef::displayName,
{ it.pageUrlRelativeTo(ref) }, { it.pageUrlRelativeTo(ref) },
{ null } { null },
) )
writer.writeLinks( writer.writeLinks(
HtmlConstants.KNOWN_SUBTYPES, HtmlConstants.KNOWN_SUBTYPES,
@@ -176,7 +178,7 @@ internal class RuntimeDataGenerator(
}, },
TypeRef::displayName, TypeRef::displayName,
{ it.pageUrlRelativeTo(ref) }, { it.pageUrlRelativeTo(ref) },
{ null } { null },
) )
} }
} }
@@ -191,7 +193,7 @@ internal class RuntimeDataGenerator(
// link href // link href
href: (T) -> String?, href: (T) -> String?,
// link CSS classes // link CSS classes
classes: (T) -> String? classes: (T) -> String?,
) { ) {
if (items.isEmpty()) return if (items.isEmpty()) return
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ package org.pkl.doc
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.bufferedWriter import kotlin.io.path.bufferedWriter
import org.pkl.commons.createParentDirectories import kotlin.io.path.createParentDirectories
import org.pkl.core.Member import org.pkl.core.Member
import org.pkl.core.PClass.Method import org.pkl.core.PClass.Method
import org.pkl.core.PClass.Property import org.pkl.core.PClass.Property
+4 -4
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@ import java.io.InputStream
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.bufferedWriter import kotlin.io.path.bufferedWriter
import kotlin.io.path.createParentDirectories
import kotlin.io.path.outputStream import kotlin.io.path.outputStream
import org.pkl.commons.createParentDirectories
import org.pkl.core.* import org.pkl.core.*
import org.pkl.core.parser.Lexer import org.pkl.core.parser.Lexer
import org.pkl.core.util.IoUtils import org.pkl.core.util.IoUtils
@@ -62,7 +62,7 @@ internal val List<PObject>.isUnlisted: Boolean
internal val List<PObject>.deprecation: String? internal val List<PObject>.deprecation: String?
get() = find { it.classInfo == PClassInfo.Deprecated }?.get("message") as String? get() = find { it.classInfo == PClassInfo.Deprecated }?.get("message") as String?
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST", "unused")
internal val List<PObject>.alsoKnownAs: List<String>? internal val List<PObject>.alsoKnownAs: List<String>?
get() = find { it.classInfo == PClassInfo.AlsoKnownAs }?.get("names") as List<String>? get() = find { it.classInfo == PClassInfo.AlsoKnownAs }?.get("names") as List<String>?
@@ -111,7 +111,7 @@ internal inline fun JsonWriter.array(body: JsonWriter.() -> Unit) {
internal fun String.replaceSourceCodePlaceholders( internal fun String.replaceSourceCodePlaceholders(
path: String, path: String,
sourceLocation: Member.SourceLocation sourceLocation: Member.SourceLocation,
): String { ): String {
return replace("%{path}", path) return replace("%{path}", path)
.replace("%{line}", sourceLocation.startLine().toString()) .replace("%{line}", sourceLocation.startLine().toString())
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@ import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource import org.junit.jupiter.params.provider.MethodSource
import org.pkl.commons.cli.CliBaseOptions import org.pkl.commons.cli.CliBaseOptions
import org.pkl.commons.cli.CliException import org.pkl.commons.cli.CliException
import org.pkl.commons.createParentDirectories
import org.pkl.commons.readString import org.pkl.commons.readString
import org.pkl.commons.test.FileTestUtils import org.pkl.commons.test.FileTestUtils
import org.pkl.commons.test.PackageServer import org.pkl.commons.test.PackageServer
@@ -106,12 +105,7 @@ class CliDocGeneratorTest {
actualOutputFiles.map { IoUtils.toNormalizedPathString(actualOutputDir.relativize(it)) } actualOutputFiles.map { IoUtils.toNormalizedPathString(actualOutputDir.relativize(it)) }
} }
private val binaryFileExtensions = private val binaryFileExtensions = setOf("woff2", "png", "svg")
setOf(
"woff2",
"png",
"svg",
)
private fun runDocGenerator(outputDir: Path, cacheDir: Path?) { private fun runDocGenerator(outputDir: Path, cacheDir: Path?) {
CliDocGenerator( CliDocGenerator(
@@ -127,10 +121,10 @@ class CliDocGeneratorTest {
URI("package://localhost:0/unlisted@1.0.0"), URI("package://localhost:0/unlisted@1.0.0"),
URI("package://localhost:0/deprecated@1.0.0"), URI("package://localhost:0/deprecated@1.0.0"),
) + package1InputModules + package2InputModules, ) + package1InputModules + package2InputModules,
moduleCacheDir = cacheDir moduleCacheDir = cacheDir,
), ),
outputDir = outputDir, outputDir = outputDir,
isTestMode = true isTestMode = true,
) )
) )
.run() .run()
@@ -172,7 +166,7 @@ class CliDocGeneratorTest {
CliDocGeneratorOptions( CliDocGeneratorOptions(
CliBaseOptions(sourceModules = listOf(descriptor1.toUri(), descriptor2.toUri())), CliBaseOptions(sourceModules = listOf(descriptor1.toUri(), descriptor2.toUri())),
outputDir = tmpOutputDir, outputDir = tmpOutputDir,
isTestMode = true isTestMode = true,
) )
) )
@@ -192,7 +186,7 @@ class CliDocGeneratorTest {
CliDocGeneratorOptions( CliDocGeneratorOptions(
CliBaseOptions(sourceModules = listOf(module1.toUri())), CliBaseOptions(sourceModules = listOf(module1.toUri())),
outputDir = tmpOutputDir, outputDir = tmpOutputDir,
isTestMode = true isTestMode = true,
) )
) )
@@ -212,7 +206,7 @@ class CliDocGeneratorTest {
CliDocGeneratorOptions( CliDocGeneratorOptions(
CliBaseOptions(sourceModules = listOf(descriptor1.toUri())), CliBaseOptions(sourceModules = listOf(descriptor1.toUri())),
outputDir = tmpOutputDir, outputDir = tmpOutputDir,
isTestMode = true isTestMode = true,
) )
) )
@@ -286,17 +280,14 @@ class CliDocGeneratorTest {
sourceCode = URI.create("foo.pkl"), sourceCode = URI.create("foo.pkl"),
issueTracker = URI.create("https://github.com/apple/pkl/issues"), issueTracker = URI.create("https://github.com/apple/pkl/issues"),
overview = "my overview", overview = "my overview",
sourceCodeUrlScheme = "https://example.com/blob/$version%{path}#L%{line}-%{endLine}" sourceCodeUrlScheme = "https://example.com/blob/$version%{path}#L%{line}-%{endLine}",
), ),
modules = emptyList() modules = emptyList(),
), )
) )
val packages: List<PackageData> = val packages: List<PackageData> =
listOf( listOf(createPackageData("1.2.3"), createPackageData("1.3.0-SNAPSHOT"))
createPackageData("1.2.3"),
createPackageData("1.3.0-SNAPSHOT"),
)
val comparator = val comparator =
Comparator<String> { v1, v2 -> Version.parse(v1).compareTo(Version.parse(v2)) }.reversed() Comparator<String> { v1, v2 -> Version.parse(v1).compareTo(Version.parse(v2)) }.reversed()
+21 -16
View File
@@ -3,26 +3,31 @@
# This file is expected to be part of source control. # This file is expected to be part of source control.
com.tunnelvisionlabs:antlr4-runtime:4.9.0=testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
+22 -16
View File
@@ -4,24 +4,30 @@
com.github.ajalt.clikt:clikt-jvm:3.5.4=compileClasspath com.github.ajalt.clikt:clikt-jvm:3.5.4=compileClasspath
com.github.ajalt.clikt:clikt:3.5.4=compileClasspath,compileOnlyDependenciesMetadata com.github.ajalt.clikt:clikt:3.5.4=compileClasspath,compileOnlyDependenciesMetadata
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=compileClasspath,compileOnlyDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=compileClasspath,compileOnlyDependenciesMetadata,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=compileClasspath,compileOnlyDependenciesMetadata,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=compileClasspath,compileOnlyDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=compileClasspath,compileOnlyDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=compileClasspath,compileOnlyDependenciesMetadata
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=compileClasspath,compileOnlyDependenciesMetadata,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=compileClasspath,compileOnlyDependenciesMetadata,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=compileClasspath,compileOnlyDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
+11 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -53,7 +53,13 @@ sourceSets {
test { test {
// Remove Gradle distribution JARs from test compile classpath. // Remove Gradle distribution JARs from test compile classpath.
// This prevents a conflict between Gradle's and Pkl's Kotlin versions. // This prevents a conflict between Gradle's and Pkl's Kotlin versions.
compileClasspath = compileClasspath.filter { !(it.path.contains("dists")) } //
// For some reason, IntelliJ import turns pklCommonsTest into a runtime dependency
// if `compileClasspath` is filtered, causing "unresolved reference" errors in IntelliJ.
// As a workaround, don't perform filtering for IntelliJ (import).
if (System.getProperty("idea.sync.active") == null) {
compileClasspath = compileClasspath.filter { !(it.path.contains("dists")) }
}
} }
} }
@@ -99,4 +105,6 @@ signing {
// (Apparently, gradle-api.jar now contains metadata that causes kotlinc to enforce Gradle's Kotlin // (Apparently, gradle-api.jar now contains metadata that causes kotlinc to enforce Gradle's Kotlin
// version.) // version.)
// A more robust solution would be to port plugin tests to Java. // A more robust solution would be to port plugin tests to Java.
tasks.compileTestKotlin { kotlinOptions { freeCompilerArgs += "-Xskip-metadata-version-check" } } tasks.compileTestKotlin {
compilerOptions { freeCompilerArgs.add("-Xskip-metadata-version-check") }
}
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -17,14 +17,14 @@ package org.pkl.gradle
import java.net.URI import java.net.URI
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.createParentDirectories
import kotlin.io.path.writeText
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.UnexpectedBuildFailure import org.gradle.testkit.runner.UnexpectedBuildFailure
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.readString import org.pkl.commons.readString
import org.pkl.commons.writeString
abstract class AbstractTest { abstract class AbstractTest {
private val gradleVersion: String? = System.getProperty("testGradleVersion") private val gradleVersion: String? = System.getProperty("testGradleVersion")
@@ -57,10 +57,10 @@ abstract class AbstractTest {
} }
protected fun writeFile(fileName: String, contents: String): Path { protected fun writeFile(fileName: String, contents: String): Path {
return testProjectDir return testProjectDir.resolve(fileName).apply {
.resolve(fileName) createParentDirectories()
.apply { createParentDirectories() } writeText(contents.trimIndent())
.writeString(contents.trimIndent()) }
} }
protected fun checkFileContents(file: Path, contents: String) { protected fun checkFileContents(file: Path, contents: String) {
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
val baseDir = testProjectDir.resolve("build/generated/java/foo/bar") val baseDir = testProjectDir.resolve("build/generated/java/foo/bar")
val moduleFile = baseDir.resolve("Mod.java") val moduleFile = baseDir.resolve("Mod.java")
assertThat(baseDir.listDirectoryEntries().count()).isEqualTo(1) assertThat(baseDir.listDirectoryEntries().size).isEqualTo(1)
assertThat(moduleFile).exists() assertThat(moduleFile).exists()
val text = moduleFile.readText() val text = moduleFile.readText()
@@ -44,7 +44,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
""" """
|public final class Mod { |public final class Mod {
| public final @Nonnull Object other; | public final @Nonnull Object other;
""" """,
) )
checkTextContains( checkTextContains(
@@ -54,7 +54,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
| public final @Nonnull String name; | public final @Nonnull String name;
| |
| public final @Nonnull List<Address> addresses; | public final @Nonnull List<Address> addresses;
""" """,
) )
checkTextContains( checkTextContains(
@@ -64,7 +64,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
| public final @Nonnull String street; | public final @Nonnull String street;
| |
| public final long zip; | public final long zip;
""" """,
) )
} }
@@ -100,7 +100,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
} }
} }
} }
""" """,
) )
val result = runTask("evalTest", true) val result = runTask("evalTest", true)
@@ -139,7 +139,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
} }
} }
} }
""" """,
) )
} }
@@ -160,7 +160,7 @@ class JavaCodeGeneratorsTest : AbstractTest() {
} }
other = 42 other = 42
""" """,
) )
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
val baseDir = testProjectDir.resolve("build/generated/kotlin/foo/bar") val baseDir = testProjectDir.resolve("build/generated/kotlin/foo/bar")
val kotlinFile = baseDir.resolve("Mod.kt") val kotlinFile = baseDir.resolve("Mod.kt")
assertThat(baseDir.listDirectoryEntries().count()).isEqualTo(1) assertThat(baseDir.listDirectoryEntries().size).isEqualTo(1)
assertThat(kotlinFile).exists() assertThat(kotlinFile).exists()
val text = kotlinFile.readText() val text = kotlinFile.readText()
@@ -39,11 +39,14 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
// shading must not affect generated code // shading must not affect generated code
assertThat(text).doesNotContain("org.pkl.thirdparty") assertThat(text).doesNotContain("org.pkl.thirdparty")
checkTextContains(text, """ checkTextContains(
text,
"""
|data class Mod( |data class Mod(
| val other: Any? | val other: Any?
|) |)
""") """,
)
checkTextContains( checkTextContains(
text, text,
@@ -52,7 +55,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
| val name: String, | val name: String,
| val addresses: List<Address> | val addresses: List<Address>
| ) | )
""" """,
) )
checkTextContains( checkTextContains(
@@ -62,7 +65,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
| open val street: String, | open val street: String,
| open val zip: Long | open val zip: Long
| ) | )
""" """,
) )
} }
@@ -97,7 +100,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
} }
} }
} }
""" """,
) )
val result = runTask("evalTest", true) val result = runTask("evalTest", true)
@@ -148,7 +151,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
} }
} }
} }
""" """,
) )
} }
@@ -170,7 +173,7 @@ class KotlinCodeGeneratorsTest : AbstractTest() {
} }
other = 42 other = 42
""" """,
) )
} }
} }
+21 -16
View File
@@ -3,26 +3,31 @@
# This file is expected to be part of source control. # This file is expected to be part of source control.
com.tunnelvisionlabs:antlr4-runtime:4.9.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath com.tunnelvisionlabs:antlr4-runtime:4.9.0=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:1.7.10=kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-script-runtime:1.7.10=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath org.jetbrains.kotlin:kotlin-compiler-runner:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-client:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.0.21=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest org.jetbrains.kotlin:kotlin-native-prebuilt:2.0.21=kotlinNativeBundleConfiguration
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-script-runtime:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-common:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains:annotations:13.0=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.21=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.21=apiDependenciesMetadata,compileClasspath,implementationDependenciesMetadata,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-api:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata org.junit.jupiter:junit-jupiter-engine:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath,testRuntimeOnlyDependenciesMetadata
org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath org.junit.jupiter:junit-jupiter-params:5.11.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ class ServerMessagePackEncoder(packer: MessagePacker) : BaseMessagePackEncoder(p
packKeyValue("sha256", checksums.sha256) packKeyValue("sha256", checksums.sha256)
} }
private fun MessagePacker.packExternalReader(spec: ExternalReader) { private fun packExternalReader(spec: ExternalReader) {
packMapHeader(1, spec.arguments) packMapHeader(1, spec.arguments)
packKeyValue("executable", spec.executable) packKeyValue("executable", spec.executable)
spec.arguments?.let { packKeyValue("arguments", it) } spec.arguments?.let { packKeyValue("arguments", it) }
@@ -141,7 +141,7 @@ class ServerMessagePackEncoder(packer: MessagePacker) : BaseMessagePackEncoder(p
packer.packMapHeader(msg.externalModuleReaders.size) packer.packMapHeader(msg.externalModuleReaders.size)
for ((scheme, spec) in msg.externalModuleReaders) { for ((scheme, spec) in msg.externalModuleReaders) {
packer.packString(scheme) packer.packString(scheme)
packer.packExternalReader(spec) packExternalReader(spec)
} }
} }
if (msg.externalResourceReaders != null) { if (msg.externalResourceReaders != null) {
@@ -149,7 +149,7 @@ class ServerMessagePackEncoder(packer: MessagePacker) : BaseMessagePackEncoder(p
packer.packMapHeader(msg.externalResourceReaders.size) packer.packMapHeader(msg.externalResourceReaders.size)
for ((scheme, spec) in msg.externalResourceReaders) { for ((scheme, spec) in msg.externalResourceReaders) {
packer.packString(scheme) packer.packString(scheme)
packer.packExternalReader(spec) packExternalReader(spec)
} }
} }
return return
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -50,6 +50,7 @@ private val threadLocalEncoder: ThreadLocal<(Message) -> ByteArray> =
} }
} }
@Suppress("unused")
internal fun encode(message: Message): ByteArray { internal fun encode(message: Message): ByteArray {
return threadLocalEncoder.get()(message) return threadLocalEncoder.get()(message)
} }
@@ -60,6 +61,7 @@ internal fun encode(message: Message): ByteArray {
* *
* [Future.get] will wrap any exception in [ExecutionException], which is kind of silly. * [Future.get] will wrap any exception in [ExecutionException], which is kind of silly.
*/ */
@Suppress("unused")
fun <T> Future<T>.getUnderlying(): T = fun <T> Future<T>.getUnderlying(): T =
try { try {
get() get()
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ abstract class AbstractServerTest {
companion object { companion object {
/** Set to `true` to bypass messagepack serialization when running [JvmServerTest]. */ /** Set to `true` to bypass messagepack serialization when running [JvmServerTest]. */
const val USE_DIRECT_TRANSPORT = false internal const val USE_DIRECT_TRANSPORT = false
val executor: ExecutorService = val executor: ExecutorService =
if (USE_DIRECT_TRANSPORT) { if (USE_DIRECT_TRANSPORT) {
@@ -77,7 +77,7 @@ abstract class AbstractServerTest {
} }
""" """
.trimIndent(), .trimIndent(),
null null,
) )
) )
@@ -104,7 +104,7 @@ abstract class AbstractServerTest {
foo = trace(1 + 2 + 3) foo = trace(1 + 2 + 3)
""" """
.trimIndent(), .trimIndent(),
null null,
) )
) )
@@ -131,7 +131,7 @@ abstract class AbstractServerTest {
result = foo() result = foo()
""" """
.trimIndent(), .trimIndent(),
null null,
) )
) )
@@ -153,7 +153,7 @@ abstract class AbstractServerTest {
evaluatorId, evaluatorId,
URI("repl:text"), URI("repl:text"),
"""res = read("bahumbug:/foo.pkl").text""", """res = read("bahumbug:/foo.pkl").text""",
"res" "res",
) )
) )
@@ -166,7 +166,7 @@ abstract class AbstractServerTest {
readResourceMsg.requestId, readResourceMsg.requestId,
evaluatorId, evaluatorId,
"my bahumbug".toByteArray(), "my bahumbug".toByteArray(),
null null,
) )
) )
@@ -192,7 +192,7 @@ abstract class AbstractServerTest {
evaluatorId = evaluatorId, evaluatorId = evaluatorId,
moduleUri = URI("repl:text"), moduleUri = URI("repl:text"),
moduleText = """res = read("bahumbug:/foo.pkl").text""", moduleText = """res = read("bahumbug:/foo.pkl").text""",
expr = "res" expr = "res",
) )
) )
@@ -225,7 +225,7 @@ abstract class AbstractServerTest {
evaluatorId, evaluatorId,
URI("repl:text"), URI("repl:text"),
"""res = read("bahumbug:/foo.txt").text""", """res = read("bahumbug:/foo.txt").text""",
"res" "res",
) )
) )
@@ -236,7 +236,7 @@ abstract class AbstractServerTest {
readResourceMsg.requestId, readResourceMsg.requestId,
evaluatorId, evaluatorId,
byteArrayOf(), byteArrayOf(),
"cannot read my bahumbug" "cannot read my bahumbug",
) )
) )
@@ -258,7 +258,7 @@ abstract class AbstractServerTest {
res = read*("bird:/**.txt").keys res = read*("bird:/**.txt").keys
""" """
.trimIndent(), .trimIndent(),
"res" "res",
) )
) )
val listResourcesRequest = client.receive<ListResourcesRequest>() val listResourcesRequest = client.receive<ListResourcesRequest>()
@@ -268,7 +268,7 @@ abstract class AbstractServerTest {
listResourcesRequest.requestId, listResourcesRequest.requestId,
listResourcesRequest.evaluatorId, listResourcesRequest.evaluatorId,
listOf(PathElement("foo.txt", false), PathElement("subdir", true)), listOf(PathElement("foo.txt", false), PathElement("subdir", true)),
null null,
) )
) )
val listResourcesRequest2 = client.receive<ListResourcesRequest>() val listResourcesRequest2 = client.receive<ListResourcesRequest>()
@@ -277,10 +277,8 @@ abstract class AbstractServerTest {
ListResourcesResponse( ListResourcesResponse(
listResourcesRequest2.requestId, listResourcesRequest2.requestId,
listResourcesRequest2.evaluatorId, listResourcesRequest2.evaluatorId,
listOf( listOf(PathElement("bar.txt", false)),
PathElement("bar.txt", false), null,
),
null
) )
) )
val evaluateResponse = client.receive<EvaluateResponse>() val evaluateResponse = client.receive<EvaluateResponse>()
@@ -309,7 +307,7 @@ abstract class AbstractServerTest {
res = read*("bird:/**.txt").keys res = read*("bird:/**.txt").keys
""" """
.trimIndent(), .trimIndent(),
"res" "res",
) )
) )
val listResourcesRequest = client.receive<ListResourcesRequest>() val listResourcesRequest = client.receive<ListResourcesRequest>()
@@ -318,7 +316,7 @@ abstract class AbstractServerTest {
listResourcesRequest.requestId, listResourcesRequest.requestId,
listResourcesRequest.evaluatorId, listResourcesRequest.evaluatorId,
null, null,
null null,
) )
) )
val evaluateResponse = client.receive<EvaluateResponse>() val evaluateResponse = client.receive<EvaluateResponse>()
@@ -345,7 +343,7 @@ abstract class AbstractServerTest {
res = read*("bird:/**.txt").keys res = read*("bird:/**.txt").keys
""" """
.trimIndent(), .trimIndent(),
"res" "res",
) )
) )
val listResourcesRequest = client.receive<ListResourcesRequest>() val listResourcesRequest = client.receive<ListResourcesRequest>()
@@ -355,7 +353,7 @@ abstract class AbstractServerTest {
listResourcesRequest.requestId, listResourcesRequest.requestId,
listResourcesRequest.evaluatorId, listResourcesRequest.evaluatorId,
null, null,
"didnt work" "didnt work",
) )
) )
val evaluateResponse = client.receive<EvaluateResponse>() val evaluateResponse = client.receive<EvaluateResponse>()
@@ -390,7 +388,7 @@ abstract class AbstractServerTest {
evaluatorId, evaluatorId,
URI("repl:text"), URI("repl:text"),
"""res = import("bird:/pigeon.pkl").value""", """res = import("bird:/pigeon.pkl").value""",
"res" "res",
) )
) )
@@ -418,7 +416,7 @@ abstract class AbstractServerTest {
evaluatorId = evaluatorId, evaluatorId = evaluatorId,
moduleUri = URI("repl:text"), moduleUri = URI("repl:text"),
moduleText = """res = import("bird:/pigeon.pkl")""", moduleText = """res = import("bird:/pigeon.pkl")""",
expr = "res" expr = "res",
) )
) )
@@ -448,7 +446,7 @@ abstract class AbstractServerTest {
evaluatorId, evaluatorId,
URI("repl:text"), URI("repl:text"),
"""res = import("bird:/pigeon.pkl").value""", """res = import("bird:/pigeon.pkl").value""",
"res" "res",
) )
) )
@@ -475,7 +473,7 @@ abstract class AbstractServerTest {
evaluatorId, evaluatorId,
URI("repl:text"), URI("repl:text"),
"""res = import*("bird:/**.pkl").keys""", """res = import*("bird:/**.pkl").keys""",
"res" "res",
) )
) )
@@ -489,9 +487,9 @@ abstract class AbstractServerTest {
listOf( listOf(
PathElement("birds", true), PathElement("birds", true),
PathElement("majesticBirds", true), PathElement("majesticBirds", true),
PathElement("Person.pkl", false) PathElement("Person.pkl", false),
), ),
null null,
) )
) )
val listModulesMsg2 = client.receive<ListModulesRequest>() val listModulesMsg2 = client.receive<ListModulesRequest>()
@@ -501,11 +499,8 @@ abstract class AbstractServerTest {
ListModulesResponse( ListModulesResponse(
listModulesMsg2.requestId, listModulesMsg2.requestId,
listModulesMsg2.evaluatorId, listModulesMsg2.evaluatorId,
listOf( listOf(PathElement("pigeon.pkl", false), PathElement("parrot.pkl", false)),
PathElement("pigeon.pkl", false), null,
PathElement("parrot.pkl", false),
),
null
) )
) )
val listModulesMsg3 = client.receive<ListModulesRequest>() val listModulesMsg3 = client.receive<ListModulesRequest>()
@@ -515,11 +510,8 @@ abstract class AbstractServerTest {
ListModulesResponse( ListModulesResponse(
listModulesMsg3.requestId, listModulesMsg3.requestId,
listModulesMsg3.evaluatorId, listModulesMsg3.evaluatorId,
listOf( listOf(PathElement("barnOwl.pkl", false), PathElement("elfOwl.pkl", false)),
PathElement("barnOwl.pkl", false), null,
PathElement("elfOwl.pkl", false),
),
null
) )
) )
@@ -550,7 +542,7 @@ abstract class AbstractServerTest {
evaluatorId, evaluatorId,
URI("repl:text"), URI("repl:text"),
"""res = import*("bird:/**.pkl").keys""", """res = import*("bird:/**.pkl").keys""",
"res" "res",
) )
) )
val listModulesMsg = client.receive<ListModulesRequest>() val listModulesMsg = client.receive<ListModulesRequest>()
@@ -578,7 +570,7 @@ abstract class AbstractServerTest {
evaluatorId, evaluatorId,
URI("repl:text"), URI("repl:text"),
"""res = import*("bird:/**.pkl").keys""", """res = import*("bird:/**.pkl").keys""",
"res" "res",
) )
) )
@@ -669,7 +661,7 @@ abstract class AbstractServerTest {
res = buz.res res = buz.res
""" """
.trimIndent(), .trimIndent(),
"res" "res",
) )
) )
val readModuleRequest = client.receive<ReadModuleRequest>() val readModuleRequest = client.receive<ReadModuleRequest>()
@@ -679,7 +671,7 @@ abstract class AbstractServerTest {
readModuleRequest.requestId, readModuleRequest.requestId,
readModuleRequest.evaluatorId, readModuleRequest.evaluatorId,
null, null,
"not here" "not here",
) )
) )
@@ -690,7 +682,7 @@ abstract class AbstractServerTest {
readModuleRequest2.requestId, readModuleRequest2.requestId,
readModuleRequest2.evaluatorId, readModuleRequest2.evaluatorId,
"res = 1", "res = 1",
null null,
) )
) )
@@ -714,15 +706,7 @@ abstract class AbstractServerTest {
val reader = ModuleReaderSpec("bird", true, false, false) val reader = ModuleReaderSpec("bird", true, false, false)
val evaluatorId = client.sendCreateEvaluatorRequest(moduleReaders = listOf(reader)) val evaluatorId = client.sendCreateEvaluatorRequest(moduleReaders = listOf(reader))
client.send( client.send(EvaluateRequest(1, evaluatorId, URI("bird:/pigeon.pkl"), null, "output.text"))
EvaluateRequest(
1,
evaluatorId,
URI("bird:/pigeon.pkl"),
null,
"output.text",
)
)
val readModuleRequest = client.receive<ReadModuleRequest>() val readModuleRequest = client.receive<ReadModuleRequest>()
assertThat(readModuleRequest.uri.toString()).isEqualTo("bird:/pigeon.pkl") assertThat(readModuleRequest.uri.toString()).isEqualTo("bird:/pigeon.pkl")
@@ -737,7 +721,7 @@ abstract class AbstractServerTest {
fullName = firstName + " " + lastName fullName = firstName + " " + lastName
""" """
.trimIndent(), .trimIndent(),
null null,
) )
) )
@@ -759,15 +743,7 @@ abstract class AbstractServerTest {
fun `concurrent evaluations`() { fun `concurrent evaluations`() {
val reader = ModuleReaderSpec("bird", true, false, false) val reader = ModuleReaderSpec("bird", true, false, false)
val evaluatorId = client.sendCreateEvaluatorRequest(moduleReaders = listOf(reader)) val evaluatorId = client.sendCreateEvaluatorRequest(moduleReaders = listOf(reader))
client.send( client.send(EvaluateRequest(1, evaluatorId, URI("bird:/pigeon.pkl"), null, "output.text"))
EvaluateRequest(
1,
evaluatorId,
URI("bird:/pigeon.pkl"),
null,
"output.text",
)
)
client.send(EvaluateRequest(2, evaluatorId, URI("bird:/parrot.pkl"), null, "output.text")) client.send(EvaluateRequest(2, evaluatorId, URI("bird:/parrot.pkl"), null, "output.text"))
@@ -785,7 +761,7 @@ abstract class AbstractServerTest {
fullName = firstName + " " + lastName fullName = firstName + " " + lastName
""" """
.trimIndent(), .trimIndent(),
null null,
) )
) )
@@ -815,7 +791,7 @@ abstract class AbstractServerTest {
fullName = firstName + " " + lastName fullName = firstName + " " + lastName
""" """
.trimIndent(), .trimIndent(),
null null,
) )
) )
@@ -923,20 +899,12 @@ abstract class AbstractServerTest {
Project( Project(
libDir.toUri().resolve("PklProject"), libDir.toUri().resolve("PklProject"),
URI("package://localhost:0/lib@5.0.0"), URI("package://localhost:0/lib@5.0.0"),
emptyMap() emptyMap(),
) ),
) ),
) ),
) )
client.send( client.send(EvaluateRequest(1, evaluatorId, module.toUri(), null, "output.text"))
EvaluateRequest(
1,
evaluatorId,
module.toUri(),
null,
"output.text",
)
)
val resp2 = client.receive<EvaluateResponse>() val resp2 = client.receive<EvaluateResponse>()
assertThat(resp2.error).isNull() assertThat(resp2.error).isNull()
assertThat(resp2.result).isNotNull() assertThat(resp2.result).isNotNull()
@@ -987,7 +955,7 @@ abstract class AbstractServerTest {
project, project,
http, http,
null, null,
null null,
) )
send(message) send(message)
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ class BinaryEvaluatorSnippetTestEngine : InputOutputTestEngine() {
null, null,
null, null,
null, null,
null null,
) )
private fun String.stripFilePaths() = private fun String.stripFilePaths() =
@@ -67,5 +67,5 @@ class BinaryEvaluatorSnippetTestEngine : InputOutputTestEngine() {
} }
} }
val ByteArray.debugRendering val ByteArray.debugRendering: String
get() = MessagePackDebugRenderer(this).output get() = MessagePackDebugRenderer(this).output
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ class MessagePackDebugRenderer(bytes: ByteArray) {
} }
} }
val output by lazy { val output: String by lazy {
renderValue() renderValue()
sb.toString().removePrefix("\n") sb.toString().removePrefix("\n")
} }
+11 -11
View File
@@ -12,17 +12,17 @@ org.commonmark:commonmark:0.24.0=runtimeClasspath,testRuntimeClasspath
org.fusesource.jansi:jansi:2.4.1=runtimeClasspath,testRuntimeClasspath org.fusesource.jansi:jansi:2.4.1=runtimeClasspath,testRuntimeClasspath
org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.sdk:graal-sdk:23.0.6=runtimeClasspath,testRuntimeClasspath
org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath org.graalvm.truffle:truffle-api:23.0.6=runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-reflect:1.7.10=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:2.0.21=runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.7.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib:2.0.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.1=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-html-jvm:0.11.0=runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-bom:1.5.1=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-bom:1.8.0=runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.5.1=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.8.0=runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core:1.5.1=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-core:1.8.0=runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.5.1=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.8.0=runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1=runtimeClasspath,testRuntimeClasspath org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0=runtimeClasspath,testRuntimeClasspath
org.jetbrains:annotations:13.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains:annotations:13.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jline:jline-native:3.23.0=runtimeClasspath,testRuntimeClasspath org.jline:jline-native:3.23.0=runtimeClasspath,testRuntimeClasspath
org.jline:jline-reader:3.23.0=runtimeClasspath,testRuntimeClasspath org.jline:jline-reader:3.23.0=runtimeClasspath,testRuntimeClasspath
+2 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@ dependencies {
api(projects.pklConfigJava) api(projects.pklConfigJava)
api(projects.pklCore) api(projects.pklCore)
api(projects.pklDoc) api(projects.pklDoc)
api(projects.pklCommons)
// used by `pklFatJar` plugin (ideally this would be inferred automatically) // used by `pklFatJar` plugin (ideally this would be inferred automatically)
firstPartySourcesJars(project(":pkl-cli", "sourcesJar")) firstPartySourcesJars(project(":pkl-cli", "sourcesJar"))