Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

java_library: provide a way to specify non transitive dependencies #63

Closed
davido opened this issue Nov 1, 2013 · 4 comments
Closed
Assignees

Comments

@davido
Copy link
Contributor

davido commented Nov 1, 2013

When building a plugin (P) for an existing system (S) which exposes an API in form of library (A) the following idiom is used:

P depends on A but java_binary P must not contain the content of A.
That's because P is deployed in S and all artifacts from A are obviously exist.

Currently it is not possible to express that idiom with Buck's native java_library.

Sugestion: extend java_library with new parameter: compiled_deps.

Alternatively provide a new finction java_library2 that exposes that parameter.

Working use case: java_library2() that exposes compile_deps parameter in:

https://github.com/davido/gerrit-reviewers-plugin/blob/master/lib/build.defs

To see the difference between call to java_library2 and java_library try to replace it on line 61: in gerrit_plugin() definition:

java_library(
name = name + '__plugin',
srcs = srcs,
resources = resources,
deps = deps + ['//:%s-lib' % type],
)

With the outcome that reviewers.jar would contain the whole gerrit-plugin-api.jar and not only 4 classes it adds.

@thkoch2001
Copy link

Maybe it'd make sense to use the same wording as used in maven: "provided"?

Maven documentation: Introduction to the Dependency Mechanism

Thank you for working on an alternative to maven!!!

@spearce
Copy link
Contributor

spearce commented Nov 9, 2013

I would suggest adding compile_deps to java_library(), e.g.:

java_library(
name = 'api',
srcs = glob(...),
deps = ['//lib:guava'],
compile_deps = ['//lib:servlet-api'],
)

deps is transitive, while compile_deps is only passed to the javac
invocation and is not exposed to java_binary() that includes this
library.

@davido
Copy link
Contributor Author

davido commented Nov 10, 2013

Done in [1].

[1] davido@2d27e26

@shs96c
Copy link
Contributor

shs96c commented May 2, 2014

After discussion on #68 this has been implemented in cea4e34 The documentation can currently be found here:
http://facebook.github.io/buck/rule/java_library.html

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

Successfully merging a pull request may close this issue.

6 participants