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

scala import should support neverlink #371

Closed
ittaiz opened this issue Dec 24, 2017 · 8 comments
Closed

scala import should support neverlink #371

ittaiz opened this issue Dec 24, 2017 · 8 comments

Comments

@ittaiz
Copy link
Member

ittaiz commented Dec 24, 2017

scala import should expose a neverlink attribute which if supplied means this target is to be used at compile time but not at runtime (similar but not identical to maven's provided scope)
Should probably wait for bazelbuild/bazel#3769 since neverlink is part of the design

@arjantop
Copy link

Was there anything done in this area already? Is there no support for compile only dependencies currently for scala?

@ittaiz
Copy link
Member Author

ittaiz commented Jan 21, 2018

Nothing was done. I'll probably handle it sometime in the next month since we'll need it.
There isn't currently any support since no one needed it so far.
We'll need it for external dependencies (hence this ticket about scala_import) and there is a general one about scala_library which can be picked up by people (#213)

@arjantop
Copy link

@ittaiz can you maybe estimate the difficulty of these tasks?

@johnynek
Copy link
Member

I think it wouldn't be too hard. We usually keep to sets of jars: compile jars and runtime jars. The rules are just ways to manage combining those.

The trouble is: until now, runtime jars is a strict super set of compile jars. We may have an assumption of that in some places. If not, then just not putting a jar into the runtime jars when we see neverlink should do it. For instance: https://github.com/bazelbuild/rules_scala/blob/master/scala/scala_import.bzl#L9 search for "runtime" in that file and you'll get an idea how we are plumbing through.

It is pretty easy to test for though, so it shouldn't be mysterious: just make a target that has a neverlink, then make a test that depends on it and verify that Class.forName throws if never link is set, but it does not when it is not set. Something like that.

@ittaiz
Copy link
Member Author

ittaiz commented Jan 24, 2018

A bit short on time but essentially scala_import should be really easy. It's just a matter of omitting these jars from the transitive_compile_jars and transitive_runtime_jars sets.
Re scala_library I'm not sure. Can take a deeper look tomorrow or a bit later.

@gravitywp
Copy link

any updates?

@ittaiz
Copy link
Member Author

ittaiz commented Mar 20, 2018

No. I will get to it eventually because I need it but it might take 1-2 months.
I also think it’s an easy change to contribute though a test might be a bit tricky (definitely doable tough)

@ittaiz
Copy link
Member Author

ittaiz commented Jul 3, 2018

done in #547

@ittaiz ittaiz closed this as completed Jul 3, 2018
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

4 participants