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

KotlinBuilder leaks dagger dependency into compilation. #192

Closed
cgruber opened this issue Jun 6, 2019 · 2 comments
Closed

KotlinBuilder leaks dagger dependency into compilation. #192

cgruber opened this issue Jun 6, 2019 · 2 comments

Comments

@cgruber
Copy link
Collaborator

cgruber commented Jun 6, 2019

When using Dagger >2.21 which introduces a new inner class Component.Factory, compilations that involve dagger processing end up having an older version of Dagger (2.16), which is API incompatible (Component in both versions have different metadata about inner classes). This results in compile-time crashes during annotation processing.

This likely means that however kapt is being invoked, the builder itself is in the classpath, probably because the builder is invoking kapt in its process.

The correct action would be to isolate classloaders.

Possible backups would include:

  • "shading" all of the third-party consumed libraries by the builder, so as not to conflate types. (good practice anyway)
  • removing dagger and hand-rolling the dependency injection (crappy, but reduces the deps of the builder itself - it's mostly in kotlin anyway, so it might be feasible to use kotlinisms to reduce the cost of a service-locator-ish approach).
  • Causing the dagger used to build the builder to be supplied externally, so users of the rules could control what dagger version was used in the infrastructure (a more mono-repo approach).
@cgruber
Copy link
Collaborator Author

cgruber commented Jun 6, 2019

Gonna suggest probably shading, as it's the simplest option, architecturally. Just changes the packaging step.

cgruber added a commit to cgruber/rules_kotlin that referenced this issue Jun 12, 2019
…shade dagger, avoiding leakage of the bytecode from the builder into compilation jobs peformed by the builder.

Fixes bazelbuild#192
cgruber added a commit to cgruber/rules_kotlin that referenced this issue Jun 12, 2019
…shade dagger, avoiding leakage of the bytecode from the builder into compilation jobs peformed by the builder.

Fixes bazelbuild#192
cgruber added a commit to cgruber/rules_kotlin that referenced this issue Jun 12, 2019
…shade dagger, avoiding leakage of the bytecode from the builder into compilation jobs peformed by the builder.

Fixes bazelbuild#192
cgruber added a commit to cgruber/rules_kotlin that referenced this issue Jun 12, 2019
…shade dagger, avoiding leakage of the bytecode from the builder into compilation jobs peformed by the builder.

Fixes bazelbuild#192
@cgruber
Copy link
Collaborator Author

cgruber commented Jun 13, 2019

This fix is released in https://github.com/cgruber/rules_kotlin/releases/tag/legacy-modded-0_26_1-01

jongerrish added a commit to jongerrish/rules_kotlin that referenced this issue Apr 16, 2020
…shade dagger, avoiding leakage of the bytecode from the builder into compilation jobs peformed by the builder.

Fixes bazelbuild#192
richmowd411 added a commit to richmowd411/Rules-Kotlin that referenced this issue Apr 12, 2022
…shade dagger, avoiding leakage of the bytecode from the builder into compilation jobs peformed by the builder.

Fixes bazelbuild/rules_kotlin#192
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

1 participant