-
Notifications
You must be signed in to change notification settings - Fork 204
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
[wip] dep analysis for strict deps and unused deps #40
Conversation
@iirina I'm wondering if you could give this POC a review or suggest someone else. It would be useful if I could reuse any bits in Bazel core -- I am essentially rewriting the java builder with a Kotlin compile phase. |
…us for the user what to do
…asspath still used
8614db6
to
65e439c
Compare
@@ -111,6 +119,11 @@ def define_kt_toolchain(name, language_version=None, api_version=None, jvm_targe | |||
api_version = api_version, | |||
jvm_target = jvm_target, | |||
coroutines = coroutines, | |||
jvm_strict_deps = select({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendandouglas FYI this is how I am currently going to relay the strict dep flag to the builder. Is this the right place for it ? My initial thoughts were to go through a common hidden attribute on the rules but bazelbuild/bazel#287 prevents this. I can make it hidden here ?
p.s., This branch is quite chaotic atm so don't bother reading any of the other code.
So this PR has a POC of strict dep checking working. The sequence of actions run within the builder is as follows:
Deps.Dependencies
) against the--direct_dependencies
and--indirect_dependencies
passed via the command line.buildozer
output and delete the generated jar.The dependency analysis / dependency selection is not in line with how the native rules currently do It bazelbuild/bazel#4584. The analysis is attempting to select deps further away from a jars
File.owner
-- at least one hop but at the moment it could be much closer to the target. So for example a//third_party:guice
label could be chosen for bothjavax-inject
andguice
. Perhaps the heuristic should prefer in-project labels exporting only one jar if available.A compiler plugin for Kotlin makes more sense so that we get more error context -- one short term work around is to run a compile phase after detecting indirect dependency usage with a restricted classpath and concatenate those errors with the buildozer suggestions. This doesn't cover the mixed mode scenario, currently java code is compiled by javac -- and writing a compiler plugin for javac makes no sense. Could the JavaBuilder be leveraged here without going back out to skylark ?