question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need a solution to replace Java -sourcepath in Bazel java support (use-case: Groovy stubs)

See original GitHub issue

This 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:closed
  • Created 7 years ago
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
damienmgcommented, Mar 7, 2017

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.

0reactions
iirinacommented, Mar 15, 2017

Damien helped me figure it out. It was because my files were under java/com/google/somenameand the expected location of B.jar was com/google/somename/B.jar. Thanks!

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found