Compile support for special FILES - protobuf, Thrift and Avro #1153
Replies: 2 comments 6 replies
-
This is treading into full build system territory :) Something if we get too far users are better of using maven/gradle. I'm fine exploring it but let's see if we can avoid adding it to jbang core as proto buf isn't the only thing one would want. Adding it to //FILES does not sound right as that is supposed to be dumb and direct adding resources to the built result. We have the integration mechanism that lets one have dependency that will be able to hook in after compile but before zipping ...but that is too late for protobuf? |
Beta Was this translation helpful? Give feedback.
-
esbuild is a famous JS/TS transform tool, and it has good feature called loader, and it can help you transform resource to special object. For example, in Jbang script, I use With loader introduced, you can use following code:
Jbang will help to read demo.csv and generate a new Java file called DemoCSV.java, and demo.cvs's content has been inlined into text field, and you just need to invoke DemoCSV.text, that's all. We can design loader alike esbuild, but focus on Java only:
|
Beta Was this translation helpful? Give feedback.
-
Protobuf and gRPC are used widely. If a developer use
//FILES account.proto
in script, it's not just to add file in classpath, and it means to help me compile protobuf and then I can import generated Message class or gRPC class directly. Yes, most developers know how to use Gradle/Maven to compile protobuf, but it's boring work to repeat again. JBang can make this job simple, just//FIES
proto file, and JBang will fix everything for you, and you can use Generated classes and interface directly.Custom resource compile is normal in JavaScript, such as json import, GraphQL import, Yaml import etc, and these resources will be transformed to JS object by plugin during compile, and easy for developer to operate transformed JS object.
Following resource types could be considered at first:
For this case, HTTP resource should be considered, such as
//FILES demo.proto=https://github.com/user/name/demo.proto
. These resources almost act as contract/interface for client/server and are stored on git or registry server.Beta Was this translation helpful? Give feedback.
All reactions