mirror of
https://github.com/apple/pkl.git
synced 2026-04-25 09:48:41 +02:00
pkl-executor: fix loading projects and fix incorrectly thrown PklException
* Load `PklProject` using the same security settings and env vars passed provided via ExecutorSPIOptions * Handle thrown `PklException` from loading `PklProject` and throw `ExecutorSPIException` * Handle thrown `PklException` of older Pkl distributions, converting them into `ExecutorSpiException`
This commit is contained in:
@@ -116,13 +116,22 @@ public final class ExecutorSpiImpl implements ExecutorSpi {
|
||||
.setTimeout(options.getTimeout())
|
||||
.setOutputFormat(options.getOutputFormat())
|
||||
.setModuleCacheDir(options.getModuleCacheDir());
|
||||
if (options.getProjectDir() != null) {
|
||||
var project = Project.loadFromPath(options.getProjectDir().resolve(PKL_PROJECT_FILENAME));
|
||||
builder.setProjectDependencies(project.getDependencies());
|
||||
}
|
||||
|
||||
try (var evaluator = builder.build()) {
|
||||
return evaluator.evaluateOutputText(ModuleSource.path(modulePath));
|
||||
try {
|
||||
if (options.getProjectDir() != null) {
|
||||
var project =
|
||||
Project.loadFromPath(
|
||||
options.getProjectDir().resolve(PKL_PROJECT_FILENAME),
|
||||
securityManager,
|
||||
null,
|
||||
transformer,
|
||||
options.getEnvironmentVariables());
|
||||
builder.setProjectDependencies(project.getDependencies());
|
||||
}
|
||||
|
||||
try (var evaluator = builder.build()) {
|
||||
return evaluator.evaluateOutputText(ModuleSource.path(modulePath));
|
||||
}
|
||||
} catch (PklException e) {
|
||||
throw new ExecutorSpiException(e.getMessage(), e.getCause());
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user