Skip to content

Commit

Permalink
Merge pull request #264 from DataDog/nogorodnikov/rum-4407/add-test-f…
Browse files Browse the repository at this point in the history
…or-duplicate-resources-issue

RUM-4407 & RUM-4087: Add test for the duplicate resources issue with AGP 8.4.x
  • Loading branch information
0xnm authored May 30, 2024
2 parents ed9c4e6 + 12d2037 commit 46233f7
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ internal class DdAndroidGradlePluginFunctionalTest {
assertThat(result).hasSuccessfulTaskOutcome(":samples:app:assembleRelease")
}

@Test
fun `M success W assembleRelease { new Variant API is used in buildscript }`() {
// Given
stubGradleBuildFromResourceFile(
"build_with_android_components.gradle",
appBuildGradleFile
)
// When
val result = gradleRunner { withArguments("--stacktrace", ":samples:app:assembleRelease") }
.build()

// Then
assertThat(result).hasSuccessfulTaskOutcome(":samples:app:assembleRelease")
}

@Test
fun `M success W assembleRelease { project with library module }`() {
// Given
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("com.datadoghq.dd-sdk-android-gradle-plugin")
}

repositories {
google()
mavenCentral()
}

extensions.configure("androidComponents") { extension ->
extension.onVariants(extension.selector().all()) { variant ->
// just request assets, this will be enough to reproduce
// https://issuetracker.google.com/issues/342428022 when using new Variant API + legacy one
// with AGP 8.4.0
if (variant.metaClass.respondsTo(variant, "getSources")) {
// available only since AGP 7.2.0
variant.getSources().getAssets()
}
}
}

android {
compileSdkVersion = rootProject.ext.targetSdkVersion
buildToolsVersion = rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "com.example.variants"
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled = true
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

namespace = "com.example.variants"

compileOptions {
sourceCompatibility = rootProject.ext.jvmTarget
targetCompatibility = rootProject.ext.jvmTarget
}

kotlinOptions {
jvmTarget = rootProject.ext.jvmTarget
}
}

dependencies {
implementation(rootProject.ext.datadogSdkDependency)
}

0 comments on commit 46233f7

Please sign in to comment.