mirror of
https://github.com/apple/pkl.git
synced 2026-04-22 08:18:32 +02:00
Add analyze imports libs (SPICE-0001) (#695)
This adds a new feature to build a dependency graph of Pkl programs, following the SPICE outlined in https://github.com/apple/pkl-evolution/pull/2. It adds: * CLI command `pkl analyze imports` * Java API `org.pkl.core.Analyzer` * Pkl stdlib module `pkl:analyze` * pkl-gradle extension `analyze` In addition, it also changes the Gradle plugin such that `transitiveModules` is by default computed from the import graph.
This commit is contained in:
@@ -102,7 +102,6 @@ pkl {
|
||||
evaluators {
|
||||
evalPkl {
|
||||
sourceModules.add(file("module1.pkl"))
|
||||
transitiveModules.from file("module2.pkl")
|
||||
outputFile = layout.buildDirectory.file("module1.yaml")
|
||||
outputFormat = "yaml"
|
||||
}
|
||||
@@ -118,7 +117,6 @@ pkl {
|
||||
evaluators {
|
||||
register("evalPkl") {
|
||||
sourceModules.add(file("module1.pkl"))
|
||||
transitiveModules.from(file("module2.pkl"))
|
||||
outputFile.set(layout.buildDirectory.file("module1.yaml"))
|
||||
outputFormat.set("yaml")
|
||||
}
|
||||
@@ -127,9 +125,6 @@ pkl {
|
||||
----
|
||||
====
|
||||
|
||||
To guarantee correct Gradle up-to-date behavior,
|
||||
`transitiveModules` needs to contain all module files transitively referenced by `sourceModules`.
|
||||
|
||||
For each declared evaluator, the Pkl plugin creates an equally named task.
|
||||
Hence the above evaluator can be run with:
|
||||
|
||||
@@ -691,3 +686,61 @@ The project directories to create packages for.
|
||||
Common properties:
|
||||
|
||||
include::../partials/gradle-common-properties.adoc[]
|
||||
|
||||
[[analyze-imports]]
|
||||
== Analyze Imports
|
||||
|
||||
This feature is the Gradle analogy for the xref:pkl-cli:index.adoc#command-analyze-imports[analyze imports] command in the CLI. It builds a graph of imports of the provided source modules.
|
||||
|
||||
=== Usage
|
||||
|
||||
[tabs]
|
||||
====
|
||||
build.gradle::
|
||||
+
|
||||
[source,groovy]
|
||||
----
|
||||
pkl {
|
||||
analyzers {
|
||||
imports {
|
||||
appConfig {
|
||||
sourceModules.add(file("src/main/resources/appConfig.pkl"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
build.gradle.kts::
|
||||
+
|
||||
[source,kotlin]
|
||||
----
|
||||
pkl {
|
||||
analyzers {
|
||||
imports {
|
||||
register("appConfig") {
|
||||
sourceModules.add(file("src/main/resources/appConfig.pkl"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
=== Configuration Options
|
||||
|
||||
.outputFormat: Property<String>
|
||||
[%collapsible]
|
||||
====
|
||||
Same meaning as <<output-format,outputFormat>> in <<module-evaluation>>.
|
||||
====
|
||||
|
||||
.outputFile: RegularFileProperty<String>
|
||||
[%collapsible]
|
||||
====
|
||||
Same meaning as <<output-file,outputFile>> in <<module-evaluation>>.
|
||||
====
|
||||
|
||||
Common properties:
|
||||
|
||||
include::../partials/gradle-modules-properties.adoc[]
|
||||
|
||||
Reference in New Issue
Block a user