jbang icon indicating copy to clipboard operation
jbang copied to clipboard

Add main method in build.jbang as build handler

Open linux-china opened this issue 3 years ago • 6 comments

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
    }
}

linux-china avatar Sep 05 '22 23:09 linux-china

Not following? Can You elaborate?

maxandersen avatar Sep 06 '22 00:09 maxandersen

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.

quintesse avatar Sep 06 '22 00:09 quintesse

It's a feature requirement and just for discussion :)

linux-china avatar Sep 06 '22 00:09 linux-china

...so the //DEPS is for the build itself not for the app being built ?

maxandersen avatar Sep 06 '22 01:09 maxandersen

...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 avatar Sep 06 '22 04:09 linux-china

@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.

quintesse avatar Sep 06 '22 09:09 quintesse