Skip to content

Added information about codegen deps and cli usage #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions codegen-java/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ $ java -cp <classpath-for-pkl-codegen-java> \
src/main/resources/Birds.pkl
----

The CLI jar tool (pkl-codegen-java) has several dependencies to run: pkl-cli-java, kotlin-stdlib and javapoet if you do not already have these dependencies (or pkl-codegen-java.jar) you can download the respective jars at the following urls:

* https://search.maven.org/remote_content?g=com.squareup&a=javapoet&v=RELEASE
* https://search.maven.org/remote_content?g=org.jetbrains.kotlin&a=kotlin-stdlib&v=RELEASE
* https://search.maven.org/remote_content?g=org.pkl-lang&a=pkl-cli-java&v=LATEST
* https://search.maven.org/remote_content?g=org.pkl-lang&a=pkl-codegen-java&v=LATEST

Then you can call the tool with the downloaded jars (either remove the versions from the filenames on download or change the below to include the versions)

[source,shell script]
----
$ java -cp "javapoet.jar;kotlin-stdlib.jar;pkl-cli-java.jar;pkl-codegen-java.jar" org.pkl.codegen.java.Main \
-o generated \
src/main/resources/Birds.pkl
----

You will likely need the --allowed-modules whitelisting depending on the pkl location, also added to the command. Make sure to see the https://github.com/apple/pkl/WINDOWS.adoc[WINDOWS.adoc] if you are on Windows for additional tips.


NOTE: xref:build.gradle.kts[] demonstrates how to generate code with the Gradle plugin.

The following Java code is generated:
Expand Down