Skip to content

Comments

Use runtime classpath at root to workaround Dagger/Hilt API vs Impl issue.#2154

Merged
copybara-service[bot] merged 1 commit intomasterfrom
test_337516449
Jan 6, 2021
Merged

Use runtime classpath at root to workaround Dagger/Hilt API vs Impl issue.#2154
copybara-service[bot] merged 1 commit intomasterfrom
test_337516449

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Oct 20, 2020

Use runtime classpath at root to workaround Dagger/Hilt API vs Impl issue.

This CL adds a new Hilt option called 'enableClasspathAggregation' that will configure the compile classpath of the project (for app modules and tests) to use the runtime classpath. This means that transitive dependencies will be available during compilation which in turn will allow Dagger to traverse the classes along the dependency tree and will allow for Hilt's aggregating classes to be discovered.

The classpath configuration is done by resolving the runtime configuration with an artifact view and adding it to the 'CompileOnly' config. This solution is inefficient and will cause build performance impact, but it is a starting point that can be further optimized by using a smarter transform that can extract the necessary classes required by Dagger and Hilt.

Fixes: #1991
RELNOTES=Use runtime classpath at root to workaround Dagger/Hilt API vs Impl issue.

@google-cla google-cla bot added the cla: yes label Oct 20, 2020
@copybara-service copybara-service bot force-pushed the test_337516449 branch 6 times, most recently from 512baf4 to 967ae9a Compare October 22, 2020 16:39
@Kshitij09
Copy link

When should I expect this to be fixed? Just for confirmation, this will solve the need to replace "implementation" with "api" right?

@danysantiago
Copy link
Member

will solve the need to replace "implementation" with "api" right?

Yes - We still have a few issues to resolve before we can commit to this solution. No ETA sorry.

@copybara-service copybara-service bot force-pushed the test_337516449 branch 2 times, most recently from 5d5a744 to 9d6c1cf Compare December 17, 2020 02:36
@copybara-service copybara-service bot force-pushed the test_337516449 branch 3 times, most recently from 02fe454 to 61fe1c4 Compare January 5, 2021 23:16
…ssue.

This CL adds a new Hilt option called 'enableClasspathAggregation' that will configure the compile classpath of the project (for app modules and tests) to use the runtime classpath. This means that transitive dependencies will be available during compilation which in turn will allow Dagger to traverse the classes along the dependency tree and will allow for Hilt's aggregating classes to be discovered.

The classpath configuration is done by resolving the runtime configuration with an artifact view and adding it to the 'CompileOnly' config. This solution is inefficient and will cause build performance impact, but it is a starting point that can be further optimized by using a smarter transform that can extract the necessary classes required by Dagger and Hilt.

Fixes: #1991
RELNOTES=Use runtime classpath at root to workaround Dagger/Hilt API vs Impl issue.
PiperOrigin-RevId: 350239023
@copybara-service copybara-service bot merged commit 239768b into master Jan 6, 2021
@copybara-service copybara-service bot deleted the test_337516449 branch January 6, 2021 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion needed for using Hilt in library modules

3 participants