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_library equivalent of Maven's scope=provided #16929

Closed
tharakadesilva opened this issue Dec 6, 2022 · 2 comments
Closed

java_library equivalent of Maven's scope=provided #16929

tharakadesilva opened this issue Dec 6, 2022 · 2 comments
Labels
team-Rules-Java Issues for Java rules

Comments

@tharakadesilva
Copy link

tharakadesilva commented Dec 6, 2022

We are hitting an issue similar to #1402. We are creating a set of libraries for our organization and we want something like this:

  • Define a header library
  • Add multiple implementations for the header to support different frameworks. This is similar to this.
  • We want the dependencies for these to be available during compilation like this, but we don't want to be attached to the library's jar.

#1402 mentions how to do something similar with java_binary, but we need this at the java_library level.

You might ask us why not have these implementations in two different java_librarys. We can't do that right now as that breaks backwards compatibility for our current implementations. Currently our libs are tightly coupled to a single framework and we are trying to remove this coupling while maintaining backwards compatibility. This is to allow our application owners to migrate at their own pace.

So my question is, can we do the Maven's scope=provided equivalent in a java_library?

@ShreeM01 ShreeM01 added team-Rules-Java Issues for Java rules untriaged labels Dec 6, 2022
@davido
Copy link
Contributor

davido commented Dec 25, 2022

This is a known missing feature in Bazel.

See also this similar feature request that was rejected.

It worth noting, that there is a way to achieve dependency exclusion using deploy_env attribute in java_binary rule. See for example Gerrit Code Review code base how it could be used.

@hvadehra
Copy link
Member

The semantics of scope=provided for a java_library does not make sense to me. I concur with the decision in #1402 to use java_binary and deploy_env if absolutely needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-Java Issues for Java rules
Projects
None yet
Development

No branches or pull requests

4 participants