Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ local gradleCheckJobs: Mapping<String, GradleCheckJob> = new {
javaVersion = "17.0"
isRelease = false
}
["gradle-check-jdk21"] {
javaVersion = "21.0"
isRelease = false
}
}

jobs {
Expand Down
33 changes: 33 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,24 @@ jobs:
LANG: en_US.UTF-8
docker:
- image: cimg/openjdk:17.0
gradle-check-jdk21:
steps:
- checkout
- run:
command: ./gradlew --info --stacktrace check
name: gradle check
- run:
command: |-
mkdir ~/test-results/
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/ \;
name: Gather test results
when: always
- store_test_results:
path: ~/test-results
environment:
LANG: en_US.UTF-8
docker:
- image: cimg/openjdk:21.0
bench:
steps:
- checkout
Expand Down Expand Up @@ -765,6 +783,9 @@ workflows:
- gradle-check-jdk17:
requires:
- hold
- gradle-check-jdk21:
requires:
- hold
- check-patch-file:
requires:
- hold
Expand All @@ -776,6 +797,7 @@ workflows:
jobs:
- gradle-check-jdk11
- gradle-check-jdk17
- gradle-check-jdk21
- check-patch-file
- bench
- gradle-compatibility
Expand All @@ -788,6 +810,7 @@ workflows:
requires:
- gradle-check-jdk11
- gradle-check-jdk17
- gradle-check-jdk21
- check-patch-file
- bench
- gradle-compatibility
Expand Down Expand Up @@ -820,6 +843,12 @@ workflows:
ignore: /.*/
tags:
only: /^v?\d+\.\d+\.\d+$/
- gradle-check-jdk21:
filters:
branches:
ignore: /.*/
tags:
only: /^v?\d+\.\d+\.\d+$/
- check-patch-file:
filters:
branches:
Expand Down Expand Up @@ -872,6 +901,7 @@ workflows:
requires:
- gradle-check-jdk11
- gradle-check-jdk17
- gradle-check-jdk21
- check-patch-file
- bench
- gradle-compatibility
Expand Down Expand Up @@ -917,6 +947,9 @@ workflows:
- gradle-check-jdk17:
requires:
- hold
- gradle-check-jdk21:
requires:
- hold
- check-patch-file:
requires:
- hold
Expand Down
2 changes: 1 addition & 1 deletion .circleci/jobs/GradleCheckJob.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extends "GradleJob.pkl"

import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.1.0#/Config.pkl"

javaVersion: "11.0"|"17.0"
javaVersion: "11.0"|"17.0"|"21.0"

steps {
new Config.RunStep {
Expand Down
3 changes: 1 addition & 2 deletions buildSrc/src/main/kotlin/BuildInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import java.io.File
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.artifacts.VersionConstraint
import org.gradle.kotlin.dsl.getByType

// `buildInfo` in main build scripts
Expand Down Expand Up @@ -109,7 +108,7 @@ open class BuildInfo(project: Project) {
// only run command once per build invocation
if (project === project.rootProject) {
Runtime.getRuntime()
.exec("git rev-parse --short HEAD", arrayOf(), project.rootDir)
.exec(arrayOf("git", "rev-parse", "--short", "HEAD"), arrayOf(), project.rootDir)
.inputStream.reader().readText().trim()
} else {
project.rootProject.extensions.getByType(BuildInfo::class.java).commitId
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/GradleVersionInfo.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.net.URL
import org.gradle.util.GradleVersion
import groovy.json.JsonSlurper
import java.net.URI

@Suppress("unused")
class GradleVersionInfo(json: Map<String, Any>) {
Expand Down Expand Up @@ -50,18 +50,18 @@ class GradleVersionInfo(json: Map<String, Any>) {

private fun fetchSingle(url: String): GradleVersionInfo {
@Suppress("UNCHECKED_CAST")
return GradleVersionInfo(JsonSlurper().parse(URL(url)) as Map<String, Any>)
return GradleVersionInfo(JsonSlurper().parse(URI(url).toURL()) as Map<String, Any>)
}

private fun fetchSingleOrNull(url: String): GradleVersionInfo? {
@Suppress("UNCHECKED_CAST")
val json = JsonSlurper().parse(URL(url)) as Map<String, Any>
val json = JsonSlurper().parse(URI(url).toURL()) as Map<String, Any>
return if (json.isEmpty()) null else GradleVersionInfo(json)
}

private fun fetchMultiple(url: String): List<GradleVersionInfo> {
@Suppress("UNCHECKED_CAST")
return (JsonSlurper().parse(URL(url)) as List<Map<String, Any>>)
return (JsonSlurper().parse(URI(url).toURL()) as List<Map<String, Any>>)
.map { GradleVersionInfo(it) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ clikt = "3.5.1"
commonMark = "0.+"
downloadTaskPlugin = "4.1.2"
geantyref = "1.+"
googleJavaFormat = "1.15.0"
googleJavaFormat = "1.21.0"
# must not use `+` because used in download URL
graalVm = "22.3.3"
# intentionally empty; replaced by patch file when building pkl-cli macos/aarch64
Expand Down
2 changes: 1 addition & 1 deletion patches/graalVm23.patch
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ index f242210..e2e8ee8 100644
+++ b/gradle/libs.versions.toml
@@ -8,11 +8,11 @@ downloadTaskPlugin = "4.1.2"
geantyref = "1.+"
googleJavaFormat = "1.15.0"
googleJavaFormat = "1.21.0"
# must not use `+` because used in download URL
-graalVm = "22.3.3"
-# intentionally empty; replaced by patch file when building pkl-cli macos/aarch64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,21 @@ class CliJavaCodeGeneratorTest {

val module1PropertiesFile = resourcesDir.resolve("org.mod1.properties")

val module1PropertiesString = module1PropertiesFile.readString()
// use two assertions because java.util.Properties doesn't guarantee order
assertContains(
"""
org.pkl.config.java.mapper.org.mod1\#Person=org.Mod1${dollar}Person
org.pkl.config.java.mapper.org.mod1\#ModuleClass=org.Mod1
"""
.trimIndent(),
module1PropertiesFile.readString()
"""org.pkl.config.java.mapper.org.mod1\#Person=org.Mod1${dollar}Person""",
module1PropertiesString
)
assertContains(
"""org.pkl.config.java.mapper.org.mod1\#ModuleClass=org.Mod1""",
module1PropertiesString
)

val module2PropertiesFile = resourcesDir.resolve("org.mod2.properties")

assertContains(
"""
org.pkl.config.java.mapper.org.mod2\#ModuleClass=org.Mod2
"""
.trimIndent(),
"""org.pkl.config.java.mapper.org.mod2\#ModuleClass=org.Mod2""",
module2PropertiesFile.readString()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ public Optional<Object> read(URI uri) throws IOException {
}

try {
var url = IoUtils.toUrl(uri);
var content = IoUtils.readBytes(url);
var content = IoUtils.readBytes(uri);
return Optional.of(new Resource(uri, content));
} catch (FileNotFoundException e) {
return Optional.empty();
Expand Down
8 changes: 4 additions & 4 deletions pkl-core/src/main/java/org/pkl/core/util/IoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public static String readString(InputStream inputStream) throws IOException {
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
}

public static byte[] readBytes(URL url) throws IOException {
if (HttpUtils.isHttpUrl(url)) {
throw new IllegalArgumentException("Should use HTTP client to GET " + url);
public static byte[] readBytes(URI uri) throws IOException {
if (HttpUtils.isHttpUrl(uri)) {
throw new IllegalArgumentException("Should use HTTP client to GET " + uri);
}
try (var stream = url.openStream()) {
try (var stream = IoUtils.toUrl(uri).openStream()) {
return stream.readAllBytes();
}
}
Expand Down
9 changes: 4 additions & 5 deletions pkl-core/src/test/kotlin/org/pkl/core/util/HttpUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.junit.jupiter.api.assertThrows
import org.pkl.commons.test.FakeHttpResponse
import java.io.IOException
import java.net.URI
import java.net.URL

class HttpUtilsTest {
@Test
Expand All @@ -17,10 +16,10 @@ class HttpUtilsTest {
assertThat(HttpUtils.isHttpUrl(URI("HtTpS://example.com"))).isTrue
assertThat(HttpUtils.isHttpUrl(URI("file://example.com"))).isFalse

assertThat(HttpUtils.isHttpUrl(URL("http://example.com"))).isTrue
assertThat(HttpUtils.isHttpUrl(URL("https://example.com"))).isTrue
assertThat(HttpUtils.isHttpUrl(URL("HtTpS://example.com"))).isTrue
assertThat(HttpUtils.isHttpUrl(URL("file://example.com"))).isFalse
assertThat(HttpUtils.isHttpUrl(URI("http://example.com").toURL())).isTrue
assertThat(HttpUtils.isHttpUrl(URI("https://example.com").toURL())).isTrue
assertThat(HttpUtils.isHttpUrl(URI("HtTpS://example.com").toURL())).isTrue
assertThat(HttpUtils.isHttpUrl(URI("file://example.com").toURL())).isFalse
}

@Test
Expand Down
8 changes: 4 additions & 4 deletions pkl-core/src/test/kotlin/org/pkl/core/util/IoUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -415,20 +415,20 @@ class IoUtilsTest {
@Test
fun `readBytes(URL) does not support HTTP URLs`() {
assertThrows<IllegalArgumentException> {
IoUtils.readBytes(URL("https://example.com"))
IoUtils.readBytes(URI("https://example.com"))
}
assertThrows<IllegalArgumentException> {
IoUtils.readBytes(URL("http://example.com"))
IoUtils.readBytes(URI("http://example.com"))
}
}

@Test
fun `readString(URL) does not support HTTP URLs`() {
assertThrows<IllegalArgumentException> {
IoUtils.readString(URL("https://example.com"))
IoUtils.readString(URI("https://example.com").toURL())
}
assertThrows<IllegalArgumentException> {
IoUtils.readString(URL("http://example.com"))
IoUtils.readString(URI("http://example.com").toURL())
}
}
}
3 changes: 2 additions & 1 deletion pkl-tools/src/dummy/java/org/pkl/tools/Empty.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
*/
// TODO: figure out how to generate javadoc for a shadow jar.
@SuppressWarnings("unused")
public class Empty {
public final class Empty {
private Empty() {}
}