mirror of
https://github.com/apple/pkl.git
synced 2026-04-23 00:38:37 +02:00
@@ -22,7 +22,7 @@ At the same time, anyone configuring your application -- whether that's your use
|
|||||||
+
|
+
|
||||||
At the time of writing, Pkl offers configuration libraries for the JVM runtime, Swift, and also for Golang.
|
At the time of writing, Pkl offers configuration libraries for the JVM runtime, Swift, and also for Golang.
|
||||||
+
|
+
|
||||||
We maintian the following libraries:
|
We maintain the following libraries:
|
||||||
+
|
+
|
||||||
* xref:java-binding:pkl-config-java.adoc[pkl-config-java] for Java compatible languages
|
* xref:java-binding:pkl-config-java.adoc[pkl-config-java] for Java compatible languages
|
||||||
* xref:kotlin-binding:pkl-config-kotlin.adoc[pkl-config-kotlin] for the {uri-kotlin-homepage}[Kotlin] language.
|
* xref:kotlin-binding:pkl-config-kotlin.adoc[pkl-config-kotlin] for the {uri-kotlin-homepage}[Kotlin] language.
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ To run the CLI, execute the library Jar or its `org.pkl.codegen.kotlin.Main` mai
|
|||||||
*Synopsis:* `java -cp <classpath> -jar pkl-codegen-kotlin.jar [<options>] <modules>`
|
*Synopsis:* `java -cp <classpath> -jar pkl-codegen-kotlin.jar [<options>] <modules>`
|
||||||
|
|
||||||
`<modules>`::
|
`<modules>`::
|
||||||
The absolute or relative URIs of the modules to generate classe for.
|
The absolute or relative URIs of the modules to generate classes for.
|
||||||
Relative URIs are resolved against the working directory.
|
Relative URIs are resolved against the working directory.
|
||||||
|
|
||||||
==== Options
|
==== Options
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ Floats support the same comparison and arithmetic operators as integers.
|
|||||||
Float literals with zero fractional part can be safely replaced with integer literals.
|
Float literals with zero fractional part can be safely replaced with integer literals.
|
||||||
For example, it is safe to write `1.3 * 42` instead of `1.3 * 42.0`.
|
For example, it is safe to write `1.3 * 42` instead of `1.3 * 42.0`.
|
||||||
|
|
||||||
Floats can also include the same underscore separater as integers. For example, `1_000.4_400` is a float whose value is equivalent to `1000.4400`.
|
Floats can also include the same underscore separator as integers. For example, `1_000.4_400` is a float whose value is equivalent to `1000.4400`.
|
||||||
|
|
||||||
TIP: As integers are more convenient to use than floats with zero fractional part, we recommend to require `x: Number` instead of `x: Float` in type annotations.
|
TIP: As integers are more convenient to use than floats with zero fractional part, we recommend to require `x: Number` instead of `x: Float` in type annotations.
|
||||||
|
|
||||||
@@ -3363,7 +3363,7 @@ list3 = List(1, "x", 5.min, List(1, 2, 3)) // <3>
|
|||||||
----
|
----
|
||||||
<1> result: empty list
|
<1> result: empty list
|
||||||
<2> result: list of length 3
|
<2> result: list of length 3
|
||||||
<3> result: heterogenous list whose last element is another list
|
<3> result: heterogeneous list whose last element is another list
|
||||||
|
|
||||||
To concatenate lists, use the `+` operator:
|
To concatenate lists, use the `+` operator:
|
||||||
|
|
||||||
@@ -3420,7 +3420,7 @@ res4 = Set(1, "x", 5.min, List(1, 2, 3)) // <4>
|
|||||||
<1> result: empty set
|
<1> result: empty set
|
||||||
<2> result: set of length 3
|
<2> result: set of length 3
|
||||||
<3> result: same set of length 3
|
<3> result: same set of length 3
|
||||||
<4> result: heterogenous set that contains a list as its last element
|
<4> result: heterogeneous set that contains a list as its last element
|
||||||
|
|
||||||
To compute the union of sets, use the `+` operator:
|
To compute the union of sets, use the `+` operator:
|
||||||
|
|
||||||
@@ -3836,7 +3836,7 @@ More complex union types can be formed:
|
|||||||
foo: List<Boolean|Number|String>|Bird
|
foo: List<Boolean|Number|String>|Bird
|
||||||
----
|
----
|
||||||
|
|
||||||
Union types have no implicit default values, but an explicit type can be choosen using a `*` marker:
|
Union types have no implicit default values, but an explicit type can be chosen using a `*` marker:
|
||||||
[source%parsed,{pkl}]
|
[source%parsed,{pkl}]
|
||||||
----
|
----
|
||||||
foo: "a"|"b" // undefined. Will throw an error if not amended
|
foo: "a"|"b" // undefined. Will throw an error if not amended
|
||||||
@@ -3997,7 +3997,7 @@ pigeon: Bird = new {
|
|||||||
----
|
----
|
||||||
<1> Restricts `name` to have at least three characters.
|
<1> Restricts `name` to have at least three characters.
|
||||||
<2> The name of the bird (`this`) should not be the same as the name of the `parent`.
|
<2> The name of the bird (`this`) should not be the same as the name of the `parent`.
|
||||||
<3> Note how `parent` is different from `name`. If they were the same, we would be thrown a contraint error.
|
<3> Note how `parent` is different from `name`. If they were the same, we would be thrown a constraint error.
|
||||||
|
|
||||||
In the following example, we define a `Bird` with a name of only two characters.
|
In the following example, we define a `Bird` with a name of only two characters.
|
||||||
|
|
||||||
@@ -5024,7 +5024,7 @@ To answer this question, Pkl follows these steps:
|
|||||||
If a match is found, this is the answer.
|
If a match is found, this is the answer.
|
||||||
. Search the `pkl.base` module for a top-level definition of method `x`.
|
. Search the `pkl.base` module for a top-level definition of method `x`.
|
||||||
If a match is found, this is the answer.
|
If a match is found, this is the answer.
|
||||||
. Seach the class inheritance chain of `this`, starting with the class of `this`
|
. Search the class inheritance chain of `this`, starting with the class of `this`
|
||||||
and continuing upwards until and including class `Any`, for a method named `x.`
|
and continuing upwards until and including class `Any`, for a method named `x.`
|
||||||
If a match is found, this is the answer.
|
If a match is found, this is the answer.
|
||||||
. Throw a "method `x` not found" error.
|
. Throw a "method `x` not found" error.
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ This command also takes <<common-options, common options>>.
|
|||||||
[[command-server]]
|
[[command-server]]
|
||||||
=== `pkl server`
|
=== `pkl server`
|
||||||
|
|
||||||
*Synopsys:* `pkl server`
|
*Synopsis:* `pkl server`
|
||||||
|
|
||||||
Run as a server that communicates over standard input/output.
|
Run as a server that communicates over standard input/output.
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ This option is used for embedding Pkl in an external client, such as xref:swift:
|
|||||||
[[command-test]]
|
[[command-test]]
|
||||||
=== `pkl test`
|
=== `pkl test`
|
||||||
|
|
||||||
*Synopsys:* `pkl test [<options>] [<modules>]`
|
*Synopsis:* `pkl test [<options>] [<modules>]`
|
||||||
|
|
||||||
Evaluate the given `<modules>` as _tests_, producing a test report and appropriate exit code.
|
Evaluate the given `<modules>` as _tests_, producing a test report and appropriate exit code.
|
||||||
|
|
||||||
@@ -410,7 +410,7 @@ This command also takes <<common-options, common options>>.
|
|||||||
[[command-repl]]
|
[[command-repl]]
|
||||||
=== `pkl repl`
|
=== `pkl repl`
|
||||||
|
|
||||||
*Synopsys:* `pkl repl [<options>]`
|
*Synopsis:* `pkl repl [<options>]`
|
||||||
|
|
||||||
Start a REPL session.
|
Start a REPL session.
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ The cache directory for storing packages.
|
|||||||
.--no-cache
|
.--no-cache
|
||||||
[%collapsible]
|
[%collapsible]
|
||||||
====
|
====
|
||||||
Disable cacheing of packages.
|
Disable caching of packages.
|
||||||
====
|
====
|
||||||
|
|
||||||
.-e, --env-var
|
.-e, --env-var
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ Default: `false` +
|
|||||||
Whether to ignore expected example files and generate them again.
|
Whether to ignore expected example files and generate them again.
|
||||||
====
|
====
|
||||||
|
|
||||||
Common propeties:
|
Common properties:
|
||||||
|
|
||||||
include::../partials/gradle-common-properties.adoc[]
|
include::../partials/gradle-common-properties.adoc[]
|
||||||
|
|
||||||
@@ -688,6 +688,6 @@ Example: `projectDirectories.from(file("pkl-config/""))` +
|
|||||||
The project directories to create packages for.
|
The project directories to create packages for.
|
||||||
====
|
====
|
||||||
|
|
||||||
Common propeties:
|
Common properties:
|
||||||
|
|
||||||
include::../partials/gradle-common-properties.adoc[]
|
include::../partials/gradle-common-properties.adoc[]
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ If `null`, defaults to `~/.pkl/cache`.
|
|||||||
[%collapsible]
|
[%collapsible]
|
||||||
====
|
====
|
||||||
Default: `false` +
|
Default: `false` +
|
||||||
Disable cacheing of packages.
|
Disable caching of packages.
|
||||||
====
|
====
|
||||||
|
|
||||||
.modulePath: ConfigurableFileCollection
|
.modulePath: ConfigurableFileCollection
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ myFoo1: Foo = new Foo { foo = "bar" } // <1>
|
|||||||
myFoo2 = new Foo { foo = "bar" } // <2>
|
myFoo2 = new Foo { foo = "bar" } // <2>
|
||||||
----
|
----
|
||||||
<1> Unnecessary `new Foo { ... }`
|
<1> Unnecessary `new Foo { ... }`
|
||||||
<2> Unless amending/extendinge a module where `myFoo2` is already defined, `myFoo2` is effectively the `unknown` type, i.e. `myFoo2: unknown`.
|
<2> Unless amending/extending a module where `myFoo2` is already defined, `myFoo2` is effectively the `unknown` type, i.e. `myFoo2: unknown`.
|
||||||
|
|
||||||
== Comments
|
== Comments
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ Add a single space after `///`.
|
|||||||
|
|
||||||
[source%parsed,{pkl}]
|
[source%parsed,{pkl}]
|
||||||
----
|
----
|
||||||
/// The time alotted for eating lunch.
|
/// The time allotted for eating lunch.
|
||||||
///
|
///
|
||||||
/// Note:
|
/// Note:
|
||||||
/// * Hamburgers typically take longer to eat than salad.
|
/// * Hamburgers typically take longer to eat than salad.
|
||||||
@@ -300,7 +300,7 @@ A line comment may also be placed at the end of a line, as long as the line does
|
|||||||
[source%tested,{pkl}]
|
[source%tested,{pkl}]
|
||||||
----
|
----
|
||||||
/// Designates whether it is zebra party time.
|
/// Designates whether it is zebra party time.
|
||||||
partyTime: Booleean // TODO: Add constraints here?
|
partyTime: Boolean // TODO: Add constraints here?
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Block comments
|
=== Block comments
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class ProjectCommand(helpLink: String) :
|
|||||||
This command runs a project's api tests, as defined by `apiTests` in `PklProject`.
|
This command runs a project's api tests, as defined by `apiTests` in `PklProject`.
|
||||||
Additionally, it verifies that all imports resolve to paths that are local to the project.
|
Additionally, it verifies that all imports resolve to paths that are local to the project.
|
||||||
|
|
||||||
Finally, this command writes the folowing artifacts into the output directory specified by the output path.
|
Finally, this command writes the following artifacts into the output directory specified by the output path.
|
||||||
|
|
||||||
- `name@version` - dependency metadata$NEWLINE
|
- `name@version` - dependency metadata$NEWLINE
|
||||||
- `name@version.sha256` - dependency metadata's SHA-256 checksum$NEWLINE
|
- `name@version.sha256` - dependency metadata's SHA-256 checksum$NEWLINE
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `disabling cacheing is an error`(@TempDir tempDir: Path) {
|
fun `disabling caching is an error`(@TempDir tempDir: Path) {
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliDownloadPackageCommand(
|
||||||
baseOptions = CliBaseOptions(workingDir = tempDir, noCache = true),
|
baseOptions = CliBaseOptions(workingDir = tempDir, noCache = true),
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class CliMainTest {
|
|||||||
private val cmd = RootCommand("pkl", "pkl version 1", "").subcommands(evalCmd)
|
private val cmd = RootCommand("pkl", "pkl version 1", "").subcommands(evalCmd)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `duplicate CLI option produces meaningful errror message`(@TempDir tempDir: Path) {
|
fun `duplicate CLI option produces meaningful error message`(@TempDir tempDir: Path) {
|
||||||
val inputFile = tempDir.resolve("test.pkl").writeString("").toString()
|
val inputFile = tempDir.resolve("test.pkl").writeString("").toString()
|
||||||
|
|
||||||
assertThatCode {
|
assertThatCode {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class CliProjectPackagerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `missing PklProject when explict dir is provided`(@TempDir tempDir: Path) {
|
fun `missing PklProject when explicit dir is provided`(@TempDir tempDir: Path) {
|
||||||
val packager =
|
val packager =
|
||||||
CliProjectPackager(
|
CliProjectPackager(
|
||||||
CliBaseOptions(workingDir = tempDir),
|
CliBaseOptions(workingDir = tempDir),
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class CliProjectResolverTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `missing PklProject when explict dir is provided`(@TempDir tempDir: Path) {
|
fun `missing PklProject when explicit dir is provided`(@TempDir tempDir: Path) {
|
||||||
val packager =
|
val packager =
|
||||||
CliProjectResolver(
|
CliProjectResolver(
|
||||||
CliBaseOptions(),
|
CliBaseOptions(),
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class BaseOptions : OptionGroup() {
|
|||||||
.associate()
|
.associate()
|
||||||
|
|
||||||
val noCache: Boolean by
|
val noCache: Boolean by
|
||||||
option(names = arrayOf("--no-cache"), help = "Disable cacheing of packages")
|
option(names = arrayOf("--no-cache"), help = "Disable caching of packages")
|
||||||
.single()
|
.single()
|
||||||
.flag(default = false)
|
.flag(default = false)
|
||||||
|
|
||||||
|
|||||||
@@ -119,11 +119,11 @@ object PackageServer {
|
|||||||
fun ensureStarted() =
|
fun ensureStarted() =
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
// Crude hack to make sure that parrallel tests don't try and use each others mock server
|
// Crude hack to make sure that parallel tests don't try and use each others mock server
|
||||||
// otherwise you get flaky tests when a server instance is shutdown by one set of tests
|
// otherwise you get flaky tests when a server instance is shutdown by one set of tests
|
||||||
// while another set of tests is still relying on it.
|
// while another set of tests is still relying on it.
|
||||||
// Side effect is that tests that spin up a mock package server are now serialised, rather
|
// Side effect is that tests that spin up a mock package server are now serialised, rather
|
||||||
// than running in parrallel. But that seems like a reasonable tradeoff to avoid flaky
|
// than running in parallel. But that seems like a reasonable tradeoff to avoid flaky
|
||||||
// tests.
|
// tests.
|
||||||
for (i in 1..20) {
|
for (i in 1..20) {
|
||||||
try {
|
try {
|
||||||
@@ -134,7 +134,7 @@ object PackageServer {
|
|||||||
return@synchronized
|
return@synchronized
|
||||||
} catch (_: BindException) {
|
} catch (_: BindException) {
|
||||||
println(
|
println(
|
||||||
"Port $PORT in use after $i/20 attempt(s), probably another test running in parrallel. Sleeping for 1 second and trying again"
|
"Port $PORT in use after $i/20 attempt(s), probably another test running in parallel. Sleeping for 1 second and trying again"
|
||||||
)
|
)
|
||||||
Thread.sleep(1000)
|
Thread.sleep(1000)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.pkl.core.PClassInfo;
|
|||||||
* for every parameterization of the target type. Once created, the converter is cached for later
|
* for every parameterization of the target type. Once created, the converter is cached for later
|
||||||
* use, and the factory is never again invoked for the same parameterized target type.
|
* use, and the factory is never again invoked for the same parameterized target type.
|
||||||
*
|
*
|
||||||
* <p>For best performace, all introspection of target types (for example using {@link Reflection})
|
* <p>For best performance, all introspection of target types (for example using {@link Reflection})
|
||||||
* should happen in the factory rather then the returned converters.
|
* should happen in the factory rather then the returned converters.
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
package org.pkl.core;
|
package org.pkl.core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SecurityManagerException declares that a violation occured during an external i/o operation.
|
* A SecurityManagerException declares that a violation occurred during an external i/o operation.
|
||||||
*
|
*
|
||||||
* <p>{@link SecurityManagerException#getMessage()} is passed to users when errors arise.
|
* <p>{@link SecurityManagerException#getMessage()} is passed to users when errors arise.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public final class ValueRenderers {
|
|||||||
* Creates a renderer for {@link java.util.Properties} file format. If {@code omitNullProperties}
|
* Creates a renderer for {@link java.util.Properties} file format. If {@code omitNullProperties}
|
||||||
* is {@code true}, object properties and map entries whose value is {@code null} will not be
|
* is {@code true}, object properties and map entries whose value is {@code null} will not be
|
||||||
* rendered. If {@code restrictCharset} is {@code true} characters outside the printable US-ASCII
|
* rendered. If {@code restrictCharset} is {@code true} characters outside the printable US-ASCII
|
||||||
* charset range will be rendererd as Unicode escapes (see
|
* charset range will be rendered as Unicode escapes (see
|
||||||
* https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.3).
|
* https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.3).
|
||||||
*/
|
*/
|
||||||
public static ValueRenderer properties(
|
public static ValueRenderer properties(
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public abstract class GeneratorPredicateMemberNode extends GeneratorMemberNode {
|
|||||||
var visitedKeys = EconomicSets.create();
|
var visitedKeys = EconomicSets.create();
|
||||||
|
|
||||||
// do our own traversal instead of relying on `VmAbstractObject.force/iterateMemberValues`
|
// do our own traversal instead of relying on `VmAbstractObject.force/iterateMemberValues`
|
||||||
// (more efficent and we don't want to execute `predicateNode` behind Truffle boundary)
|
// (more efficient and we don't want to execute `predicateNode` behind Truffle boundary)
|
||||||
for (var owner = parent; owner != null; owner = owner.getParent()) {
|
for (var owner = parent; owner != null; owner = owner.getParent()) {
|
||||||
var entries = EconomicMaps.getEntries(owner.getMembers());
|
var entries = EconomicMaps.getEntries(owner.getMembers());
|
||||||
while (entries.advance()) {
|
while (entries.advance()) {
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ public final class ModuleKeys {
|
|||||||
protected Pair<String, String> parseDependencyNotation(String importPath) {
|
protected Pair<String, String> parseDependencyNotation(String importPath) {
|
||||||
var idx = importPath.indexOf('/');
|
var idx = importPath.indexOf('/');
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
// treat named dependency wihout a subpath as the root path.
|
// treat named dependency without a subpath as the root path.
|
||||||
// i.e. resolve to `@foo` to `package://example.com/foo@1.0.0#/`
|
// i.e. resolve to `@foo` to `package://example.com/foo@1.0.0#/`
|
||||||
return Pair.of(importPath.substring(1), "/");
|
return Pair.of(importPath.substring(1), "/");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ class PackageResolvers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves packages, cacheing them to disk.
|
* Resolves packages, caching them to disk.
|
||||||
*
|
*
|
||||||
* <p>Uses the built-in zip file system in {@link jdk.nio.zipfs} for reading files from the zip
|
* <p>Uses the built-in zip file system in {@link jdk.nio.zipfs} for reading files from the zip
|
||||||
* archive.
|
* archive.
|
||||||
@@ -480,12 +480,12 @@ class PackageResolvers {
|
|||||||
PackageUri packageUri, URI requestUri, @Nullable Checksums checksums)
|
PackageUri packageUri, URI requestUri, @Nullable Checksums checksums)
|
||||||
throws IOException, SecurityManagerException {
|
throws IOException, SecurityManagerException {
|
||||||
var metadataFileName = getLastSegmentName(packageUri) + ".json";
|
var metadataFileName = getLastSegmentName(packageUri) + ".json";
|
||||||
var metdataRelativePath = getRelativePath(packageUri).resolve(metadataFileName);
|
var metadataRelativePath = getRelativePath(packageUri).resolve(metadataFileName);
|
||||||
var cachePath = cacheDir.resolve(metdataRelativePath);
|
var cachePath = cacheDir.resolve(metadataRelativePath);
|
||||||
if (Files.exists(cachePath)) {
|
if (Files.exists(cachePath)) {
|
||||||
return cachePath;
|
return cachePath;
|
||||||
}
|
}
|
||||||
var tmpPath = tmpDir.resolve(metdataRelativePath);
|
var tmpPath = tmpDir.resolve(metadataRelativePath);
|
||||||
try {
|
try {
|
||||||
downloadMetadata(packageUri, requestUri, tmpPath, checksums);
|
downloadMetadata(packageUri, requestUri, tmpPath, checksums);
|
||||||
Files.createDirectories(cachePath.getParent());
|
Files.createDirectories(cachePath.getParent());
|
||||||
@@ -600,7 +600,7 @@ class PackageResolvers {
|
|||||||
var path = getZipFileSystem(uri, checksums).getPath(uri.getUri().getFragment());
|
var path = getZipFileSystem(uri, checksums).getPath(uri.getUri().getFragment());
|
||||||
if (Files.isDirectory(path)) {
|
if (Files.isDirectory(path)) {
|
||||||
if (allowDirectories) {
|
if (allowDirectories) {
|
||||||
// mimick the format that we get when reading a `file:` directory
|
// mimic the format that we get when reading a `file:` directory
|
||||||
try (var paths = Files.list(path)) {
|
try (var paths = Files.list(path)) {
|
||||||
var text =
|
var text =
|
||||||
paths
|
paths
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public final class Project {
|
|||||||
* <p>Evaluates a module's {@code output.value} to allow for embedding a project within a
|
* <p>Evaluates a module's {@code output.value} to allow for embedding a project within a
|
||||||
* template.
|
* template.
|
||||||
*
|
*
|
||||||
* @throws PklException if an error occured while evaluating the project file.
|
* @throws PklException if an error occurred while evaluating the project file.
|
||||||
*/
|
*/
|
||||||
public static Project loadFromPath(
|
public static Project loadFromPath(
|
||||||
Path path,
|
Path path,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import org.pkl.core.util.json.JsonWriter;
|
|||||||
/**
|
/**
|
||||||
* The Java representation of a project's resolved dependency list. Resolved dependencies are stored
|
* The Java representation of a project's resolved dependency list. Resolved dependencies are stored
|
||||||
* as JSON as a sibling file to PklProject. Each key in the JSON file records an entry for each
|
* as JSON as a sibling file to PklProject. Each key in the JSON file records an entry for each
|
||||||
* dependecy via its base URI, and the major version number.
|
* dependency via its base URI, and the major version number.
|
||||||
*
|
*
|
||||||
* <p>A resolved dependency can either be local or remote. A remote dependency will have its
|
* <p>A resolved dependency can either be local or remote. A remote dependency will have its
|
||||||
* checksums recorded, while a local dependency will point to the relative path of the project
|
* checksums recorded, while a local dependency will point to the relative path of the project
|
||||||
@@ -100,7 +100,7 @@ public class ProjectDeps {
|
|||||||
private static EconomicMap<CanonicalPackageUri, Dependency> parseResolvedDependencies(
|
private static EconomicMap<CanonicalPackageUri, Dependency> parseResolvedDependencies(
|
||||||
Object object) throws JsonParseException, URISyntaxException {
|
Object object) throws JsonParseException, URISyntaxException {
|
||||||
if (!(object instanceof JsObject)) {
|
if (!(object instanceof JsObject)) {
|
||||||
throw new FormatException("resolvedDendencies", "object", object.getClass());
|
throw new FormatException("resolvedDependencies", "object", object.getClass());
|
||||||
}
|
}
|
||||||
var jsObj = (JsObject) object;
|
var jsObj = (JsObject) object;
|
||||||
var ret = EconomicMaps.<CanonicalPackageUri, Dependency>create(jsObj.size());
|
var ret = EconomicMaps.<CanonicalPackageUri, Dependency>create(jsObj.size());
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class FileSystemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possibily close this file system. Will not close if the file system was initialized externally
|
* Possibly close this file system. Will not close if the file system was initialized externally
|
||||||
* to Pkl.
|
* to Pkl.
|
||||||
*/
|
*/
|
||||||
private static synchronized void close(Handle fs) throws IOException {
|
private static synchronized void close(Handle fs) throws IOException {
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ objectSpreadDuplicateEntry=\
|
|||||||
Cannot spread object because the enclosing object already has a declaration of entry key `{0}`.
|
Cannot spread object because the enclosing object already has a declaration of entry key `{0}`.
|
||||||
|
|
||||||
objectSpreadDuplicateProperty=\
|
objectSpreadDuplicateProperty=\
|
||||||
Cannot spread object because the enclosing object already has a delcaration of property `{0}`.
|
Cannot spread object because the enclosing object already has a declaration of property `{0}`.
|
||||||
|
|
||||||
cannotSpreadObject=\
|
cannotSpreadObject=\
|
||||||
Cannot spread value of type `{0}` into object of type `{1}`.
|
Cannot spread value of type `{0}` into object of type `{1}`.
|
||||||
@@ -842,7 +842,7 @@ stackOverflow=\
|
|||||||
A stack overflow occurred.
|
A stack overflow occurred.
|
||||||
|
|
||||||
multipleUnionDefaults=\
|
multipleUnionDefaults=\
|
||||||
A type union cannnot have more than one default type.
|
A type union cannot have more than one default type.
|
||||||
|
|
||||||
notAUnion=\
|
notAUnion=\
|
||||||
Only type unions can have a default marker (*).
|
Only type unions can have a default marker (*).
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
–– Pkl Error ––
|
–– Pkl Error ––
|
||||||
A type union cannnot have more than one default type.
|
A type union cannot have more than one default type.
|
||||||
|
|
||||||
x | foo: *Int|*String|*"foo"
|
x | foo: *Int|*String|*"foo"
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
–– Pkl Error ––
|
–– Pkl Error ––
|
||||||
Cannot spread object because the enclosing object already has a delcaration of property `foo`.
|
Cannot spread object because the enclosing object already has a declaration of property `foo`.
|
||||||
|
|
||||||
x | ...source
|
x | ...source
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ property7: Float = 3.14159265359
|
|||||||
/// Rest of the body
|
/// Rest of the body
|
||||||
property8: Int = 0
|
property8: Int = 0
|
||||||
|
|
||||||
/// Sumary
|
/// Summary
|
||||||
/// ```java
|
/// ```java
|
||||||
///
|
///
|
||||||
/// code = 0
|
/// code = 0
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ code = 4 * 10
|
|||||||
</div>
|
</div>
|
||||||
<div class="member-main">
|
<div class="member-main">
|
||||||
<div class="member-signature"><span class="name-decl">property9</span>: <a href="https://pages.github.com/apple/pkl/stdlib/pkl/0.24.0/base/Int.html" class="name-ref">Int</a><span class="context"> (<a href="../modulePropertyComments/index.html" class="name-ref">com.package1.modulePropertyComments</a>)</span></div>
|
<div class="member-signature"><span class="name-decl">property9</span>: <a href="https://pages.github.com/apple/pkl/stdlib/pkl/0.24.0/base/Int.html" class="name-ref">Int</a><span class="context"> (<a href="../modulePropertyComments/index.html" class="name-ref">com.package1.modulePropertyComments</a>)</span></div>
|
||||||
<div class="doc-comment"><p>Sumary</p></div>
|
<div class="doc-comment"><p>Summary</p></div>
|
||||||
<div class="doc-comment expandable hidden collapsed"><pre><code class="language-java">
|
<div class="doc-comment expandable hidden collapsed"><pre><code class="language-java">
|
||||||
code = 0
|
code = 0
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ code = 4 * 10
|
|||||||
</div>
|
</div>
|
||||||
<div class="member-main">
|
<div class="member-main">
|
||||||
<div class="member-signature"><span class="name-decl">property9</span>: <a href="https://pages.github.com/apple/pkl/stdlib/pkl/0.24.0/base/Int.html" class="name-ref">Int</a><a class="member-source-link" href="https://example.com/package1/modulePropertyComments.pkl#L123-L456">Source</a></div>
|
<div class="member-signature"><span class="name-decl">property9</span>: <a href="https://pages.github.com/apple/pkl/stdlib/pkl/0.24.0/base/Int.html" class="name-ref">Int</a><a class="member-source-link" href="https://example.com/package1/modulePropertyComments.pkl#L123-L456">Source</a></div>
|
||||||
<div class="doc-comment"><p>Sumary</p></div>
|
<div class="doc-comment"><p>Summary</p></div>
|
||||||
<div class="doc-comment expandable hidden collapsed"><pre><code class="language-java">
|
<div class="doc-comment expandable hidden collapsed"><pre><code class="language-java">
|
||||||
code = 0
|
code = 0
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ typealias LocalDependency = Project(
|
|||||||
/// When fetching a remote dependency, two HTTPS requests are made.
|
/// When fetching a remote dependency, two HTTPS requests are made.
|
||||||
/// Given dependency URI `package://example.com/foo@0.5.0`, the following requests are made:
|
/// Given dependency URI `package://example.com/foo@0.5.0`, the following requests are made:
|
||||||
///
|
///
|
||||||
/// 1. `GET https://example.com/foo@0.5.0` to retreive the metadata JSON file.
|
/// 1. `GET https://example.com/foo@0.5.0` to retrieve the metadata JSON file.
|
||||||
/// 2. Given the metadata JSON file, make a GET request to the package URI ZIP archive.
|
/// 2. Given the metadata JSON file, make a GET request to the package URI ZIP archive.
|
||||||
///
|
///
|
||||||
/// If this project is published as a package, these dependencies are included within the published
|
/// If this project is published as a package, these dependencies are included within the published
|
||||||
@@ -170,12 +170,12 @@ typealias LocalDependency = Project(
|
|||||||
/// Pkl uses the
|
/// Pkl uses the
|
||||||
/// [minimum version selection algorithm 1](https://research.swtch.com/vgo-mvs#algorithm_1)
|
/// [minimum version selection algorithm 1](https://research.swtch.com/vgo-mvs#algorithm_1)
|
||||||
/// to resolve dependencies.
|
/// to resolve dependencies.
|
||||||
/// A dependency is identfied by its package URI, as well as its major semver number.
|
/// A dependency is identified by its package URI, as well as its major semver number.
|
||||||
///
|
///
|
||||||
/// To determine the resolved dependencies of a project, the following algorithm is applied:
|
/// To determine the resolved dependencies of a project, the following algorithm is applied:
|
||||||
/// 1. Gather all dependencies, both direct and transitive.
|
/// 1. Gather all dependencies, both direct and transitive.
|
||||||
/// 2. For each package's major version, determine the highest declared minor version.
|
/// 2. For each package's major version, determine the highest declared minor version.
|
||||||
/// 3. Write each resolved depenency to sibling file `PklProject.deps.json`.
|
/// 3. Write each resolved dependency to sibling file `PklProject.deps.json`.
|
||||||
dependencies: Mapping<String(!contains("/")), *RemoteDependency|LocalDependency>
|
dependencies: Mapping<String(!contains("/")), *RemoteDependency|LocalDependency>
|
||||||
|
|
||||||
/// If set, controls the base evaluator settings when running the evaluator.
|
/// If set, controls the base evaluator settings when running the evaluator.
|
||||||
@@ -196,7 +196,7 @@ evaluatorSettings: EvaluatorSettings
|
|||||||
/// dependency.
|
/// dependency.
|
||||||
projectFileUri: String = reflect.Module(module).uri
|
projectFileUri: String = reflect.Module(module).uri
|
||||||
|
|
||||||
/// Instantiates a project definintion within the enclosing module.
|
/// Instantiates a project definition within the enclosing module.
|
||||||
///
|
///
|
||||||
/// This is a convenience method for setting [projectFileUri] to the enclosing module's URI.
|
/// This is a convenience method for setting [projectFileUri] to the enclosing module's URI.
|
||||||
///
|
///
|
||||||
@@ -443,7 +443,7 @@ class EvaluatorSettings {
|
|||||||
|
|
||||||
/// Disables the file system cache for `package:` modules.
|
/// Disables the file system cache for `package:` modules.
|
||||||
///
|
///
|
||||||
/// When cacheing is disabled, packages are loaded over the network and stored in memory.
|
/// When caching is disabled, packages are loaded over the network and stored in memory.
|
||||||
noCache: Boolean?
|
noCache: Boolean?
|
||||||
|
|
||||||
/// A collection of jars, zips, or directories to be placed into the module path.
|
/// A collection of jars, zips, or directories to be placed into the module path.
|
||||||
|
|||||||
Reference in New Issue
Block a user