Skip to content
This repository has been archived by the owner on Mar 14, 2019. It is now read-only.

Remove the library() macro and _lib targets #16

Merged
merged 8 commits into from
Mar 6, 2019
Merged

Remove the library() macro and _lib targets #16

merged 8 commits into from
Mar 6, 2019

Conversation

jin
Copy link
Owner

@jin jin commented Mar 4, 2019

The original motivation for adding _lib targets for every artifact was to ensure that you don't need to specify transitive dependencies on top of the top level artifact in deps in order to use the top level artifact. This is already fully wired up in the versionless aliases and the java_import and aar_import targets.

For example, if you want to use junit:junit which itself depends on org.hamcrest:hamcrest-core, you do not need to specify artifact("org.hamcrest:hamcrest-core") alongside artifact("junit:junit") in deps, because the java_import target for junit:junit already depends on org:hamcrest:hamcrest-core.

The generated _lib targets, as it's implemented currently, re-exports the direct dependencies of an artifact, and itself, in a java_library. This may be useful to reduce the number of specified artifacts in deps, but it can hide unnecessary dependencies in the classpath, causing a large over-specification of available compile-time classes. If a target wishes to use an indirect dependency, the target should specify the versionless alias of the indirect dependency in its deps, and not rely on the overspecification of _lib/library() targets.

@jin jin requested a review from dkelmer March 4, 2019 22:00
@jin
Copy link
Owner Author

jin commented Mar 4, 2019

cc @davidsantiago

@davidsantiago
Copy link
Contributor

FWIW, LGTM. 🙈

Copy link
Collaborator

@dkelmer dkelmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to make sure I understand: let's assume maven jar-A depends on maven jar-B. Before this change, projects could depend on the _lib target and then use symbols from both jar-A and jar-B? And what you're saying is that with this change, users would need to explicitly depend on jar-B if they wanted to use symbols from it? That definitely sounds like a step in the right direction. I eventually want to ban usage of jar-B entirely unless it's explicitly added to the artifacts list in the repository rule.

README.md Outdated Show resolved Hide resolved
@jin
Copy link
Owner Author

jin commented Mar 5, 2019

@dkelmer that is exactly right.

@jin jin requested a review from dkelmer March 6, 2019 20:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants