From 5e2931f0953e9f3ec5053478ea5111287d0d0e52 Mon Sep 17 00:00:00 2001 From: "Xavier F. Gouchet" Date: Tue, 10 Oct 2023 15:13:35 +0200 Subject: [PATCH] RUM-713 Allow customer to use non standard obfuscation --- .../gradle/plugin/DdAndroidGradlePlugin.kt | 34 +++++--- .../gradle/plugin/DdExtensionConfiguration.kt | 8 ++ .../DdAndroidGradlePluginFunctionalTest.kt | 86 ++++++++++++++----- .../plugin/DdAndroidGradlePluginTest.kt | 40 ++++++--- .../build_with_non_default_obfuscation.gradle | 67 +++++++++++++++ .../build_with_plugin_disabled.gradle | 67 +++++++++++++++ 6 files changed, 254 insertions(+), 48 deletions(-) create mode 100644 dd-sdk-android-gradle-plugin/src/test/resources/build_with_non_default_obfuscation.gradle create mode 100644 dd-sdk-android-gradle-plugin/src/test/resources/build_with_plugin_disabled.gradle diff --git a/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePlugin.kt b/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePlugin.kt index 96c4fa24..b0f4fe2e 100644 --- a/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePlugin.kt +++ b/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePlugin.kt @@ -25,6 +25,7 @@ import javax.inject.Inject /** * Plugin adding tasks for Android projects using Datadog's SDK for Android. */ +@Suppress("TooManyFunctions") class DdAndroidGradlePlugin @Inject constructor( private val execOps: ExecOperations ) : Plugin { @@ -40,6 +41,8 @@ class DdAndroidGradlePlugin @Inject constructor( val androidExtension = target.extensions.findByType(AppExtension::class.java) if (androidExtension == null) { LOGGER.error(ERROR_NOT_ANDROID) + } else if (!extension.enabled) { + LOGGER.info("Datadog extension disabled, no upload task created") } else { androidExtension.applicationVariants.all { variant -> configureVariantForUploadTask(target, variant, apiKey, extension) @@ -73,13 +76,13 @@ class DdAndroidGradlePlugin @Inject constructor( apiKey: ApiKey, extension: DdExtension ): Task? { - if (!variant.buildType.isMinifyEnabled) { - LOGGER.info("Minifying disabled for variant ${variant.name}, no upload task created") - return null - } + val extensionConfiguration = resolveExtensionConfiguration(extension, variant) + val isDefaultObfuscationEnabled = variant.buildType.isMinifyEnabled + val isNonDefaultObfuscationEnabled = extensionConfiguration.nonDefaultObfuscation + val isObfuscationEnabled = isDefaultObfuscationEnabled || isNonDefaultObfuscationEnabled - if (!extension.enabled) { - LOGGER.info("Extension disabled for variant ${variant.name}, no upload task created") + if (!isObfuscationEnabled) { + LOGGER.info("Minifying disabled for variant ${variant.name}, no upload task created") return null } @@ -91,13 +94,10 @@ class DdAndroidGradlePlugin @Inject constructor( DdMappingFileUploadTask::class.java, GitRepositoryDetector(execOps) ) - val extensionConfiguration = resolveExtensionConfiguration(extension, variant) configureVariantTask(uploadTask, apiKey, flavorName, extensionConfiguration, variant) - val outputsDir = File(target.buildDir, "outputs") - uploadTask.mappingFilePath = - resolveMappingFilePath(extensionConfiguration, outputsDir, variant) + uploadTask.mappingFilePath = resolveMappingFilePath(extensionConfiguration, target, variant) uploadTask.mappingFilePackagesAliases = filterMappingFileReplacements( extensionConfiguration.mappingFilePackageAliases, @@ -108,9 +108,7 @@ class DdAndroidGradlePlugin @Inject constructor( uploadTask.datadogCiFile = findDatadogCiFile(target.projectDir) } - val reportsDir = File(outputsDir, "reports") - val datadogDir = File(reportsDir, "datadog") - uploadTask.repositoryFile = File(datadogDir, "repository.json") + uploadTask.repositoryFile = resolveDatadogRepositoryFile(target) val roots = mutableListOf() variant.sourceSets.forEach { @@ -187,19 +185,27 @@ class DdAndroidGradlePlugin @Inject constructor( private fun resolveMappingFilePath( extensionConfiguration: DdExtensionConfiguration, - outputsDir: File, + target: Project, variant: ApplicationVariant ): String { val customPath = extensionConfiguration.mappingFilePath return if (customPath != null) { customPath } else { + val outputsDir = File(target.buildDir, "outputs") val mappingDir = File(outputsDir, "mapping") val flavorDir = File(mappingDir, variant.name) File(flavorDir, "mapping.txt").path } } + private fun resolveDatadogRepositoryFile(target: Project): File { + val outputsDir = File(target.buildDir, "outputs") + val reportsDir = File(outputsDir, "reports") + val datadogDir = File(reportsDir, "datadog") + return File(datadogDir, "repository.json") + } + private fun filterMappingFileReplacements( replacements: Map, applicationId: String diff --git a/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdExtensionConfiguration.kt b/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdExtensionConfiguration.kt index 35e78a51..a735daf0 100644 --- a/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdExtensionConfiguration.kt +++ b/dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdExtensionConfiguration.kt @@ -83,6 +83,13 @@ open class DdExtensionConfiguration( */ var mappingFileTrimIndents: Boolean = false + /** + * This property declares that the obfuscation technology used is not the default + * R8/Proguard included in the Android toolchain (e.g.: Dexguard, …). + * Doing so will create an upload task for all variants and all build types + */ + var nonDefaultObfuscation: Boolean = false + /** * Ignore the config declared in `datadog-ci.json` file if found. */ @@ -98,5 +105,6 @@ open class DdExtensionConfiguration( mappingFilePackageAliases = config.mappingFilePackageAliases mappingFileTrimIndents = config.mappingFileTrimIndents ignoreDatadogCiFileConfig = config.ignoreDatadogCiFileConfig + nonDefaultObfuscation = config.nonDefaultObfuscation } } 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 8ffb2d93..86f1af46 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 @@ -42,6 +42,7 @@ internal class DdAndroidGradlePluginFunctionalTest { private lateinit var libModuleMainSrcDir: File private lateinit var libModuleKotlinSourcesDir: File private lateinit var settingsFile: File + private lateinit var localPropertiesFile: File private lateinit var appBuildGradleFile: File private lateinit var libModuleBuildGradleFile: File private lateinit var appManifestFile: File @@ -69,6 +70,7 @@ internal class DdAndroidGradlePluginFunctionalTest { appRootDir = File(testProjectDir, "samples/app").apply { mkdirs() } libModuleRootDir = File(testProjectDir, "samples/lib-module").apply { mkdirs() } settingsFile = File(testProjectDir, "settings.gradle") + localPropertiesFile = File(testProjectDir, "local.properties") gradlePropertiesFile = File(testProjectDir, "gradle.properties") appMainSrcDir = File(appRootDir, "src/main").apply { mkdirs() } appKotlinSourcesDir = File(appMainSrcDir, "kotlin").apply { mkdirs() } @@ -86,6 +88,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // compatible) val agpVersion = forge.anElementFrom(OLD_AGP_VERSION, LATEST_AGP_VERSION) stubFile(settingsFile, SETTINGS_FILE_CONTENT.format(Locale.US, agpVersion)) + stubFile(localPropertiesFile, "sdk.dir=${System.getenv("ANDROID_HOME")}") stubFile(sampleApplicationClassFile, APPLICATION_CLASS_CONTENT) stubFile(appManifestFile, APP_MANIFEST_FILE_CONTENT) stubFile(gradlePropertiesFile, GRADLE_PROPERTIES_FILE_CONTENT) @@ -117,7 +120,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -136,7 +139,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -175,7 +178,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleDebug") + .withArguments("--info", ":samples:app:assembleDebug") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -194,7 +197,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleDebug") + .withArguments("--info", ":samples:app:assembleDebug") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -203,6 +206,45 @@ internal class DdAndroidGradlePluginFunctionalTest { .isEqualTo(TaskOutcome.SUCCESS) } + @Test + fun `M success W assembleDebug { non default obfuscation }`() { + // Given + stubGradleBuildFromResourceFile( + "build_with_non_default_obfuscation.gradle", + appBuildGradleFile + ) + // When + val result = GradleRunner.create() + .withProjectDir(testProjectDir) + .withArguments("--info", ":samples:app:assembleDebug") + .withPluginClasspath(getTestConfigurationClasspath()) + .build() + + // Then + assertThat(result.task(":samples:app:assembleDebug")?.outcome) + .isEqualTo(TaskOutcome.SUCCESS) + } + + @Test + fun `M success W assembleDebug { plugin disabled }`() { + // Given + stubGradleBuildFromResourceFile( + "build_with_plugin_disabled.gradle", + appBuildGradleFile + ) + // When + val result = GradleRunner.create() + .withProjectDir(testProjectDir) + .withArguments("--info", ":samples:app:assembleDebug") + .withPluginClasspath(getTestConfigurationClasspath()) + .build() + + // Then + assertThat(result.task(":samples:app:assembleDebug")?.outcome) + .isEqualTo(TaskOutcome.SUCCESS) + assertThat(result.output).contains("Datadog extension disabled, no upload task created") + } + @Test fun `M success W assembleDebug { build cache }`() { // Given @@ -340,7 +382,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -366,7 +408,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleDebug") + .withArguments("--info", ":samples:app:assembleDebug") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -393,7 +435,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .buildAndFail() } @@ -410,7 +452,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleDebug") + .withArguments("--info", ":samples:app:assembleDebug") .withPluginClasspath(getTestConfigurationClasspath()) .buildAndFail() } @@ -427,7 +469,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -448,7 +490,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleDebug") + .withArguments("--info", ":samples:app:assembleDebug") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -480,13 +522,13 @@ internal class DdAndroidGradlePluginFunctionalTest { // line, so we do the explicit split GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(taskName, "--info", "-PDD_API_KEY=fakekey") + .withArguments(taskName, "--info", "--stacktrace", "-PDD_API_KEY=fakekey") .withPluginClasspath(getTestConfigurationClasspath()) .buildAndFail() @@ -519,13 +561,13 @@ internal class DdAndroidGradlePluginFunctionalTest { // line, so we do the explicit split GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(taskName, "--info", "-PDD_API_KEY=fakekey", "-Pdd-disable-gzip") + .withArguments(taskName, "--info", "--stacktrace", "-PDD_API_KEY=fakekey", "-Pdd-disable-gzip") .withPluginClasspath(getTestConfigurationClasspath()) .buildAndFail() @@ -567,7 +609,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // line, so we do the explicit split GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() @@ -605,13 +647,13 @@ internal class DdAndroidGradlePluginFunctionalTest { // When GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(taskName, "--info", "-PDD_API_KEY=fakekey") + .withArguments(taskName, "--info", "--stacktrace", "-PDD_API_KEY=fakekey") .withPluginClasspath(getTestConfigurationClasspath()) .buildAndFail() @@ -643,13 +685,13 @@ internal class DdAndroidGradlePluginFunctionalTest { // When GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(taskName, "--info", "-PDD_API_KEY=fakekey") + .withArguments(taskName, "--info", "--stacktrace", "-PDD_API_KEY=fakekey") .withPluginClasspath(getTestConfigurationClasspath()) .buildAndFail() @@ -687,13 +729,13 @@ internal class DdAndroidGradlePluginFunctionalTest { // When GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:assembleRelease") + .withArguments("--info", ":samples:app:assembleRelease") .withPluginClasspath(getTestConfigurationClasspath()) .build() val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(taskName, "--info", "-PDD_API_KEY=fakekey") + .withArguments(taskName, "--info", "--stacktrace", "-PDD_API_KEY=fakekey") .withPluginClasspath(getTestConfigurationClasspath()) .buildAndFail() @@ -712,7 +754,7 @@ internal class DdAndroidGradlePluginFunctionalTest { // When val result = GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(":samples:app:tasks") + .withArguments("--info", ":samples:app:tasks") .withPluginClasspath(getTestConfigurationClasspath()) .build() diff --git a/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginTest.kt b/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginTest.kt index 4b0fc8ea..e5cb8e9e 100644 --- a/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginTest.kt +++ b/dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/DdAndroidGradlePluginTest.kt @@ -250,6 +250,7 @@ internal class DdAndroidGradlePluginTest { fakeExtension.mappingFilePackageAliases = emptyMap() fakeExtension.mappingFileTrimIndents = false val variantName = "$flavorName${buildTypeName.replaceFirstChar { capitalizeChar(it) }}" + val fakeMappingFilePath = "${fakeProject.buildDir}/outputs/mapping/$variantName/mapping.txt" whenever(mockVariant.name) doReturn variantName whenever(mockVariant.flavorName) doReturn flavorName whenever(mockVariant.versionName) doReturn versionName @@ -279,8 +280,7 @@ internal class DdAndroidGradlePluginTest { assertThat(task.serviceName).isEqualTo(packageName) assertThat(task.remoteRepositoryUrl).isEmpty() assertThat(task.site).isEqualTo("") - assertThat(task.mappingFilePath) - .isEqualTo("${fakeProject.buildDir}/outputs/mapping/$variantName/mapping.txt") + assertThat(task.mappingFilePath).isEqualTo(fakeMappingFilePath) assertThat(task.mappingFilePackagesAliases).isEmpty() assertThat(task.mappingFileTrimIndents).isFalse assertThat(task.datadogCiFile).isNull() @@ -303,6 +303,7 @@ internal class DdAndroidGradlePluginTest { fakeExtension.mappingFileTrimIndents = false fakeExtension.ignoreDatadogCiFileConfig = false val variantName = "$flavorName${buildTypeName.replaceFirstChar { capitalizeChar(it) }}" + val fakeMappingFilePath = "${fakeProject.buildDir}/outputs/mapping/$variantName/mapping.txt" whenever(mockVariant.name) doReturn variantName whenever(mockVariant.flavorName) doReturn flavorName whenever(mockVariant.versionName) doReturn versionName @@ -335,8 +336,7 @@ internal class DdAndroidGradlePluginTest { assertThat(task.serviceName).isEqualTo(packageName) assertThat(task.remoteRepositoryUrl).isEmpty() assertThat(task.site).isEqualTo("") - assertThat(task.mappingFilePath) - .isEqualTo("${fakeProject.buildDir}/outputs/mapping/$variantName/mapping.txt") + assertThat(task.mappingFilePath).isEqualTo(fakeMappingFilePath) assertThat(task.mappingFilePackagesAliases).isEmpty() assertThat(task.mappingFileTrimIndents).isFalse assertThat(task.datadogCiFile).isEqualTo(fakeDatadogCiFile) @@ -359,6 +359,7 @@ internal class DdAndroidGradlePluginTest { fakeExtension.mappingFileTrimIndents = false fakeExtension.ignoreDatadogCiFileConfig = true val variantName = "$flavorName${buildTypeName.replaceFirstChar { capitalizeChar(it) }}" + val fakeMappingFilePath = "${fakeProject.buildDir}/outputs/mapping/$variantName/mapping.txt" whenever(mockVariant.name) doReturn variantName whenever(mockVariant.flavorName) doReturn flavorName whenever(mockVariant.versionName) doReturn versionName @@ -391,15 +392,14 @@ internal class DdAndroidGradlePluginTest { assertThat(task.serviceName).isEqualTo(packageName) assertThat(task.remoteRepositoryUrl).isEmpty() assertThat(task.site).isEqualTo("") - assertThat(task.mappingFilePath) - .isEqualTo("${fakeProject.buildDir}/outputs/mapping/$variantName/mapping.txt") + assertThat(task.mappingFilePath).isEqualTo(fakeMappingFilePath) assertThat(task.mappingFilePackagesAliases).isEmpty() assertThat(task.mappingFileTrimIndents).isFalse assertThat(task.datadogCiFile).isNull() } @Test - fun `𝕄 do nothing 𝕎 configureVariant() {minify disabled}`( + fun `𝕄 do nothing 𝕎 configureVariant() { no deobfuscation }`( @StringForgery(case = Case.LOWER) flavorName: String, @StringForgery(case = Case.LOWER) buildTypeName: String, @StringForgery versionName: String, @@ -412,7 +412,6 @@ internal class DdAndroidGradlePluginTest { whenever(mockVariant.versionName) doReturn versionName whenever(mockVariant.applicationId) doReturn packageName whenever(mockVariant.buildType) doReturn mockBuildType - whenever(mockBuildType.isMinifyEnabled) doReturn false whenever(mockBuildType.name) doReturn fakeBuildTypeName // When @@ -428,21 +427,21 @@ internal class DdAndroidGradlePluginTest { } @Test - fun `𝕄 do nothing 𝕎 configureVariant() {plugin disabled}`( + fun `𝕄 configure the upload task 𝕎 configureVariant() { non default obfuscation }`( @StringForgery(case = Case.LOWER) flavorName: String, @StringForgery(case = Case.LOWER) buildTypeName: String, @StringForgery versionName: String, @StringForgery packageName: String ) { // Given - fakeExtension.enabled = false + fakeExtension.nonDefaultObfuscation = true val variantName = "$flavorName${buildTypeName.replaceFirstChar { capitalizeChar(it) }}" whenever(mockVariant.name) doReturn variantName whenever(mockVariant.flavorName) doReturn flavorName whenever(mockVariant.versionName) doReturn versionName whenever(mockVariant.applicationId) doReturn packageName whenever(mockVariant.buildType) doReturn mockBuildType - whenever(mockBuildType.isMinifyEnabled) doReturn true + whenever(mockBuildType.isMinifyEnabled) doReturn false whenever(mockBuildType.name) doReturn fakeBuildTypeName // When @@ -454,7 +453,24 @@ internal class DdAndroidGradlePluginTest { ) // Then - assertThat(task).isNull() + check(task is DdMappingFileUploadTask) + assertThat(task.repositoryDetector).isInstanceOf(GitRepositoryDetector::class.java) + assertThat(task.name).isEqualTo( + "uploadMapping${variantName.replaceFirstChar { capitalizeChar(it) }}" + ) + assertThat(task.apiKey).isEqualTo(fakeApiKey.value) + assertThat(task.apiKeySource).isEqualTo(fakeApiKey.source) + assertThat(task.variantName).isEqualTo(flavorName) + assertThat(task.versionName).isEqualTo(fakeExtension.versionName) + assertThat(task.serviceName).isEqualTo(fakeExtension.serviceName) + assertThat(task.site).isEqualTo(fakeExtension.site) + assertThat(task.remoteRepositoryUrl).isEqualTo(fakeExtension.remoteRepositoryUrl) + assertThat(task.mappingFilePath).isEqualTo(fakeExtension.mappingFilePath) + assertThat(task.mappingFilePackagesAliases) + .isEqualTo(fakeExtension.mappingFilePackageAliases) + assertThat(task.mappingFileTrimIndents) + .isEqualTo(fakeExtension.mappingFileTrimIndents) + assertThat(task.datadogCiFile).isNull() } // endregion diff --git a/dd-sdk-android-gradle-plugin/src/test/resources/build_with_non_default_obfuscation.gradle b/dd-sdk-android-gradle-plugin/src/test/resources/build_with_non_default_obfuscation.gradle new file mode 100644 index 00000000..6c7c18a2 --- /dev/null +++ b/dd-sdk-android-gradle-plugin/src/test/resources/build_with_non_default_obfuscation.gradle @@ -0,0 +1,67 @@ +plugins { + id("com.android.application") + id("kotlin-android") + id("com.datadoghq.dd-sdk-android-gradle-plugin") +} + +repositories { + google() + mavenCentral() +} + +android { + compileSdkVersion = 33 + buildToolsVersion = "33.0.1" + + defaultConfig { + applicationId "com.example.variants" + minSdkVersion 21 + targetSdkVersion 33 + 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 = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + flavorDimensions("version", "colour") + productFlavors { + demo { + dimension "version" + applicationIdSuffix ".demo" + versionNameSuffix "-demo" + } + full { + dimension "version" + applicationIdSuffix ".full" + versionNameSuffix "-full" + } + + green { + dimension "colour" + } + blue { + dimension "colour" + } + } +} + +dependencies { + implementation("com.datadoghq:dd-sdk-android-rum:2.2.0") +} + +datadog { + nonDefaultObfuscation = true +} diff --git a/dd-sdk-android-gradle-plugin/src/test/resources/build_with_plugin_disabled.gradle b/dd-sdk-android-gradle-plugin/src/test/resources/build_with_plugin_disabled.gradle new file mode 100644 index 00000000..01a71fcb --- /dev/null +++ b/dd-sdk-android-gradle-plugin/src/test/resources/build_with_plugin_disabled.gradle @@ -0,0 +1,67 @@ +plugins { + id("com.android.application") + id("kotlin-android") + id("com.datadoghq.dd-sdk-android-gradle-plugin") +} + +repositories { + google() + mavenCentral() +} + +android { + compileSdkVersion = 33 + buildToolsVersion = "33.0.1" + + defaultConfig { + applicationId "com.example.variants" + minSdkVersion 21 + targetSdkVersion 33 + 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 = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + flavorDimensions("version", "colour") + productFlavors { + demo { + dimension "version" + applicationIdSuffix ".demo" + versionNameSuffix "-demo" + } + full { + dimension "version" + applicationIdSuffix ".full" + versionNameSuffix "-full" + } + + green { + dimension "colour" + } + blue { + dimension "colour" + } + } +} + +dependencies { + implementation("com.datadoghq:dd-sdk-android-rum:2.2.0") +} + +datadog { + enabled = false +}