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

Include desugaring lib also in library modules #1604

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

julioromano
Copy link
Contributor

@julioromano julioromano commented Oct 19, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Includes the coreLibraryDesugaring(libs.android.desugar) dependency in all modules which use one of our gradle plugins.

Motivation and context

Right now desugaring is enabled also in library modules but the desugar dependency is not included in those.
This causes some unwanted side effects such as being unable to run compose previews in an emu.

This change will also include the desugar dependency in those libraries.

As per: https://developer.android.com/studio/write/java8-support#library-desugaring
Rationale is that desugaring is applied by D8/R8 when generating dex files, so libraries alone are never desugared because AARs carry .class files.
Another thing to always make sure of is that, whenever `isCoreLibraryDesugaringEnabled = true` to always add the relative dependency.
@julioromano julioromano requested a review from a team as a code owner October 19, 2023 08:08
@julioromano julioromano requested review from ganfra and removed request for a team October 19, 2023 08:08
Copy link
Contributor

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

Good catch, thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/PxEwBt

@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (a73378b) 58.96% compared to head (759cc3e) 58.96%.
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1604   +/-   ##
========================================
  Coverage    58.96%   58.96%           
========================================
  Files         1199     1199           
  Lines        30961    30961           
  Branches      6343     6343           
========================================
  Hits         18257    18257           
  Misses        9959     9959           
  Partials      2745     2745           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks. ./gradlew tasks works again with this.

@julioromano julioromano changed the title Enable java desugaring only in app modules Include desugaring lib also in library modules Oct 19, 2023
@sonarcloud
Copy link

sonarcloud bot commented Oct 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@julioromano julioromano enabled auto-merge (squash) October 19, 2023 08:55
@julioromano
Copy link
Contributor Author

Unfortunately this change triggers lint errors on the library modules which use java8 apis.

I had to reverse course: Will enable desugaring AND include the desugar dep in all modules.
Apparently there are also some news coming in AGP 8.2.0 about this (see https://issuetracker.google.com/issues/259041363 and https://issuetracker.google.com/issues/203113147).
./gradlew tasks still works with this approach.

@julioromano julioromano merged commit 79d2941 into develop Oct 19, 2023
15 checks passed
@julioromano julioromano deleted the julioromano/composeRunPreview branch October 19, 2023 09:00
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.

None yet

3 participants