Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: download sources for external dependencies #42

Closed
ruudud opened this issue Jan 18, 2017 · 8 comments
Closed

Java: download sources for external dependencies #42

ruudud opened this issue Jan 18, 2017 · 8 comments

Comments

@ruudud
Copy link

ruudud commented Jan 18, 2017

Let's say I have used maven_jar() in my WORKSPACE to make apache httpclient available to declare as a dependency, and that I am able to build my project without any problems with code using this external dependency.

When I in IntelliJ try to Go to → Implementation on a class from the dependency and click on "Download" in the bar at the top of the opened class file, I get an error Sources not found: Sources for 'httpclient-4.5.2-ijar.jar' not found.

I suspect this is due to the ijar trick bazel is doing?https://github.com/bazelbuild/bazel/tree/master/third_party/ijar

The functionality to easy download sources for external dependencies is a great feature, and I miss it very much.

Should this be working? Am I missing something?

Bazel version: 0.4.3

@brendandouglas
Copy link
Contributor

This is basically the same issue as #31. The bazel plugin only sees the output from bazel, which doesn't include the sources. Until that's supported more naturally by bazel, you'll need a workaround.

The gerrit project has an example of this, which should work in conjunction with the bazel IntelliJ plugin:
https://gerrit.googlesource.com/gerrit/+/master/tools/bzl/maven_jar.bzl

@ruudud
Copy link
Author

ruudud commented Jan 24, 2017

Thanks!

@dfabulich
Copy link

I'm not sure I understand. Are you saying that if I use this skylark rule instead of the built-in maven_jar WORKSPACE rule, the IntelliJ plugin will attach source jars automatically?

@brendandouglas
Copy link
Contributor

That's right -- the skylark extension will create a java_import target with the relevant srcjar attribute value filled in. That Skylark extension just overrides the behaviour of maven_jar, so you'll need to load it in the WORKSPACE file (see the gerrit project's WORKSPACE file as an example). Then just leave all your maven_jar targets as they were.

You can test it by loading that gerrit project in IntelliJ (you'll need Bazel 0.4.4 or later, and IJwB 2017.01.09 or later).

@nornagon
Copy link

I tried using a modified version of gerrit's maven_jar replacement, and found that IntelliJ complained that the jar's bytecode didn't match what was being referenced by the source. It seems like there's some confusion going on between the ijar and the source jar?

@dfabulich
Copy link

Not "confusion" exactly, but Bazel does configure IntelliJ to use ijars by default. I believe that's on purpose?

@bluecmd
Copy link

bluecmd commented Apr 4, 2017

I'd suggest having this issue open until it has been resolved without requiring overriding maven_jar.

@brendandouglas
Copy link
Contributor

This change should be made in Bazel -- the open issue is bazelbuild/bazel#308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants