Need a solution to replace Java -sourcepath in Bazel java support (use-case: Groovy stubs)
See original GitHub issueThis was reported while testing 0.4.5rc1 by a user that was not able to update to 0.4.4 due to the java bug.
$ ls -R
.:
bazel-bin bazel-genfiles bazel-out bazel-test bazel-testlogs g WORKSPACE
./g:
A.java B.java BUILD
[dmarting@trantor] /tmp/test$ cat WORKSPACE
[dmarting@trantor] /tmp/test$ cat g/A.java
package g;
public class A {
public A() {
new B();
}
}
[dmarting@trantor] /tmp/test$ cat g/B.java
package g;
public class B {
public B() {
}
}
[dmarting@trantor] /tmp/test$ cat g/BUILD
genrule(
name = "stub",
srcs = ["B.java"],
outs = ["B.jar"],
cmd = "zip $@ $(SRCS)",
)
java_library(
name = "test",
srcs = ["A.java"],
javacopts = ["-sourcepath $(GENDIR)/$(location :stub)", "-implicit:none"],
deps = [":stub"]
)
Issue Analytics
- State:
- Created 7 years ago
- Comments:23 (23 by maintainers)
Top Results From Across the Web
Java and Bazel
This page contains resources that help you use Bazel with Java projects. It links to a tutorial, build rules, and other information specific ......
Read more >Change in bazel[master]: Add Spock support to Groovy rules.
Spock is a popular unit testing framework for Java and Groovy applications, see https://code.google.com/p/spock/ for details. This build rule is just a
Read more >Java 9 should be supported #3410 - bazelbuild/bazel - GitHub
java_toolchain requires a bootstrap classpath, including rt.jar, but Java 9 no longer has rt.jar or anything like that.
Read more >How to define a local Java Toolchain in Bazel - Stack Overflow
Basically I came up with the following solution which seems to solve my problem and is inspired by the rule default_java_toolchain .
Read more >Building Groovy with Bazel
Bazel is a build automation tool that ships with support for a variety of languages out-of-the-box. For example, you can build Java projects ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
nope we have the temporary solution in the current RC (supporting
-sourcepath
in javacopts) so we can take the time to have a proper API for this use case.Damien helped me figure it out. It was because my files were under
java/com/google/somename
and the expected location ofB.jar
wascom/google/somename/B.jar
. Thanks!