jbang
jbang copied to clipboard
Add main method in build.jbang as build handler
Just alike Cargo build.rs, and main method in build.jbang will be executed before javac compile.
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.google.protobuf:protobuf-java:3.21.5
//SOURCES Hello.java
//FILES user.proto
public class build {
public static void main(String[] args) {
// call protoc command line to compile proto file
}
}
Not following? Can You elaborate?
I'm guessing that he's suggesting a feature where any code in the build file gets (compiled and) executed before doing the compilation of the script. A bit like my build stage proposal I guess.
It's a feature requirement and just for discussion :)
...so the //DEPS is for the build itself not for the app being built ?
...so the //DEPS is for the build itself not for the app being built ?
I think //DEPS is for build and app both. To introduce build dependencies is some complicated for Java. Rust has dependencies, dev-dependencies and build-dependencies.
[build-dependencies]
cc = "1.0.3"
@linux-china my proposal was actually to add an option like //BUILDSTEP build.java (or //BUILDSTAGE or //ONBUILD, name still to be decided) which would point to a separate source file that contains the code to be run before the build of the actual app. That way it can have its own dependencies.