diff --git a/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginFunctionalTest.kt b/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginFunctionalTest.kt index 417c1325..5119dc18 100644 --- a/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginFunctionalTest.kt +++ b/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginFunctionalTest.kt @@ -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 diff --git a/dd-sdk-android-gradle-plugin/src/test/resources/build_with_android_components.gradle b/dd-sdk-android-gradle-plugin/src/test/resources/build_with_android_components.gradle new file mode 100644 index 00000000..685a266e --- /dev/null +++ b/dd-sdk-android-gradle-plugin/src/test/resources/build_with_android_components.gradle @@ -0,0 +1,55 @@ +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 + 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) +}