mirror of
https://github.com/apple/pkl.git
synced 2026-03-30 05:41:54 +02:00
Moving to java.net.http.HttpClient brings many benefits, including HTTP/2 support and the ability to make asynchronous requests. Major additions and changes: - Introduce a lightweight org.pkl.core.http.HttpClient API. This keeps some flexibility and allows to enforce behavior such as setting the User-Agent header. - Provide an implementation that delegates to java.net.http.HttpClient. - Use HttpClient for all HTTP(s) requests across the codebase. This required adding an HttpClient parameter to constructors and factory methods of multiple classes, some of which are public APIs. - Manage CA certificates per HTTP client instead of per JVM. This makes it unnecessary to set JVM-wide system/security properties and default SSLSocketFactory's. - Add executor v2 options to the executor SPI - Add pkl-certs as a new artifact, and remove certs from pkl-commons-cli artifact Each HTTP client maintains its own connection pool and SSLContext. For efficiency reasons, It's best to reuse clients whenever feasible. To avoid memory leaks, clients are not stored in static fields. HTTP clients are expensive to create. For this reason, EvaluatorBuilder defaults to a "lazy" client that creates the underlying java.net.http.HttpClient on the first send (which may never happen).
66 lines
1.9 KiB
Kotlin
66 lines
1.9 KiB
Kotlin
plugins {
|
|
pklAllProjects
|
|
pklJavaLibrary
|
|
pklPublishLibrary
|
|
pklKotlinTest
|
|
}
|
|
|
|
val pklDistributionCurrent: Configuration by configurations.creating
|
|
val pklDistribution025: Configuration by configurations.creating
|
|
|
|
// Because pkl-executor doesn't depend on other Pkl modules
|
|
// (nor has overlapping dependencies that could cause a version conflict),
|
|
// clients are free to use different versions of pkl-executor and (say) pkl-config-java-all.
|
|
// (Pkl distributions used by EmbeddedExecutor are isolated via class loaders.)
|
|
dependencies {
|
|
pklDistributionCurrent(project(":pkl-config-java", "fatJar"))
|
|
@Suppress("UnstableApiUsage")
|
|
pklDistribution025(libs.pklConfigJavaAll025)
|
|
|
|
implementation(libs.slf4jApi)
|
|
|
|
testImplementation(projects.pklCommonsTest)
|
|
testImplementation(projects.pklCore)
|
|
testImplementation(libs.slf4jSimple)
|
|
}
|
|
|
|
// TODO why is this needed? Without this, we get error:
|
|
// `Entry org/pkl/executor/EmbeddedExecutor.java is a duplicate but no duplicate handling strategy has been set.`
|
|
// However, we do not have multiple of these Java files.
|
|
tasks.named<Jar>("sourcesJar") {
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
named<MavenPublication>("library") {
|
|
pom {
|
|
url.set("https://github.com/apple/pkl/tree/main/pkl-executor")
|
|
description.set("""
|
|
Library for executing Pkl code in a sandboxed environment.
|
|
""".trimIndent())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
srcDir("src/main/java")
|
|
}
|
|
}
|
|
}
|
|
|
|
// this task could be folded into tasks.test by switching to IntelliJ's Gradle test runner
|
|
val prepareTest by tasks.registering {
|
|
// used by EmbeddedExecutorTest
|
|
dependsOn(pklDistributionCurrent, pklDistribution025)
|
|
}
|
|
|
|
tasks.test {
|
|
dependsOn(prepareTest)
|
|
systemProperty("pklDistributionCurrent", pklDistributionCurrent.singleFile)
|
|
systemProperty("pklDistribution025", pklDistribution025.singleFile)
|
|
}
|