-
Notifications
You must be signed in to change notification settings - Fork 16
Description
We can build Haskell binaries that use inline-java. However, initializing the JVM in these programs requires specifying the paths to all the jar files that are needed by the Java part of the program.
Currently, inline-java achieves this by making a fat jar of the java dependencies as in
| data = [":jar_deploy.jar"], |
then we pass the path to the fat jar to the jvm as in
inline-java/benchmarks/wizzardo-http/src/main/haskell/Main.hs
Lines 35 to 36 in 2d94d44
| let jarPath = Runfiles.rlocation r "io_tweag_inline_java/benchmarks/wizzardo-http/jar_deploy.jar" | |
| cpArg = "-Djava.class.path=" <> fromString jarPath |
Fat jars, however, aren't always ideal, and there is some boilerplate to using these in BUILD files.
It would be nice defining a rule in inline-java to create script wrappers around binaries, which sets the classpath before calling the executable. Something like
haskell_binary(
name = "hello-hs"
deps = haskell_deps + some_java_deps,
...
)
classpath_wrapper(
name = "hello-hs-wrapper"
dep = ":hello-hs"
)
we can then run in the command line bazel-bin/hello-hs-wrapper.sh to execute the program with an environment variable like INLINE_JAVA_CLASSPATH=paths/to/jars/in/runfiles.
tweag/rules_haskell#1483 would be blocking this feature, which otherwise could be implemented with transitive_runtime_jars.