From 08dba29eb535668641e34455bfc6c6c1c471b8c1 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 24 Mar 2026 11:51:15 -0500 Subject: [PATCH 1/2] Generate templated sources under main/java-templates This path avoids the sources getting wiped out during `mvn clean`, since they are not generated during the maven build. This patch also moves the generated WASM build under src/main/wasm since it is really a source file and not a test file. It will not be included in the built artifact. --- .github/workflows/documentation.yml | 2 +- .github/workflows/github-pages.yml | 2 +- .github/workflows/java-wasm-bindings.yml | 2 +- .gitignore | 2 +- Makefile | 4 ++-- docs/configuration.md | 6 +++--- java/.gitignore | 3 +++ java/README.md | 4 ++-- java/api/pom.xml | 2 +- java/wasm/pom.xml | 2 +- java/wasm/src/test/resources/.gitignore | 1 - .../org/ruby_lang/prism/AbstractNodeVisitor.java.erb | 0 .../java-templates}/org/ruby_lang/prism/Loader.java.erb | 0 .../main/java-templates}/org/ruby_lang/prism/Nodes.java.erb | 0 templates/template.rb | 6 +++--- 15 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 java/wasm/src/test/resources/.gitignore rename templates/java/api/{target/generated-sources/java => src/main/java-templates}/org/ruby_lang/prism/AbstractNodeVisitor.java.erb (100%) rename templates/java/api/{target/generated-sources/java => src/main/java-templates}/org/ruby_lang/prism/Loader.java.erb (100%) rename templates/java/api/{target/generated-sources/java => src/main/java-templates}/org/ruby_lang/prism/Nodes.java.erb (100%) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 5aba27ce9a..6aa63e2921 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -36,7 +36,7 @@ jobs: - name: Check C coverage run: doxygen Doxyfile - name: Check Java coverage - run: javadoc -Xdoclint:all,-missing -d doc/java -sourcepath java/api/target/generated-sources/java/:java/api/src/main/java org.ruby_lang.prism + run: javadoc -Xdoclint:all,-missing -d doc/java -sourcepath java/api/src/main/java-templates/:java/api/src/main/java org.ruby_lang.prism - name: Generate Rust documentation run: | bundle exec rake cargo:build diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 79e1d59d1a..c47f55ff3b 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -51,7 +51,7 @@ jobs: - name: Build with Doxygen run: doxygen Doxyfile - name: Build with JavaDoc - run: javadoc -Xdoclint:all,-missing -d doc/java -sourcepath java/api/target/generated-sources/java/:java/api/src/main/java org.ruby_lang.prism + run: javadoc -Xdoclint:all,-missing -d doc/java -sourcepath java/api/src/main/java-templates/:java/api/src/main/java org.ruby_lang.prism - name: Build with rustdoc run: | bundle exec rake cargo:build diff --git a/.github/workflows/java-wasm-bindings.yml b/.github/workflows/java-wasm-bindings.yml index 3f39c7a1d6..7fe24455a7 100644 --- a/.github/workflows/java-wasm-bindings.yml +++ b/.github/workflows/java-wasm-bindings.yml @@ -55,4 +55,4 @@ jobs: - uses: actions/upload-artifact@v7 with: name: prism.wasm - path: java/wasm/src/test/resources/prism.wasm + path: java/wasm/src/main/wasm/prism.wasm diff --git a/.gitignore b/.gitignore index fcdec6fb0a..cddb8cfa25 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,7 @@ out.svg /java/org/ruby_lang/prism/AbstractNodeVisitor.java /java/org/ruby_lang/prism/Loader.java /java/org/ruby_lang/prism/Nodes.java -/java/wasm/src/test/resources/prism.wasm +/java/wasm/src/main/wasm/prism.wasm /lib/prism/compiler.rb /lib/prism/dispatcher.rb /lib/prism/dot_visitor.rb diff --git a/Makefile b/Makefile index 039efee72c..0f6f5264d1 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ all: shared static shared: build/libprism.$(SOEXT) static: build/libprism.a wasm: javascript/src/prism.wasm -java-wasm: java/wasm/src/test/resources/prism.wasm +java-wasm: java/wasm/src/main/wasm/prism.wasm build/libprism.$(SOEXT): $(SHARED_OBJECTS) $(ECHO) "linking $@ with $(CC)" @@ -51,7 +51,7 @@ javascript/src/prism.wasm: Makefile $(SOURCES) $(HEADERS) -Oz -g0 -flto -fdata-sections -ffunction-sections \ -o $@ $(SOURCES) -java/wasm/src/test/resources/prism.wasm: Makefile $(SOURCES) $(HEADERS) +java/wasm/src/main/wasm/prism.wasm: Makefile $(SOURCES) $(HEADERS) $(ECHO) "building $@" $(Q) $(MAKEDIRS) $(@D) $(Q) $(WASI_SDK_PATH)/bin/clang \ diff --git a/docs/configuration.md b/docs/configuration.md index 4b23b7f46d..cc54a7ab98 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -8,9 +8,9 @@ A lot of code in prism's repository is templated from a single configuration fil * `include/prism/node_new.h` - for defining the functions that create the nodes in C * `javascript/src/deserialize.js` - for defining how to deserialize the nodes in JavaScript * `javascript/src/nodes.js` - for defining the nodes in JavaScript -* `java/api/target/generated-sources/java/org/ruby_lang/prism/AbstractNodeVisitor.java` - for defining the visitor interface for the nodes in Java -* `java/api/target/generated-sources/java/org/ruby_lang/prism/Loader.java` - for defining how to deserialize the nodes in Java -* `java/api/target/generated-sources/java/org/ruby_lang/prism/Nodes.java` - for defining the nodes in Java +* `java/api/src/main/java-templates/org/ruby_lang/prism/AbstractNodeVisitor.java` - for defining the visitor interface for the nodes in Java +* `java/api/src/main/java-templates/org/ruby_lang/prism/Loader.java` - for defining how to deserialize the nodes in Java +* `java/api/src/main/java-templates/org/ruby_lang/prism/Nodes.java` - for defining the nodes in Java * `lib/prism/compiler.rb` - for defining the compiler for the nodes in Ruby * `lib/prism/dispatcher.rb` - for defining the dispatch visitors for the nodes in Ruby * `lib/prism/dot_visitor.rb` - for defining the dot visitor for the nodes in Ruby diff --git a/java/.gitignore b/java/.gitignore index a88111250b..e61251f358 100644 --- a/java/.gitignore +++ b/java/.gitignore @@ -1,4 +1,7 @@ +api/src/main/java-templates api/target native/target +wasm/src/main/wasm wasm/target +target .idea diff --git a/java/README.md b/java/README.md index 6380850e00..0dd4215777 100644 --- a/java/README.md +++ b/java/README.md @@ -18,7 +18,7 @@ Sources under `api` are generated from templates in `../templates`. Those source $ PRISM_EXCLUDE_PRETTYPRINT=1 PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS=1 bundle exec rake templates ``` -The files go under `api/target/generated-sources/java` and will be removed with `mvn clean`. +The files are generated under `api/src/main/java-templates` and will not be removed with `mvn clean`. ### WASM build of Prism @@ -28,7 +28,7 @@ The `wasm` project needs a WASM build of Prism to be generated with the followin $ make java-wasm WASI_SDK_PATH= ``` -The files go under `wasm/target/generated-sources/wasm` and will be removed with `mvn clean`. +The build is generated under `wasm/src/main/wasm` and will not be removed with `mvn clean`. ### Build and install diff --git a/java/api/pom.xml b/java/api/pom.xml index 043173366c..396fa33161 100644 --- a/java/api/pom.xml +++ b/java/api/pom.xml @@ -27,7 +27,7 @@ - target/generated-sources/java + src/main/java-templates diff --git a/java/wasm/pom.xml b/java/wasm/pom.xml index cb06a2ac8f..b389c57ed1 100644 --- a/java/wasm/pom.xml +++ b/java/wasm/pom.xml @@ -79,8 +79,8 @@ org.ruby_lang.prism.wasm.PrismParser - src/test/resources/prism.wasm org.ruby_lang.prism.wasm.Prism + src/main/wasm/prism.wasm diff --git a/java/wasm/src/test/resources/.gitignore b/java/wasm/src/test/resources/.gitignore deleted file mode 100644 index 602a758338..0000000000 --- a/java/wasm/src/test/resources/.gitignore +++ /dev/null @@ -1 +0,0 @@ -prism.wasm diff --git a/templates/java/api/target/generated-sources/java/org/ruby_lang/prism/AbstractNodeVisitor.java.erb b/templates/java/api/src/main/java-templates/org/ruby_lang/prism/AbstractNodeVisitor.java.erb similarity index 100% rename from templates/java/api/target/generated-sources/java/org/ruby_lang/prism/AbstractNodeVisitor.java.erb rename to templates/java/api/src/main/java-templates/org/ruby_lang/prism/AbstractNodeVisitor.java.erb diff --git a/templates/java/api/target/generated-sources/java/org/ruby_lang/prism/Loader.java.erb b/templates/java/api/src/main/java-templates/org/ruby_lang/prism/Loader.java.erb similarity index 100% rename from templates/java/api/target/generated-sources/java/org/ruby_lang/prism/Loader.java.erb rename to templates/java/api/src/main/java-templates/org/ruby_lang/prism/Loader.java.erb diff --git a/templates/java/api/target/generated-sources/java/org/ruby_lang/prism/Nodes.java.erb b/templates/java/api/src/main/java-templates/org/ruby_lang/prism/Nodes.java.erb similarity index 100% rename from templates/java/api/target/generated-sources/java/org/ruby_lang/prism/Nodes.java.erb rename to templates/java/api/src/main/java-templates/org/ruby_lang/prism/Nodes.java.erb diff --git a/templates/template.rb b/templates/template.rb index 34c1afb0c6..7638c9c058 100755 --- a/templates/template.rb +++ b/templates/template.rb @@ -684,9 +684,9 @@ def locals "javascript/src/deserialize.js", "javascript/src/nodes.js", "javascript/src/visitor.js", - "java/api/target/generated-sources/java/org/ruby_lang/prism/Loader.java", - "java/api/target/generated-sources/java/org/ruby_lang/prism/Nodes.java", - "java/api/target/generated-sources/java/org/ruby_lang/prism/AbstractNodeVisitor.java", + "java/api/src/main/java-templates/org/ruby_lang/prism/Loader.java", + "java/api/src/main/java-templates/org/ruby_lang/prism/Nodes.java", + "java/api/src/main/java-templates/org/ruby_lang/prism/AbstractNodeVisitor.java", "lib/prism/compiler.rb", "lib/prism/dispatcher.rb", "lib/prism/dot_visitor.rb", From 6a8fdd912f0f1ed405ce5fae1aa3e0f8dfdb3950 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 31 Mar 2026 15:19:19 -0500 Subject: [PATCH 2/2] Remove java/native module The JNI bindings are only used by TruffleRuby, so there's no real value in publishing them to Maven. This avoids us being blocked on figuring out a reliable way to build and publish native artifacts to Maven, something that has never really had a good answer. Instead, we will push the "api" and "wasm" modules for now for JRuby's internal parser use, and prepare to push a second "wasm" module to be used by the gem (with full non-semantic data). The remaining artifacts will be the FFI-based gem (opt-in for JRuby users and built at install time) and the raw native library (bound by JRuby using JNR or Panama and to be built and installed by a JRuby-specific gem a la jruby-prism-parser. --- java/native/pom.xml | 16 ---------------- .../main/java/org/ruby_lang/prism/Parser.java | 16 ---------------- java/pom.xml | 1 - 3 files changed, 33 deletions(-) delete mode 100644 java/native/pom.xml delete mode 100644 java/native/src/main/java/org/ruby_lang/prism/Parser.java diff --git a/java/native/pom.xml b/java/native/pom.xml deleted file mode 100644 index 06f866858c..0000000000 --- a/java/native/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - - org.ruby-lang - prism-parser - 0.0.2-SNAPSHOT - - - prism-parser-native - Java Prism Native - Java native bindings Prism parser shared library - https://github.com/ruby/prism - - diff --git a/java/native/src/main/java/org/ruby_lang/prism/Parser.java b/java/native/src/main/java/org/ruby_lang/prism/Parser.java deleted file mode 100644 index 5c60977d80..0000000000 --- a/java/native/src/main/java/org/ruby_lang/prism/Parser.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.ruby_lang.prism; - -public abstract class Parser { - - @SuppressWarnings("restricted") - public static void loadLibrary(String path) { - System.load(path); - } - - public static native byte[] parseAndSerialize(byte[] source, byte[] options); - - public static byte[] parseAndSerialize(byte[] source) { - return parseAndSerialize(source, null); - } - -} diff --git a/java/pom.xml b/java/pom.xml index a8ae65581b..f405af5304 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -50,7 +50,6 @@ api - native wasm