Commit Graph

138 Commits

Author SHA1 Message Date
Daniel Chao 4a25320995 Fix import/read verification when encountering glob wildcards (#1559)
Fixes an issue where the import verifier can possibly throw when
packaging on Windows due to `*` being an invalid filename.
2026-04-29 20:20:49 -07:00
Daniel Chao 2b3603b544 Reformat Kotlin code (#1560)
ktfmt has much improved how it formats Kotlin code. Unfortunately, this
means that whenever we touch a single line in a Kotlin file, we get a
_lot_ more changes thanks to ratcheting now picking up this file for
formatting.

This PR just reformats every single Kotlin file so we don't have to deal
with this churn in future PRs that touch Kotlin code.
2026-04-25 06:14:44 -07:00
Daniel Chao 07c68239b9 Remove lockfiles, manage Gradle dependencies with Dependabot (#1535)
Dependabot currently does not update lockfiles in multi-module projects
(see https://github.com/dependabot/dependabot-core/issues/14633)

To work around this issue, we will simply remove our lockfiles, and
change our version catalog to use fully specified versions.
The removal of lockfiles introduces two issues:

1. It is less visible what our dependency graph is
2. Our builds are potentially non-reproducible

To work around this, two mitigations are in place:

1. Enable `failOnDynamicVersions()`, which causes Gradle to fail the
build if any dependencies declare a version range
2. Enable GitHub dependency submission, which provides insight into the
project SBOM
2026-04-20 09:29:33 -07:00
odenix 4faf35a66a Gradle: Replace legacy buildSrc mechanism with included build (#1524)
Motivation:
buildSrc is a special-case legacy mechanism.
Gradle recommends using an included build named build-logic instead:

https://docs.gradle.org/current/userguide/best_practices_structuring_builds.html#favor_composite_builds

Changes:
- Rename buildSrc/ to build-logic/
  - triggers reformatting
- Replace occurrences of "buildSrc" with "build-logic"
- Include the build-logic build in the main build (via
settings.gradle.kts)
- Apply convention plugins via plugin IDs instead of type-safe accessors
  - small tradeoff compared to buildSrc

Result:
- Faster and more isolated builds
- Build logic behaves like a normal build, making it easier to evolve
and reason about

---------

Co-authored-by: Daniel Chao <dan.chao@apple.com>
2026-04-15 21:37:10 -07:00
odenix 04a9cc90d2 Improve build logic for Kotlin (#1520)
- Enforce Kotlin version via resolution rule (replaces BOM)
  - fail if kotlin-stdlib/kotlin-reflect exceed target version
- Replace kotlin-stdlib-jdk8 with kotlin-stdlib (jdk7/8 are now shims)
- Port pkl-core annotation processor to Java (with Codex)
- removes kotlin-stdlib from its compile classpath for better dependency
hygiene (Java module)
- Downgrade clikt for Kotlin 2.2 compatibility
- Upgrade kotlinx-serialization

---------

Co-authored-by: Daniel Chao <dan.chao@apple.com>
2026-04-15 09:02:42 -07:00
odenix 1ba54f11a9 pkl-parser: Migrate nullness to JSpecify (#1515) 2026-04-14 12:17:17 -07:00
odenix 2d4286ee7b Upgrade JVM toolchain to 25 and Kotlin toolchain to 2.3.20 (#1516)
Motivation
- Enable correct NullAway analysis
- Pick up toolchain fixes and improvements

Toolchains
- Require JDK 25 for JVM toolchain (keep Java 17 runtime compatibility)
- Require Kotlin 2.3.20 for Kotlin toolchain (keep Kotlin 2.2 runtime
compatibility)
- Require JDK 25 for Gradle daemon JVM (via
gradle-daemon-jvm.properties)
- Fix javac and kotlinc warnings from toolchain upgrades

CI
- Bump GitHub workflows to JDK 25

Building Kotlin
- Bump Kotlin language level to 2.2 to match stdlib version
- Consolidate build logic into pklKotlinBase.gradle.kts
- Adopt modern Kotlin plugin syntax
- Fix new kotlinc warnings
- Update ktfmt to 0.62
  - first version compatible with Kotlin 2.3.20
  - changes formatting compared to 0.61
- Replace dependency resolution rule with BOM alignment
  - rule was too broad and interfered with toolchain/runtime separation

Testing
- Expand matrix to JDK 25 (LTS) and 26
- Ensure each matrix task can be run independently
- Fix KotlinCodeGeneratorsTest and EmbeddedExecutorsTest on affected
JDKs
- Disable one test in CliCommandTest on affected JDKs (failure cause
unknown)

Compatibility fixes
- Fix reflective access in DocGenerator on affected JDKs

Build fixes
- Fix misuse of `task.enabled` vs. `report.required`
- Fix `gradlew tasks` on Windows
- Downgrade Spotless to 8.3.0 to (hopefully) work around sporadic
NoClassDefFoundError

Result
- NullAway runs correctly
- Broader JDK test coverage
- More reproducible and potentially faster builds
2026-04-14 11:57:09 -07:00
odenix 2cfd0a0d28 Update JLine to 4.x (#1511)
- Remove dependency org.fusesource.jansi:jansi
- In 4.x, org.fusesource.jansi:jansi was replaced with org.jline:jansi.
Instead of adding this new dependency, this commit replaces Pkl’s single
Jansi usage with custom code that preserves existing behavior. Fixing
existing ANSI quirks is left for a future PR.
- Replace jline-terminal-ansi with jline-terminal-jni
  - In 4.x, only -jni and -ffm are available (-ffm requires Java 22+)
- Configure native-image build for jline-terminal-jni

As updating JLine is delicate, I manually tested `pkl repl` and `jpkl
repl` on Windows 11 (using Windows Terminal) and on Ubuntu, and found no
issues. However, I do not have access to a macOS machine.
2026-04-08 16:25:39 -07:00
odenix 09435af54f Improve Formatter API (#1505)
- pass `GrammarVersion` to constructor instead of passing it to each
`format` method
- replace `format(Path): String` with `format(Reader, Appendable)`
- instead of picking which overloads besides `format(String): String`
might be useful, offer a single generalized method that streams input
and output
- add `@Throws(IOException::class)` to ensure that Java callers can
catch this exception
- deprecate old methods
2026-04-07 14:16:12 -07:00
odenix 99cbd07518 Update GraalVM to 25.0.1 (#1506)
The latest version (25.0.2) no longer supports macos-x64.
2026-04-07 13:21:19 -07:00
odenix 623912eca0 Update msgpack to 0.9.11 and slf4j to 2.x (#1501) 2026-04-06 22:00:07 -07:00
odenix 1251843169 Update Kotlin dependencies (#1498) 2026-04-06 12:06:43 -07:00
odenix 0835c6da82 Update JUnit to 6.x (#1496) 2026-04-06 11:15:55 -07:00
odenix a8c66938e6 Update dependencies (#1492)
Update dependencies by running `./gradlew updateDependencyLocks`. Most
of the updated dependencies are test dependencies.
2026-04-06 08:22:06 -07:00
Jen Basch f23c37a993 Prevent --multiple-file-output-path writes from following symlinks outside the target directory (#1467) 2026-03-25 11:50:20 -07:00
Jen Basch be21c34938 Allow command transformAll functions to perform imports (#1440) 2026-02-25 08:03:53 -08:00
Jen Basch 12915f520f Fix command error and import handling (#1436) 2026-02-24 08:09:25 -08:00
Jen Basch 2ec0baad53 Allow referring to remote project dependencies on the CLI with @-notation (#1434) 2026-02-23 08:52:56 -08:00
Jen Basch a5dc91f0a5 Command flag behavior improvements (#1432)
* Forbid overlap of built-in and command-defined flag names 
* Allow interleaving built-in and command-defined flags on the command
line
* List abbreviated flag names first, matching the behavior of built-in
flags
2026-02-20 12:00:18 -08:00
Jen Basch 08712e8b26 Fix display of evaluation errors thrown by command convert/transformAll (#1431) 2026-02-20 07:51:33 -08:00
Jen Basch e07868b404 Handle lexer errors in pkl format (#1430)
Resolves #1421
2026-02-19 10:00:00 -08:00
Jen Basch 72a57af164 SPICE-0025: pkl run CLI framework (#1367) 2026-02-12 07:53:02 -08:00
Islon Scherer f0449c8330 Add flag to turn power assertions on/off (#1419) 2026-02-03 09:35:16 +01:00
Daniel Chao 03a7676e64 Implement power assertions (#1384)
This adds power assertions to Pkl!

This implements the SPICE described in
https://github.com/apple/pkl-evolution/pull/29

This follows the power assertions style of reporting also found in
Groovy, Kotlin, and others.

* Literal values are not emitted in the diagram
* Stdlib constructors of literals like `List(1, 2)` are also considered
  literals

Power assertions are added to:

* Failing type constraints
* Failing test facts

Power assertions are implemented as a truffle instrument to observe
execution.
When an assertion fails, the instrument is created and the assertion is
run again to observe facts.
This incurs runtime overhead to collect facts, but has no impact on code
in the non-error case.

---------

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2026-01-20 21:41:33 -08:00
Daniel Chao b4bd292511 Handle IOException when creating PklProject.deps.json (#1405)
Fixes an issue that otherwise bubbles up as "An unexpected error has
occured".
2026-01-12 15:08:38 -08:00
Daniel Chao f1c71bc9bb Emit error stack trace on non Pkl exceptions (#1402)
If the thrown error is not a Pkl exception, some internal error
occurred, and we need to emit the stack trace for visibility.
2026-01-12 13:45:39 -08:00
Daniel Chao 6b9c670cfd Add syntax highlighting of Pkl code (#1385)
This adds syntax highlighting of Pkl code!

It adds highlighting for:

* Stack frames within error messages
* CLI REPL (highlights as you type, highlights error output)
* Power assertions (coming in https://github.com/apple/pkl/pull/1384)

This uses the lexer for highlighting. It will highlight strings,
numbers, keywords, but doesn't understand how to highlight nodes like
types, function params, etc.
The reason for this is because a single line of code by itself may not
be grammatically valid.
2026-01-06 10:33:11 -08:00
Stefan M. 0a4281366f Do not throw if output dir is symlink (#1389) 2026-01-05 10:16:32 -08:00
Jen Basch 139f70bb79 Change pkl format --write to exit 0 when formatting violations are found (#1340) 2025-12-05 16:01:09 -08:00
Daniel Chao c2d672e943 Omit superfluous newline when writing formatted content to stdout (#1350)
Fixes an issue where an extra newline is added when writing formatted
code to stdout.

Closes https://github.com/apple/pkl/issues/1346
2025-12-05 09:54:31 -08:00
Daniel Chao 0ff99d31c9 Replace broken references to CircleCI (#1318) 2025-11-14 15:44:59 -08:00
Daniel Chao 219e766003 Make format command write relative paths (#1290) 2025-11-03 09:52:29 -08:00
Daniel Chao 40c88930c5 Normalize paths in pkl format (#1286) 2025-11-03 08:24:04 -08:00
Islon Scherer 7df447924e Coalesce pkl format subcommands into the parent command. (#1263) 2025-10-30 10:08:25 +01:00
Islon Scherer be0142d46b Add grammar compatibility option to the formatter (#1249) 2025-10-28 13:29:08 +01:00
Daniel Chao 98ab741c54 Bump Kotlin to 2.2.20, minimum Kotlin to 2.1 (#1232)
The current version of the kotlin-gradle plugin is not compatible with
Gradle 9.1, causing error `java.lang.NoSuchMethodError:
 'org.gradle.api.Project org.gradle.api.artifacts.ProjectDependency.getDependencyProject()'`

Also, the Kotlin 2.0 language target is deprecated as of Kotlin 2.2.
2025-10-08 21:40:35 -07:00
Jen Basch e230fcf1a9 Follow up for trace pretty printing (#1227) 2025-10-08 09:36:42 -07:00
Daniel Chao 55eac2088b Bump GraalVM to 25.0.0 (#1226)
* Migrate shadow plugin to org.gradleup to correctly bundle Truffle in
  a fat jar
* Switch to GraalVM Community Edition
2025-10-07 21:23:15 -07:00
Steve Salevan cecaf39aff Adds traceMode evaluator setting to support trace() pretty printing (#1100) 2025-10-07 12:31:16 -07:00
Daniel Chao d03a074f63 Bump dependencies (#1225)
* byte-buddy to 1.17.7
* commonmark to 0.26

And also test dependencies (junit, assertj)
2025-10-04 13:59:54 -07:00
Simon Rüegg d1171db3d5 Only format changed files (#1217) 2025-09-19 15:16:32 +02:00
Simon Rüegg f327c8e086 Allow formatting multiple files/directories (#1215)
This makes it easier to work with tools which return a list of file to
format, e.g. to only handle files which have changed in a PR.
2025-09-19 15:13:22 +02:00
Islon Scherer 618c6243c5 Fix bug in format apply (#1211) 2025-09-19 11:28:40 +02:00
Islon Scherer fdc501a35c Implement canonical formatter (#1107)
CLI commands also added: `pkl format check` and `pkl format apply`.
2025-09-17 11:12:04 +02:00
Jen Basch bef0375285 Improve interrupt handling in pkl repl (#1188) 2025-08-29 13:39:49 -07:00
Artem Yarmoliuk af7057b75f Fix shell completion for paths (#1161) 2025-08-26 10:46:54 -07:00
Jen Basch a8806416b9 Correctly handle EOF after unmatched backtick (#1187) 2025-08-25 14:31:26 -07:00
Daniel Chao a779316cc2 Update dependencies (#1184)
Bump test dependencies, and also commonmark
2025-08-21 21:32:56 -07:00
Daniel Chao 7c8c4438d5 Defer noProxy to settings.pkl or PklProject if not set explicitly (#1143)
Fixes an issue where `http.noProxy` settings are ignored.
2025-07-23 10:57:31 -07:00
Daniel Chao 6cd73227a1 Update dependencies (#1128) 2025-07-18 09:29:44 -07:00