mirror of
https://github.com/apple/pkl.git
synced 2026-06-08 23:02:45 +02:00
Add ResourceReaders#fromServiceProviders to preconfigured evaluator (#1094)
The preconfigured evaluator currently adds module key factories from service providers, but not resource readers. This means that users of pkl-spring, for example, cannot add custom resource readers. This is also inconsistent (in the preconfigured evaluator, `import` can use custom schemes, but not `read`).
This commit is contained in:
@@ -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.
|
||||||
@@ -91,6 +91,7 @@ public final class EvaluatorBuilder {
|
|||||||
* <li>{@link ResourceReaders#https}
|
* <li>{@link ResourceReaders#https}
|
||||||
* <li>{@link ResourceReaders#pkg}
|
* <li>{@link ResourceReaders#pkg}
|
||||||
* <li>{@link ResourceReaders#projectpackage}
|
* <li>{@link ResourceReaders#projectpackage}
|
||||||
|
* <li>{@link ResourceReaders#fromServiceProviders}
|
||||||
* <li>{@link System#getProperties}
|
* <li>{@link System#getProperties}
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@@ -108,6 +109,7 @@ public final class EvaluatorBuilder {
|
|||||||
.addResourceReader(ResourceReaders.https())
|
.addResourceReader(ResourceReaders.https())
|
||||||
.addResourceReader(ResourceReaders.pkg())
|
.addResourceReader(ResourceReaders.pkg())
|
||||||
.addResourceReader(ResourceReaders.projectpackage())
|
.addResourceReader(ResourceReaders.projectpackage())
|
||||||
|
.addResourceReaders(ResourceReaders.fromServiceProviders())
|
||||||
.addModuleKeyFactory(ModuleKeyFactories.standardLibrary);
|
.addModuleKeyFactory(ModuleKeyFactories.standardLibrary);
|
||||||
|
|
||||||
if (!TruffleOptions.AOT) {
|
if (!TruffleOptions.AOT) {
|
||||||
|
|||||||
@@ -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,6 +21,7 @@ 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.pkl.core.project.Project
|
import org.pkl.core.project.Project
|
||||||
|
import org.pkl.core.resource.TestResourceReader
|
||||||
|
|
||||||
class EvaluatorBuilderTest {
|
class EvaluatorBuilderTest {
|
||||||
@Test
|
@Test
|
||||||
@@ -35,6 +36,12 @@ class EvaluatorBuilderTest {
|
|||||||
assertThat(builder.externalProperties).isEqualTo(System.getProperties())
|
assertThat(builder.externalProperties).isEqualTo(System.getProperties())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `preconfigured builder adds resource readers from service providers`() {
|
||||||
|
val builder = EvaluatorBuilder.preconfigured()
|
||||||
|
assertThat(builder.resourceReaders).hasAtLeastOneElementOfType(TestResourceReader::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `unconfigured builder does not set process env vars`() {
|
fun `unconfigured builder does not set process env vars`() {
|
||||||
val builder = EvaluatorBuilder.unconfigured()
|
val builder = EvaluatorBuilder.unconfigured()
|
||||||
|
|||||||
Reference in New Issue
Block a user