Split maven artifacts into component libraries#4031
Conversation
* The Loader API lives under java/api. * The current native endpoint for the Prism shared library lives under java/native. * The WASM build and binding lives under java/wasm. The libraries will be released together but can be developed and snapshotted independently. Users that copy the source from the previous java/ will want to grab both java/api/src/main/java and java/native/src/main/java contents.
This uses the JRuby rake-maven-plugin to generate the templates as part of the Maven build. The generated output for the Java templates will be under java/api/target/generated-sources/java.
|
|
|
@eregon Perhaps a different artifact or perhaps a sibling API within the same artifact. I have not decided what would be cleanest. It seems like the ideal case would be that the API just includes empty elements for non-semantic elements when those are not enabled by the backend. |
|
For example modifying Loader to handle both "all fields" and "only semantic fields" will not fly, because the Java fields of the nodes need to reflect the set of fields chosen (or if always including all fields then it's a huge memory overhead). |
|
A different artifact seems the cleanest to me, also because each of these 2 artifacts would then depend on either |
Regarding naming, But, since all artifacts are either "all fields" or "only-semantic fields" I think separate prefixes would be best. So I'd suggest this:
|
|
In terms of dependencies would there be any between those artifacts? Or rather the users would pick:
|
We can bikeshed the naming later.
Everyone on the Java side of things will use |
|
Latest patch cleans up some path locations in the CI builds. The "build java*" jobs use make which uses the rake-compiler JavaExtensionTask to build, but that plugin does not have a way to fetch Maven dependencies needed like JUnit and Chicory. The make build for the Java API should not be using the extension plugin (which is designed for building JRuby extensions that have no other dependencies) and instead should use the Maven build, but I'm still sorting out where that's all done. |
d5ab64f to
2b6c107
Compare
|
Bit of a chicken and egg issue trying to get the generated parts of the Java build in place:
I'll play with different configurations to figure out an appropriate sequence and hopefully get all those steps to work in both the maven builds and the rake builds. |
6745e86 to
d0d894c
Compare
d0d894c to
1983383
Compare
#4031 (comment) is not just about the name of that one but the general organization, I think that makes sense to discuss now. It doesn't need to block this PR, but that's an important discussion and architecture point to decide early on. |
911edde to
e2e78c8
Compare
The jruby-complete naming was done a long time ago. I probably wouldn't use that naming now.
That's eight artifacts. If we also are publishing separate artifacts for every identifier form, that would be 24 artifacts. I think that's overkill. There are better ways to design the API to have optional fields in the AST, such as by having a set of full non-semantic AST subclass nodes that can be created by the full non-semantic parser build. The AST would look the same unless you require the non-semantic data, and if you don't it's the simpler API that doesn't include those fields. |
Yes, and of course they can be created as needs arise, for now a subset is fine of course, but the general naming needs to take the fields distinction into account somehow.
No, semantic implies RubySymbol (or byte[] if you prefer that for JRuby), and non-semantic implies either j.l.String or byte[] (whatever is best for general API users, still unclear at this stage), so it's still just 8. |
There's a lot of chicken-and-egg issues with trying to have Maven do all the steps for the Java artifact builds right now, so back off and require that templates (and WASM) are generated before the Maven builds of the relevant modules.
01093a6 to
0008f5e
Compare
0008f5e to
f369cab
Compare
84bb9c9 to
32661ee
Compare
| "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", |
There was a problem hiding this comment.
Is it necessary to put them under target/generated-sources instead of java/api/src/main/java?
I saw the docs mention mvn clean cleans that, but is that actually useful? There is rake clean and also the most common case is probably to run rake templates to update the generated files rather than cleaning.
This is the script used to import the .java files in TruffleRuby, it'd be nice if we don't have to manually merge from different folders.
I think it's also nicer in an editor when files in the same package are siblings on the filesystem.
There was a problem hiding this comment.
target/generated-sources is the standard location for sources generated by the Maven build, but after I reverted to generating outside of the build I'm not sure if that fits. I'll look into alternatives.
There was a problem hiding this comment.
Right but the sources are not generated by the Maven build here, so it seems better under java/api/src/main/java/org/ruby_lang/prism
|
The nesting is quite deep with Maven, e.g. I looked and found there is: So it'd be Could you try that if it doesn't cause any issue with the Maven plugins used? |
What you landed on looks good to me, i.e. require to run |
The layout I used is standard Maven layout requiring no configuration.
So only
If we generate sources into src/main/java-templates (perhaps preferable to target/generated-sources) and add
The generated C sources do go into Perhaps it would be easiest for you if the TR test build saved an archive of sources?
Actually, the
We can set up a
There may be test-time dependencies in the future, such as on JUnit for testing. JavaExtensionTask will neither be able to build nor run those tests. It already can't verify the wasm component because it knows nothing of dependencies on JUnit and JRuby for testing nor Chicory for the build. It's just inadequate for non-trivial Java projects. Verification that everything builds and tests should be done by a Maven build. |
This PR will move all Java-related components under the
java/dir and begin splitting up the aggregateprism-parserartifact into component libraries:prism-parser-api, underjava/apiis theLoaderAPI and support classes.prism-parser-native, underjava/nativeis the native JNI binding for the Prism shared library.prism-parser-wasmunderjava/wasmis the WASM-based binding of the Prism library.There will be at least two more components added to this list, either as part of this PR or as separate work.
prism-parser-complete, a build of the WASM binding that includes non-semantic information like comments and line numbers.This will likely require some enhancements in the API module to support these other elements. This will also be the basis for the JRuby version of the Ruby-based Prism parser API.
prism-parser-native-<platform>or similar will handle shipping pre-built native binaries for the JNI backend.