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

Add the option to include sources in the native maven_jar rule #3571

Closed
wants to merge 1 commit into from

Conversation

snowp
Copy link
Contributor

@snowp snowp commented Aug 16, 2017

This adds the option to download the sources jar (defined as the same maven artifact, but with classifier = "sources") along with the main jar. When doing so it will specify the srcjar attribute on the java_import rule generated by maven_jar.

The motivation behind this is improving IDE integration for third party dependencies, specifically allowing the IJ plugin to automatically attach sources to maven jars without having to use custom Skylark macros.

This also adds in the option to specify a sources_sha1, though I'm not sure how useful that is.

Example of generated BUILD file:

# DO NOT EDIT: automatically generated BUILD.bazel file for maven_jar rule com_google_guava_guava
java_import(
    name = 'jar',
    jars = ['guava-22.0.jar'],
    srcjar = ':sources',
    visibility = ['//visibility:public'],
)

filegroup(
    name = 'file',
    srcs = ['guava-22.0.jar'],
    visibility = ['//visibility:public']
)

filegroup(
    name = 'sources',
    srcs = ['guava-22.0-sources.jar'],
    visibility = ['//visibility:public']
)

Discussed in #1410 & #308

Adds two new attrs to maven_jar: `attach_sources` and `sources_sha1`
that allows a user to specify that the sources jar should be downloaded
alongside the main jar. The sources_sha1 attr can be used to verify the
checksum of the downloaded jar.
@bazel-io
Copy link
Member

Can one of the admins verify this patch?

@cheister
Copy link
Contributor

@juliexxia Can you take a look at this change? It fixes one of the most annoying bugs in the IntelliJ plugin.

@kchodorow
Copy link
Contributor

Thanks for the patch @snowp, but we actually already have a change in progress that's almost ready to merge. It'll basically download the source jar if it's available and put it in the srcjar attribute. Do you need a separate sources target?

@snowp
Copy link
Contributor Author

snowp commented Aug 23, 2017

@kchodorow Nah I don't have a need for it to be exposed as its own target. Happy to close this PR out in favor of the other change. Is that work being done in the open (i.e. on GitHub)? Would love to follow along.

@snowp snowp closed this Aug 23, 2017
@juliexxia
Copy link
Contributor

@snowp 7a7c41d should do the trick. LMK if you have any lingering questions/concerns!

@juliexxia juliexxia reopened this Aug 25, 2017
@bazel-io
Copy link
Member

Can one of the admins verify this patch?

@juliexxia juliexxia closed this Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants