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

RUM-592: Support new Variant API #263

Merged
merged 1 commit into from
May 30, 2024

Conversation

0xnm
Copy link
Contributor

@0xnm 0xnm commented May 28, 2024

What does this PR do?

This PR brings support of new Variant API. It was originally added in AGP 7, but we didn't use it because it was missing some APIs from old Variant API.

Now we will use new Variant API for AGP 8.4.0 and above (because for the older AGP versions old Variant API works fine, but AGP 8.4.0 has a regression mentioned here).

Timeline of migration from old Variant API to the new one is here (new Variant API is completely stable with AGP 9, old Variant API is removed with AGP 10, mid-2025).

This PR should fix #242 and #257.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@0xnm 0xnm requested review from a team as code owners May 28, 2024 15:33
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2024

Codecov Report

Attention: Patch coverage is 54.65116% with 78 lines in your changes are missing coverage. Please review.

Project coverage is 78.25%. Comparing base (7cd2c7d) to head (70ba81c).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #263      +/-   ##
=============================================
- Coverage      80.56%   78.25%   -2.30%     
- Complexity       210      249      +39     
=============================================
  Files             26       31       +5     
  Lines            828      892      +64     
  Branches         110      114       +4     
=============================================
+ Hits             667      698      +31     
- Misses           116      144      +28     
- Partials          45       50       +5     
Files Coverage Δ
...n/com/datadog/gradle/plugin/GenerateBuildIdTask.kt 66.67% <100.00%> (+1.96%) ⬆️
...m/datadog/gradle/plugin/NdkSymbolFileUploadTask.kt 94.12% <100.00%> (ø)
...main/kotlin/com/datadog/gradle/plugin/TaskUtils.kt 77.27% <ø> (ø)
...tlin/com/datadog/gradle/plugin/CheckSdkDepsTask.kt 88.89% <50.00%> (ø)
...kotlin/com/datadog/gradle/plugin/FileUploadTask.kt 81.75% <84.62%> (ø)
...atadog/gradle/plugin/internal/CurrentAgpVersion.kt 33.33% <33.33%> (ø)
...tadog/gradle/plugin/internal/variant/AppVariant.kt 0.00% <0.00%> (ø)
...com/datadog/gradle/plugin/MappingFileUploadTask.kt 83.82% <53.33%> (ø)
...gradle/plugin/internal/variant/NewApiAppVariant.kt 60.00% <60.00%> (ø)
...com/datadog/gradle/plugin/DdAndroidGradlePlugin.kt 70.25% <57.50%> (+2.64%) ⬆️
... and 2 more

@0xnm 0xnm force-pushed the nogorodnikov/rum-592/support-new-variant-api branch from 7374873 to 70ba81c Compare May 29, 2024 11:58
@0xnm 0xnm requested a review from xgouchet May 29, 2024 14:06
Copy link
Contributor

@mariusc83 mariusc83 left a comment

Choose a reason for hiding this comment

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

Looks good to me, few comments there but nothing blocking.

configureVariantForSdkCheck(target, variant, datadogExtension)
}
} else {
configureVariantForSdkCheck(target, variant, datadogExtension)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we have also the old variant based configureVariantForSdkCheck ? I can't see it in this PR anymore, just checking to make sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is right on this line. else here means it is old Variant API.

versionName.set(variant.versionName)
versionCode.set(variant.versionCode)

if (extensionConfiguration.serviceName != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why we are re - setting this here ? I saw that we already set this value when we configure the task. It makes it a bit weird to configure this property here at this level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is for the NDK-based task, coming from the previous development. Maybe we can refactor this in the future.


// can work probably even with lower versions, but legacy Variant API is working fine there as well
val CAN_ENABLE_NEW_VARIANT_API: Boolean
get() = TaskUtils.isAgpAbove(major = 8, minor = 4, patch = 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

you could still extract those magic numbers in 3 constants here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the added value given that we use named arguments here and property name explains what we are looking for?


@Suppress("UnstableApiUsage")
val allKotlin = variant.sources.kotlin?.all
return if (allJava != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you could define both kotlin and java as empty lists if they are null and then avoid the if/else below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

allKotlin and allJava are not collections, but of Provider type.

GitRepositoryDetector(execOps)
).apply {
configure { uploadTask ->
@Suppress("MagicNumber")
if (DdTaskUtils.isGradleAbove(target, 7, 5)) {
if (TaskUtils.isGradleAbove(target, 7, 5)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we're still using some magic numbers here, maybe we should move this in a static constant in the CurrentAgpVersion ?

@0xnm 0xnm merged commit d854a24 into develop May 30, 2024
13 checks passed
@0xnm 0xnm deleted the nogorodnikov/rum-592/support-new-variant-api branch May 30, 2024 08:34
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.

Latest build (1.13.0) breaks react native project
4 participants