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

Fix missing plugin inputs #318

Merged
merged 3 commits into from
Apr 28, 2020

Conversation

justhecuke-zz
Copy link
Contributor

java_plugin runtime jars were not being added to the KotlinCompile action's input list which meant that bazel was not properly ensuring that they were available.

This PR just adds the plugin jars we need to the action input and lets bazel handle the rest.

Before this, kotlin's plugin implementation was fundamentally broken and only worked by chance.

inputs = depset(ctx.files.srcs, transitive = [compile_deps.compile_jars]),
inputs = depset(
ctx.files.srcs,
transitive = [compile_deps.compile_jars] + [ap.classpath for ap in annotation_processors.to_list()]),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if the to_list() is strictly required, but I'm not sure how this would handle a depset of structs rather than a depset of files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We want to avoid to_list like the plague, unfortunately. It would be better to export the processor classpath from https://github.com/bazelbuild/rules_kotlin/blob/master/kotlin/internal/jvm/plugins.bzl#L36 to limit the number of times we call to_list. (probably should even happen there, tbh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've made the change you requested. I couldn't do it within the exact method you pointed to, not that I could figure anyways, but I've made changes similar to the existing pattern.

@justhecuke-zz
Copy link
Contributor Author

PTAL @cgruber

@justhecuke-zz
Copy link
Contributor Author

PTAL @restingbull

Copy link
Collaborator

@restingbull restingbull left a comment

Choose a reason for hiding this comment

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

A little restructure to collect the classpaths in the aspect to avoid flattening a depset until action execution would go a long way.

qq -- what was the bug that came up from missing the classpath?

inputs = depset(ctx.files.srcs, transitive = [compile_deps.compile_jars]),
inputs = depset(
ctx.files.srcs,
transitive = [compile_deps.compile_jars] + [ap.classpath for ap in annotation_processors.to_list()]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We want to avoid to_list like the plague, unfortunately. It would be better to export the processor classpath from https://github.com/bazelbuild/rules_kotlin/blob/master/kotlin/internal/jvm/plugins.bzl#L36 to limit the number of times we call to_list. (probably should even happen there, tbh.

@justhecuke-zz
Copy link
Contributor Author

A little restructure to collect the classpaths in the aspect to avoid flattening a depset until action execution would go a long way.

qq -- what was the bug that came up from missing the classpath?

Bug is improper/non execution of plugins and sometimes missing classes when running the plugin. Errors during the build from dagger and such not generating classes.

Jars on the processorpath didn't exist and were pointing to the target config rather than host. Especially bad when building for android since it'd try to compile for arm, possibly meaning that valid java/kotlin wouldn't be able to build due to android sdk not using java/kotlin toolchain although I didn't witness this.

End result is flaky failures during build that generally required a clean to fix up. If you hit a build failure you tended to hit it 100% until a clean. If your build worked then it tended to work 100% until a clean. Especially bad in CI since builds were always clean.

Copy link
Collaborator

@cgruber cgruber left a comment

Choose a reason for hiding this comment

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

Oh wow - we're hitting this exact same thing, as of dagger 2.27. I guess it acted as a forcing function. The only comment I would have had would be to avoid to_list, but @restingbull already got there.

This looks fine to me, but I'll wait to merge until @restingbull gives it his final nod, since he has outstanding updates to review.

Of note, I'll make sure this gets in and that I get a release out sooner than later. (been rather distracted personally and professionally - this is being prioritized now)

@cgruber cgruber merged commit dbf68b5 into bazelbuild:master Apr 28, 2020
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

Successfully merging this pull request may close these issues.

3 participants