You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to run Bazel and even build Java projects without installing Java in the system or defining JAVA_HOME. For example, consider this dockerfile:
This container has everything that's necessary to run Bazel, because Bazelisk is able to download a suitable JVM. To build a Java target, you'd need to provide additional Bazel flags:
However, if there's a dependency on a @maven// target, the build fails with an error like this:
bazel build --javabase=@bazel_tools//tools/jdk:remote_jdk11 --java_runtime_version=remotejdk_11 //src/test/...
// snip...
ERROR: /build/java-ipfs-http-client/BUILD.bazel:1:14:
//:maven_test_deps depends on @maven//:junit_junit in repository @maven which failed to fetch. no such package '@maven//':
Unable to run coursier:
/root/.cache/bazel/_bazel_root/3f57bb81dd178514a6db80432bcb53b1/external/maven/coursier: 26: exec: java: not found
Apparently Coursier expects Java to be installed (i.e. present in PATH). However, I don't see why this should be necessary.
Consider that there is already some JVM present in the system (the one which Bazel uses to run its own code), and we know were to find it. For the purpose of running Coursier, it does not matter at all what version it is, as long as it is able to launch the Coursier JAR and have the dependencies downloaded.
It is possible to run Bazel and even build Java projects without installing Java in the system or defining
JAVA_HOME
. For example, consider this dockerfile:This container has everything that's necessary to run Bazel, because Bazelisk is able to download a suitable JVM. To build a Java target, you'd need to provide additional Bazel flags:
It this environment, the above command is able to compile Java sources. (I have been experimenting with odisseus/java-ipfs-http-client@4de9831.)
However, if there's a dependency on a
@maven//
target, the build fails with an error like this:Apparently Coursier expects Java to be installed (i.e. present in
PATH
). However, I don't see why this should be necessary.Consider that there is already some JVM present in the system (the one which Bazel uses to run its own code), and we know were to find it. For the purpose of running Coursier, it does not matter at all what version it is, as long as it is able to launch the Coursier JAR and have the dependencies downloaded.
By the way, this will probably solve #770.
The text was updated successfully, but these errors were encountered: