├── .codecov.yml ├── .editorconfig ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── .gitlab-ci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile.gitlab ├── LICENSE ├── LICENSE-3rdparty.csv ├── NOTICE ├── README.md ├── ZEN.md ├── build.gradle.kts ├── buildSrc ├── .gitignore ├── build.gradle.kts ├── settings.gradle.kts └── src │ ├── main │ └── kotlin │ │ └── com │ │ └── datadog │ │ └── gradle │ │ ├── Dependencies.kt │ │ ├── KotlinDSLUtils.kt │ │ ├── config │ │ ├── AndroidConfig.kt │ │ ├── BaseExtensionConfig.kt │ │ ├── DependencyUpdateConfig.kt │ │ ├── GradlePropertiesKeys.kt │ │ ├── JUnitConfig.kt │ │ ├── JacocoConfig.kt │ │ ├── JavadocConfig.kt │ │ ├── KotlinConfig.kt │ │ └── MavenConfig.kt │ │ ├── plugin │ │ ├── checklicenses │ │ │ ├── CheckThirdPartyLicensesTask.kt │ │ │ ├── DependenciesLicenseProvider.kt │ │ │ ├── License.kt │ │ │ ├── SPDXLicenceConverter.kt │ │ │ ├── SPDXLicense.kt │ │ │ ├── ThirdPartyDependency.kt │ │ │ ├── ThirdPartyLicensesExtension.kt │ │ │ ├── ThirdPartyLicensesPlugin.kt │ │ │ └── UpdateThirdPartyLicensesTask.kt │ │ └── transdeps │ │ │ ├── TransitiveDependenciesPlugin.kt │ │ │ └── TransitiveDependenciesTask.kt │ │ └── utils │ │ ├── NodeListSequence.kt │ │ ├── SystemUtils.kt │ │ └── Version.kt │ └── test │ └── kotlin │ └── com │ └── datadog │ └── gradle │ └── utils │ └── VersionTest.kt ├── codecov.sh ├── dd-sdk-android-gradle-plugin ├── build.gradle.kts ├── src │ ├── main │ │ └── kotlin │ │ │ └── com │ │ │ └── datadog │ │ │ └── gradle │ │ │ └── plugin │ │ │ ├── CheckSdkDepsTask.kt │ │ │ ├── DatadogSite.kt │ │ │ ├── DdAndroidGradlePlugin.kt │ │ │ ├── DdExtension.kt │ │ │ ├── DdExtensionConfiguration.kt │ │ │ ├── FileUploadTask.kt │ │ │ ├── GenerateBuildIdTask.kt │ │ │ ├── InstrumentationMode.kt │ │ │ ├── MappingFileUploadTask.kt │ │ │ ├── NdkSymbolFileUploadTask.kt │ │ │ ├── RepositoryDetector.kt │ │ │ ├── RepositoryInfo.kt │ │ │ ├── SdkCheckLevel.kt │ │ │ ├── TaskUtils.kt │ │ │ ├── internal │ │ │ ├── ApiKey.kt │ │ │ ├── CurrentAgpVersion.kt │ │ │ ├── DdAppIdentifier.kt │ │ │ ├── GitRepositoryDetector.kt │ │ │ ├── MaxSizeExceededException.kt │ │ │ ├── MissingSdkException.kt │ │ │ ├── OkHttpUploader.kt │ │ │ ├── ProjectExt.kt │ │ │ ├── TaskExt.kt │ │ │ ├── Uploader.kt │ │ │ ├── VariantIterator.kt │ │ │ ├── sanitizer │ │ │ │ ├── FullUriGitRemoteUrlSanitizer.kt │ │ │ │ ├── GitRemoteUrlSanitizer.kt │ │ │ │ ├── ShortUriGitRemoteUrlSanitizer.kt │ │ │ │ ├── UriParsingException.kt │ │ │ │ └── UrlSanitizer.kt │ │ │ └── variant │ │ │ │ ├── AppVariant.kt │ │ │ │ ├── LegacyApiAppVariant.kt │ │ │ │ └── NewApiAppVariant.kt │ │ │ └── kcp │ │ │ ├── ComposeNavHostExtension.kt │ │ │ ├── ComposeNavHostTransformer.kt │ │ │ ├── ComposeTagExtension.kt │ │ │ ├── ComposeTagTransformer.kt │ │ │ ├── DatadogKotlinCompilerPluginCommandLineProcessor.kt │ │ │ ├── DatadogPluginRegistrar.kt │ │ │ ├── DefaultPluginContextUtils.kt │ │ │ ├── IrExt.kt │ │ │ ├── MessageCollectorExt.kt │ │ │ └── PluginContextUtils.kt │ └── test │ │ ├── kotlin │ │ ├── androidx │ │ │ ├── compose │ │ │ │ ├── foundation │ │ │ │ │ └── Image.kt │ │ │ │ └── material │ │ │ │ │ └── Icon.kt │ │ │ └── navigation │ │ │ │ ├── NavController.kt │ │ │ │ ├── NavDestination.kt │ │ │ │ ├── NavHostController.kt │ │ │ │ └── compose │ │ │ │ ├── NavGraphBuilder.kt │ │ │ │ ├── NavHost.kt │ │ │ │ └── NavHostController.kt │ │ ├── coil │ │ │ └── compose │ │ │ │ └── AsyncImage.kt │ │ └── com │ │ │ └── datadog │ │ │ └── gradle │ │ │ └── plugin │ │ │ ├── CheckSdkDepsTaskTest.kt │ │ │ ├── DdAndroidGradlePluginFunctionalTest.kt │ │ │ ├── DdAndroidGradlePluginTest.kt │ │ │ ├── MappingFileUploadTaskTest.kt │ │ │ ├── NdkSymbolFileUploadTaskTest.kt │ │ │ ├── RepositoryInfoTest.kt │ │ │ ├── SystemExt.kt │ │ │ ├── TaskUtilsTest.kt │ │ │ ├── internal │ │ │ ├── GitRepositoryDetectorTest.kt │ │ │ ├── OkHttpUploaderTest.kt │ │ │ ├── VariantIteratorTest.kt │ │ │ ├── sanitizer │ │ │ │ └── GitRemoteUrlSanitizerTest.kt │ │ │ └── variant │ │ │ │ ├── LegacyApiAppVariantTest.kt │ │ │ │ └── NewApiAppVariantTest.kt │ │ │ ├── kcp │ │ │ ├── ComposeNavHostCompilationTest.kt │ │ │ ├── ComposeNavHostExtensionTest.kt │ │ │ ├── ComposeTagCompilationTest.kt │ │ │ ├── ComposeTagExtensionTest.kt │ │ │ ├── ComposeTagTransformerTest.kt │ │ │ ├── DatadogKotlinCompilerPluginCommandLineProcessorTest.kt │ │ │ ├── DefaultPluginContextUtilsTest.kt │ │ │ ├── KotlinCompilerTest.kt │ │ │ └── TestCallbackContainer.kt │ │ │ └── utils │ │ │ ├── CharUtils.kt │ │ │ ├── GitUtils.kt │ │ │ ├── ReflectUtils.kt │ │ │ ├── assertj │ │ │ ├── BuildResultAssert.kt │ │ │ └── RecordedRequestAssert.kt │ │ │ └── forge │ │ │ ├── Configurator.kt │ │ │ ├── DdExtensionConfigurationForgeryFactory.kt │ │ │ ├── DdExtensionForgeryFactory.kt │ │ │ ├── IdentifierForgeryFactory.kt │ │ │ └── RepositoryInfoForgeryFactory.kt │ │ └── resources │ │ ├── build_with_android_components.gradle │ │ ├── build_with_check_deps_disabled.gradle │ │ ├── build_with_check_deps_set_to_warn.gradle │ │ ├── build_with_custom_remote_repos_url.gradle │ │ ├── build_with_datadog_dep.gradle │ │ ├── build_with_lib_module_attached.gradle │ │ ├── build_with_minify_not_enabled.gradle │ │ ├── build_with_non_default_obfuscation.gradle │ │ ├── build_with_optimized_mapping.gradle │ │ ├── build_with_plugin_disabled.gradle │ │ ├── build_with_variant_override.gradle │ │ ├── build_without_datadog_dep.gradle │ │ ├── lib_module_build.gradle │ │ ├── mapping-with-aliases.txt │ │ ├── mapping.txt │ │ ├── mockito-extensions │ │ └── org.mockito.plugins.MockMaker │ │ └── native_gradle_files │ │ ├── build_with_custom_ndk.gradle │ │ ├── build_with_custom_ndk_no_externalNativeBuild.gradle │ │ ├── build_with_native_and_datadog_dep.gradle │ │ └── build_with_proguard_native_and_datadog_dep.gradle └── transitiveDependencies ├── docs └── images │ ├── deobfuscated_stacktrace.png │ └── obfuscated_stacktrace.png ├── dogfood.py ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── instrumented ├── build.gradle.kts └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── datadog │ │ └── android │ │ └── instrumented │ │ ├── NavigationTest.kt │ │ └── SemanticsTest.kt │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── datadog │ └── android │ └── instrumented │ ├── NavHostTestScreen.kt │ └── TagTestScreen.kt ├── libs └── dd-java-agent-1.26.1.jar ├── samples ├── basic │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── datadog │ │ │ └── example │ │ │ └── basic │ │ │ ├── MainActivity.kt │ │ │ └── Toaster.kt │ │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml ├── lib-module │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ └── kotlin │ │ └── com │ │ └── datadog │ │ ├── android │ │ └── compose │ │ │ ├── ComposeInstrumentation.kt │ │ │ └── DatadogModifier.kt │ │ └── example │ │ └── lib │ │ └── Placeholder.kt ├── ndk │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ ├── CMakeLists.txt │ │ └── native_code.cpp │ │ ├── java │ │ └── com │ │ │ └── datadog │ │ │ └── example │ │ │ └── ndk │ │ │ ├── MainActivity.kt │ │ │ └── Toaster.kt │ │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml ├── variants-kotlin │ ├── .gitignore │ ├── build.gradle.kts │ ├── proguard-rules.pro │ └── src │ │ ├── demo │ │ └── java │ │ │ └── com │ │ │ └── datadog │ │ │ └── example │ │ │ └── variants │ │ │ └── VaryingClass.kt │ │ ├── full │ │ └── java │ │ │ └── com │ │ │ └── datadog │ │ │ └── example │ │ │ └── variants │ │ │ └── VaryingClass.kt │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── datadog │ │ │ │ └── example │ │ │ │ └── variants │ │ │ │ ├── MainActivity.kt │ │ │ │ └── VaryingInfo.kt │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── datadog │ │ │ │ └── example │ │ │ │ └── variants │ │ │ │ └── ext │ │ │ │ └── ActivityExt.kt │ │ └── res │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── pro │ │ └── java │ │ └── com │ │ └── datadog │ │ └── example │ │ └── variants │ │ └── VaryingClass.kt └── variants │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── demo │ └── java │ │ └── com │ │ └── datadog │ │ └── example │ │ └── variants │ │ └── VaryingClass.kt │ ├── full │ └── java │ │ └── com │ │ └── datadog │ │ └── example │ │ └── variants │ │ └── VaryingClass.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── datadog │ │ │ └── example │ │ │ └── variants │ │ │ ├── MainActivity.kt │ │ │ └── VaryingInfo.kt │ ├── kotlin │ │ └── com │ │ │ └── datadog │ │ │ └── example │ │ │ └── variants │ │ │ └── ext │ │ │ └── ActivityExt.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── pro │ └── java │ └── com │ └── datadog │ └── example │ └── variants │ └── VaryingClass.kt └── settings.gradle.kts /.codecov.yml: -------------------------------------------------------------------------------- 1 | # https://docs.codecov.io/docs/codecovyml-reference 2 | codecov: 3 | notify: 4 | require_ci_to_pass: no 5 | wait_for_ci: no 6 | 7 | comment: 8 | behavior: default 9 | layout: header, diff, tree 10 | require_changes: false 11 | require_base: no 12 | 13 | coverage: 14 | precision: 2 15 | range: "75..95" 16 | round: nearest 17 | 18 | ignore: 19 | - build 20 | - .*/build/.* 21 | - .*/src/test/.* 22 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 2 | # This product includes software developed at Datadog (https://www.datadoghq.com/). 3 | # Copyright 2016-Present Datadog, Inc. 4 | 5 | [*.{kt,kts}] 6 | ktlint_code_style = android_studio 7 | ij_kotlin_allow_trailing_comma_on_call_site = false 8 | ij_kotlin_allow_trailing_comma = false 9 | ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ 10 | max_line_length = 120 11 | 12 | # SPDX License Names 13 | [buildSrc/src/main/kotlin/com/datadog/gradle/plugin/checklicenses/SPDXLicense.kt] 14 | ktlint_standard_enum-entry-name-case = disabled 15 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Global code owners - RUM Mobile Team 2 | 3 | * @DataDog/rum-mobile @DataDog/rum-mobile-android 4 | 5 | ## Docs 6 | 7 | /docs/ @DataDog/documentation @DataDog/rum-mobile 8 | *README.md @DataDog/documentation @DataDog/rum-mobile 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | Thanks for taking the time for reporting an issue! 11 | 12 | **Describe what happened** 13 | Include any error message or stack trace if available. 14 | 15 | **Steps to reproduce the issue:** 16 | 17 | **Describe what you expected:** 18 | 19 | **Additional context** 20 | - Android Build Tools version: 21 | - Gradle version: 22 | - OS version: 23 | - Plugin version: 24 | - Proguard configuration: 25 | - Other Gradle Plugins: 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### What does this PR do? 2 | 3 | A brief description of the change being made with this pull request. 4 | 5 | ### Motivation 6 | 7 | What inspired you to submit this pull request? 8 | 9 | ### Additional Notes 10 | 11 | Anything else we should know when reviewing? 12 | 13 | ### Review checklist (to be filled by reviewers) 14 | 15 | - [ ] Feature or bugfix MUST have appropriate tests (unit, integration, e2e) 16 | - [ ] Make sure you discussed the feature or bugfix with the maintaining team in an Issue 17 | - [ ] Make sure each commit and the PR mention the Issue number (cf the [CONTRIBUTING](CONTRIBUTING.md) doc) 18 | 19 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ "**" ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [ "main", "develop", "release/**", "feature/**" ] 9 | 10 | jobs: 11 | analyze: 12 | name: Analyze 13 | runs-on: ubuntu-latest 14 | permissions: 15 | actions: read 16 | contents: read 17 | security-events: write 18 | 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | language: [ 'java' ] 23 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 24 | # Use only 'java' to analyze code written in Java, Kotlin or both 25 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 26 | 27 | steps: 28 | - name: Checkout repository 29 | uses: actions/checkout@v3 30 | 31 | - name: Setup Java 17 32 | uses: actions/setup-java@v1 33 | with: 34 | java-version: 17 35 | 36 | # Initializes the CodeQL tools for scanning. 37 | - name: Initialize CodeQL 38 | uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 39 | with: 40 | languages: ${{ matrix.language }} 41 | # If you wish to specify custom queries, you can do so here or in a config file. 42 | # By default, queries listed here will override any specified in a config file. 43 | # Prefix the list here with "+" to use these queries and those in the config file. 44 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 45 | # queries: security-extended,security-and-quality 46 | 47 | 48 | - name: Setup Gradle 49 | uses: gradle/gradle-build-action@v2.4.2 50 | with: 51 | gradle-version: 8.11.1 52 | 53 | # Manually build the java bytecode 54 | - name: Execute Gradle build 55 | run: ./gradlew :dd-sdk-android-gradle-plugin:assemble 56 | 57 | # Perform the analysis 58 | - name: Perform CodeQL Analysis 59 | uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 60 | with: 61 | category: "/language:${{matrix.language}}" 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # IntelliJ 3 | *.iml 4 | .idea/ 5 | 6 | # Android Studio 3+ 7 | .navigation/ 8 | captures/ 9 | .externalNativeBuild 10 | 11 | # Gradle files 12 | .gradle/ 13 | build/ 14 | 15 | # CMake 16 | .cxx/ 17 | 18 | # Local configuration file (sdk path, etc) 19 | local.properties 20 | repo/ 21 | 22 | # MacOS garbage 23 | .DS_Store 24 | 25 | -------------------------------------------------------------------------------- /LICENSE-3rdparty.csv: -------------------------------------------------------------------------------- 1 | Component,Origin,License,Copyright 2 | build,com.pinterest,MIT,"Copyright 2019 Pinterest Inc, Copyright 2016-2019 Stanley Shyiko" 3 | build,com.pinterest.ktlint,MIT,"Copyright 2019 Pinterest Inc, Copyright 2016-2019 Stanley Shyiko" 4 | build,io.gitlab.arturbosch.detekt,Apache-2.0,Copyright 2016-2019 the original author or authors 5 | build,org.ec4j.core,Apache-2.0,"Copyright (c) 2017 Angelo Zerr and other contributors" 6 | build,org.jetbrains.dokka,Apache-2.0,"Copyright 2014-2019 JetBrains s.r.o. and Dokka project contributors." 7 | build,org.jetbrains.intellij.deps,LGPL-2.1-only,"Copyright (c) 2001-2002, Eric D. Friedman, Jason Baldridge, Copyright (c) 1999 CERN - European Organization for Nuclear Research" 8 | import,com.android.tools.build,Apache-2.0,Copyright (C) 2013 The Android Open Source Project 9 | import,com.squareup.okhttp3,Apache-2.0,"Copyright 2019 Square, Inc" 10 | import,org.jetbrains,Apache-2.0,Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors 11 | import,org.jetbrains.kotlin,Apache-2.0,Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors 12 | import,com.google.auto.service,Apache-2.0,Copyright 2013 Google LLC 13 | import,org.json,JSON,Copyright (c) 2002 JSON.org 14 | import(test),androidx.compose,Apache-2.0,Copyright 2019 The Android Open Source Project 15 | import(test),androidx.compose.ui,Apache-2.0,Copyright 2019 The Android Open Source Project 16 | import(test),com.android.tools.build,Apache-2.0,Copyright (C) 2013 The Android Open Source Project 17 | import(test),dev.zacsweers.kctfork,MPL-2.0,Copyright (C) 2023 Thilo Schuchort 18 | import(test),com.github.xgouchet.Elmyr,MIT,Copyright 2017-2019 Xavier F. Gouchet 19 | import(test),net.wuerl.kotlin,Apache-2.0,Copyright 2016 Andreas Würl 20 | import(test),org.assertj,Apache-2.0,Copyright 2012-2019 the original author or authors 21 | import(test),org.jacoco,EPL-2.0,"Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors" 22 | import(test),org.junit.jupiter,EPL-2.0,Copyright 2015-2019 the original author or authors 23 | import(test),org.junit.platform,EPL-2.0,Copyright 2015-2019 the original author or authors 24 | import(test),org.junit.vintage,EPL-2.0,Copyright 2015-2019 the original author or authors 25 | import(test),org.mockito,MIT,Copyright (c) 2007 Mockito contributors 26 | import(test),org.mockito.kotlin,MIT,"Copyright (c) 2016 Niek Haarman, Copyright (c) 2007 Mockito contributors" 27 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Datadog dd-sdk-android 2 | Copyright 2019 Datadog, Inc. 3 | 4 | This product includes software developed at Datadog (https://www.datadoghq.com/). -------------------------------------------------------------------------------- /ZEN.md: -------------------------------------------------------------------------------- 1 | # Mobile RUM SDK Philosophy 2 | 3 | ## TL;DR; 4 | 5 | > Always keep in mind that this library lives on our users' users' device, within our user's applications. We need to be **stable**, **efficient** and **transparent**. 6 | 7 | ## Foreword 8 | 9 | This SDK lives in our customer’s applications, and is run on end users devices. Because those devices can range from low to high end, and can be used in varying conditions of network and battery, we need to make sure our footprint on the end user experience is as small as possible. 10 | 11 | ## Small Footprint 12 | 13 | - **Runtime performance** 14 | - Do not perform unnecessary operation; 15 | - Every public operation must be executed fast; 16 | - Delegate heavy work to background threads/workers when possible; 17 | - **Library size** 18 | - Avoid unnecessary dependencies; 19 | - **Network load** 20 | - Batch requests as much as possible; 21 | - Avoid making request when the device is asleep or has low battery; 22 | 23 | ## Stability 24 | 25 | - **Zero crash caused by our code!** 26 | - Unless the crash is on top-level method, caused by identifiable developer mistake, and notified with an understandable error message; 27 | - Even in top-level methods, prefer making the library non operating and logging the issue in the console logs, rather than throwing an exception 28 | - **Avoid major breaking changes** in SDK updates. 29 | - Updating to the latest version must be transparent (unless when changing major version). 30 | - Minor breaking change (single method signature change, renaming, deprecation…) can happen in minor updates but should be avoided when possible. 31 | 32 | ## Compatibility 33 | 34 | - Support old versions of the OS’s 35 | - Android: KitKat (5 years old) 36 | - Support all main languages; especially the behavior should be the same for any language, but can be enhanced for modern languages. 37 | - Android: Java/Kotlin 38 | - Support vanilla flavors of the OS first, and add possible extensions for derived flavors of the OSs (Watch, TV, …) 39 | 40 | ## API Design 41 | 42 | - **Start small, extend slowly** 43 | - **Keep new API consistent** 44 | - with previous APIs; 45 | - with other Datadog products APIs; 46 | - with Android community's best practices; 47 | - Keep backward compatibility on minor updates 48 | 49 | ## Trust 50 | 51 | - Use sensible static analysis tools 52 | - Use benchmark tools to measure the performance of the library 53 | - All parts of the libraries must be thoroughly tested 54 | 55 | 56 | ## Workflow 57 | 58 | - All code must be tested and reviewed; 59 | - Keep your PR small (each PR must solve one and only one issue); 60 | - Keep your PR as Draft until it's ready to be reviewed; 61 | 62 | ## Code architecture 63 | 64 | - Favor Object Oriented design, rather than procedural programing; 65 | - Favor code stability and maintainability; 66 | - Follow the SOLID principles; 67 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | buildscript { 8 | repositories { 9 | google() 10 | mavenCentral() 11 | maven { setUrl(com.datadog.gradle.Dependencies.Repositories.Gradle) } 12 | mavenLocal() 13 | } 14 | 15 | dependencies { 16 | classpath(libs.androidToolsPluginGradle) 17 | classpath(libs.kotlinPluginGradle) 18 | classpath(libs.dokkaPluginGradle) 19 | // Uncomment to use the samples 20 | // classpath(libs.datadogPluginGradle) 21 | } 22 | } 23 | 24 | allprojects { 25 | repositories { 26 | google() 27 | mavenCentral() 28 | maven { setUrl(com.datadog.gradle.Dependencies.Repositories.Jitpack) } 29 | maven("https://oss.sonatype.org/content/repositories/snapshots/") 30 | } 31 | } 32 | 33 | task("clean") { 34 | delete(rootProject.buildDir) 35 | } 36 | 37 | // Empty task defined by one of our CI pipeline which does not apply here. 38 | tasks.register("checkGeneratedFiles") {} 39 | -------------------------------------------------------------------------------- /buildSrc/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *.aab 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | 17 | # Gradle files 18 | build/ -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | plugins { 8 | `kotlin-dsl` 9 | id("java-gradle-plugin") 10 | @Suppress("DSL_SCOPE_VIOLATION") 11 | alias(libs.plugins.versionsPluginGradle) 12 | } 13 | 14 | buildscript { 15 | repositories { 16 | mavenCentral() 17 | } 18 | } 19 | 20 | apply(plugin = "kotlin") 21 | 22 | repositories { 23 | mavenCentral() 24 | google() 25 | maven { setUrl("https://plugins.gradle.org/m2/") } 26 | maven { setUrl("https://maven.google.com") } 27 | maven { setUrl("https://jitpack.io") } 28 | } 29 | 30 | dependencies { 31 | 32 | // Dependencies used to configure the gradle plugins 33 | implementation(embeddedKotlin("gradle-plugin")) 34 | implementation(libs.androidToolsPluginGradle) 35 | implementation(libs.versionsPluginGradle) 36 | implementation(libs.fuzzyWuzzy) 37 | implementation(libs.dokkaPluginGradle) 38 | 39 | // Tests 40 | testImplementation(libs.jUnit4) 41 | testImplementation(libs.mockitoKotlin) 42 | testImplementation(libs.elmyr.core) 43 | testImplementation(libs.elmyr.inject) 44 | testImplementation(libs.elmyr.jUnit4) 45 | testImplementation(libs.elmyr.jvm) 46 | } 47 | 48 | gradlePlugin { 49 | plugins { 50 | register("thirdPartyLicences") { 51 | id = "thirdPartyLicences" // the alias 52 | implementationClass = "com.datadog.gradle.plugin.checklicenses.ThirdPartyLicensesPlugin" 53 | } 54 | register("transitiveDependencies") { 55 | id = "transitiveDependencies" // the alias 56 | implementationClass = "com.datadog.gradle.plugin.transdeps.TransitiveDependenciesPlugin" 57 | } 58 | } 59 | } 60 | 61 | tasks { 62 | register("copyTestRes") { 63 | from("$projectDir/src/test/kotlin/com/example/model") 64 | into("$projectDir/src/test/resources/output") 65 | } 66 | 67 | register("deleteTestRes") { 68 | delete("$projectDir/src/test/resources/output/") 69 | } 70 | } 71 | 72 | tasks.named("test") { 73 | dependsOn("copyTestRes") 74 | finalizedBy("deleteTestRes") 75 | } 76 | -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | dependencyResolutionManagement { 8 | versionCatalogs { 9 | create("libs") { 10 | from(files("../gradle/libs.versions.toml")) 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/Dependencies.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle 8 | 9 | object Dependencies { 10 | 11 | object Versions { 12 | // Tests Tools 13 | const val Jacoco = "0.8.7" 14 | } 15 | 16 | object Repositories { 17 | const val Gradle = "https://plugins.gradle.org/m2/" 18 | const val Jitpack = "https://jitpack.io" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/KotlinDSLUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle 8 | 9 | import org.gradle.api.artifacts.dsl.DependencyHandler 10 | 11 | fun DependencyHandler.api(dependencies: Array) { 12 | dependencies.forEach { 13 | add("api", it) 14 | } 15 | } 16 | 17 | fun DependencyHandler.compile(dependencies: Array) { 18 | dependencies.forEach { 19 | add("compile", it) 20 | } 21 | } 22 | 23 | fun DependencyHandler.compileOnly(dependencies: Array) { 24 | dependencies.forEach { 25 | add("compileOnly", it) 26 | } 27 | } 28 | 29 | fun DependencyHandler.testCompile(dependencies: Array) { 30 | dependencies.forEach { 31 | add("testCompile", it) 32 | } 33 | } 34 | 35 | fun DependencyHandler.implementation(dependencies: Array) { 36 | dependencies.forEach { 37 | add("implementation", it) 38 | } 39 | } 40 | 41 | fun DependencyHandler.testImplementation(dependencies: Array) { 42 | dependencies.forEach { 43 | add("testImplementation", it) 44 | } 45 | } 46 | 47 | fun DependencyHandler.androidTestImplementation(dependencies: Array) { 48 | dependencies.forEach { 49 | add("androidTestImplementation", it) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/AndroidConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | 9 | object AndroidConfig { 10 | 11 | const val TARGET_SDK = 35 12 | const val MIN_SDK = 21 13 | const val BUILD_TOOLS_VERSION = "35.0.0" 14 | } 15 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/BaseExtensionConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | 9 | import org.gradle.api.Project 10 | import org.gradle.api.Task 11 | import org.gradle.kotlin.dsl.findByType 12 | 13 | inline fun Project.extensionConfig( 14 | crossinline configure: T.() -> Unit 15 | ) { 16 | project.afterEvaluate { 17 | val ext: T? = extensions.findByType(T::class) 18 | ext?.configure() 19 | } 20 | } 21 | 22 | inline fun Project.taskConfig( 23 | crossinline configure: T.() -> Unit 24 | ) { 25 | project.afterEvaluate { 26 | tasks.withType(T::class.java) { configure() } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/DependencyUpdateConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | 9 | import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask 10 | import org.gradle.api.Project 11 | 12 | fun Project.dependencyUpdateConfig() { 13 | taskConfig { 14 | revision = "release" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/GradlePropertiesKeys.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | object GradlePropertiesKeys { 9 | 10 | // you can set this property from your gradle.properties as: forceEnableLogcat = true | false 11 | const val FORCE_ENABLE_LOGCAT = "forceEnableLogcat" 12 | } 13 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/JUnitConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | 9 | import org.gradle.api.Project 10 | import org.gradle.api.tasks.testing.Test 11 | 12 | fun Project.junitConfig() { 13 | tasks.withType(Test::class.java) { 14 | jvmArgs( 15 | "--add-opens=java.base/java.lang.invoke=ALL-UNNAMED", 16 | "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED", 17 | "--add-opens=java.base/java.net=ALL-UNNAMED", 18 | "--add-opens=java.base/java.util.concurrent=ALL-UNNAMED", 19 | "--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED", 20 | "--add-opens=java.base/java.util=ALL-UNNAMED" 21 | ) 22 | useJUnitPlatform { 23 | includeEngines("spek", "junit-jupiter", "junit-vintage") 24 | } 25 | reports { 26 | junitXml.required.set(true) 27 | html.required.set(true) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/JacocoConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | 9 | import com.datadog.gradle.Dependencies 10 | import org.gradle.api.Project 11 | import org.gradle.kotlin.dsl.getByName 12 | import org.gradle.testing.jacoco.plugins.JacocoPluginExtension 13 | import org.gradle.testing.jacoco.tasks.JacocoCoverageVerification 14 | import org.gradle.testing.jacoco.tasks.JacocoReport 15 | import java.math.BigDecimal 16 | 17 | fun Project.jacocoConfig() { 18 | val jacocoTestReport = tasks.getByName("jacocoTestReport", JacocoReport::class) 19 | jacocoTestReport.reports { 20 | csv.required.set(false) 21 | xml.required.set(true) 22 | html.required.set(true) 23 | html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco/jacocoTestReport/html")) 24 | } 25 | 26 | val jacocoTestCoverageVerification = tasks.getByName( 27 | "jacocoTestCoverageVerification", 28 | JacocoCoverageVerification::class 29 | ) 30 | jacocoTestCoverageVerification.violationRules { 31 | rule { 32 | limit { 33 | // TODO increase that when coverage is better? 34 | minimum = BigDecimal(0.70) 35 | } 36 | } 37 | } 38 | 39 | listOf( 40 | jacocoTestReport, 41 | jacocoTestCoverageVerification 42 | ).forEach { task -> 43 | 44 | val mainSrc = "${project.projectDir}/src/main/kotlin" 45 | 46 | task.executionData.setFrom(files("${buildDir.path}/jacoco/test.exec")) 47 | task.sourceDirectories.setFrom(files(mainSrc)) 48 | } 49 | jacocoTestReport.dependsOn("test") 50 | jacocoTestCoverageVerification.dependsOn(jacocoTestReport) 51 | 52 | extensionConfig { 53 | toolVersion = Dependencies.Versions.Jacoco 54 | reportsDirectory.set(layout.buildDirectory.dir("jacoco")) // Jacoco's output root. 55 | } 56 | 57 | tasks.named("check") { 58 | dependsOn(jacocoTestReport) 59 | dependsOn(jacocoTestCoverageVerification) 60 | } 61 | 62 | tasks.named("test") { 63 | finalizedBy( 64 | jacocoTestReport, 65 | jacocoTestCoverageVerification 66 | ) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/JavadocConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | 9 | import org.gradle.api.Project 10 | import org.jetbrains.dokka.gradle.DokkaTask 11 | 12 | fun Project.javadocConfig() { 13 | tasks.withType(DokkaTask::class.java) { 14 | val toOutputDirectory = file("${buildDir.canonicalPath}/reports/javadoc") 15 | outputDirectory.set(toOutputDirectory) 16 | doFirst { 17 | if (!toOutputDirectory.exists()) { 18 | toOutputDirectory.mkdirs() 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/config/KotlinConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.config 8 | 9 | import org.gradle.api.JavaVersion 10 | import org.gradle.api.Project 11 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 12 | 13 | fun Project.kotlinConfig() { 14 | taskConfig { 15 | kotlinOptions { 16 | // TODO RUMM-3257 Target Java 17 bytecode at some point 17 | jvmTarget = JavaVersion.VERSION_11.toString() 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/plugin/checklicenses/License.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.checklicenses 8 | 9 | sealed class License { 10 | 11 | data class SPDX(val licenses: List) : License() { 12 | override fun toString(): String { 13 | return licenses.joinToString("/") { it.csvName } 14 | } 15 | } 16 | 17 | data class Raw(val value: String) : License() { 18 | override fun toString(): String { 19 | return "\"$value\"" 20 | } 21 | } 22 | 23 | object Empty : License() { 24 | override fun toString(): String { 25 | return "__" 26 | } 27 | } 28 | 29 | companion object { 30 | fun from(license: String?): License { 31 | val licenseOrEmpty = license.orEmpty() 32 | val matches = 33 | SPDXLicenceConverter.convert( 34 | licenseOrEmpty 35 | ) 36 | return when { 37 | licenseOrEmpty.isEmpty() -> Empty 38 | matches.isNullOrEmpty() -> Raw( 39 | licenseOrEmpty 40 | ) 41 | else -> SPDX( 42 | matches 43 | ) 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/plugin/checklicenses/ThirdPartyDependency.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.checklicenses 8 | 9 | data class ThirdPartyDependency( 10 | val component: Component, 11 | val origin: String, 12 | val license: License, 13 | val copyright: String 14 | ) { 15 | enum class Component(val csvName: String) { 16 | IMPORT("import"), 17 | IMPORT_TEST("import(test)"), 18 | BUILD("build"), 19 | UNKNOWN("__") 20 | } 21 | 22 | override fun toString(): String { 23 | return "${component.csvName},$origin,$license,__" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/plugin/checklicenses/ThirdPartyLicensesExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.checklicenses 8 | 9 | import java.io.File 10 | 11 | open class ThirdPartyLicensesExtension( 12 | var csvFile: File = File(DEFAULT_TP_LICENCE_FILENAME), 13 | var listDependencyOnce: Boolean = true, 14 | var transitiveDependencies: Boolean = false, 15 | var checkObsoleteDependencies: Boolean = false 16 | ) { 17 | companion object { 18 | const val DEFAULT_TP_LICENCE_FILENAME = "LICENSE-3rdparty.csv" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/plugin/checklicenses/ThirdPartyLicensesPlugin.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.checklicenses 8 | 9 | import com.android.build.gradle.internal.tasks.factory.dependsOn 10 | import org.gradle.api.Plugin 11 | import org.gradle.api.Project 12 | import java.io.File 13 | 14 | class ThirdPartyLicensesPlugin : Plugin { 15 | 16 | override fun apply(target: Project) { 17 | val extension = target.extensions 18 | .create(EXT_NAME, ThirdPartyLicensesExtension::class.java) 19 | extension.csvFile = File( 20 | target.rootDir, 21 | ThirdPartyLicensesExtension.DEFAULT_TP_LICENCE_FILENAME 22 | ) 23 | 24 | val updateTask = target.tasks 25 | .create(TASK_UPDATE_NAME, UpdateThirdPartyLicensesTask::class.java) 26 | updateTask.extension = extension 27 | 28 | val checkTask = target.tasks 29 | .create(TASK_CHECK_NAME, CheckThirdPartyLicensesTask::class.java) 30 | checkTask.extension = extension 31 | 32 | target.tasks.named("check").dependsOn(TASK_CHECK_NAME) 33 | } 34 | 35 | companion object { 36 | const val EXT_NAME = "thirdPartyLicences" 37 | 38 | const val TASK_UPDATE_NAME = "updateThirdPartyLicences" 39 | const val TASK_CHECK_NAME = "checkThirdPartyLicences" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/plugin/checklicenses/UpdateThirdPartyLicensesTask.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.checklicenses 8 | 9 | import org.gradle.api.DefaultTask 10 | import org.gradle.api.tasks.Input 11 | import org.gradle.api.tasks.TaskAction 12 | 13 | open class UpdateThirdPartyLicensesTask : DefaultTask() { 14 | 15 | @get: Input 16 | internal var extension: ThirdPartyLicensesExtension = 17 | ThirdPartyLicensesExtension() 18 | private val provider: DependenciesLicenseProvider = 19 | DependenciesLicenseProvider() 20 | 21 | init { 22 | group = "datadog" 23 | description = "Lists Third Party Licences in a csv file" 24 | } 25 | 26 | // region Task 27 | 28 | @TaskAction 29 | fun applyTask() { 30 | val dependencies = provider.getThirdPartyDependencies( 31 | project, 32 | extension.transitiveDependencies, 33 | extension.listDependencyOnce 34 | ) 35 | 36 | extension.csvFile.printWriter().use { writer -> 37 | writer.println("Component,Origin,License,Copyright") 38 | dependencies 39 | .forEach { 40 | writer.println(it.toString()) 41 | } 42 | } 43 | } 44 | 45 | // endregion 46 | } 47 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/plugin/transdeps/TransitiveDependenciesPlugin.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.transdeps 8 | 9 | import com.datadog.gradle.config.taskConfig 10 | import org.gradle.api.Plugin 11 | import org.gradle.api.Project 12 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 13 | import java.io.File 14 | 15 | class TransitiveDependenciesPlugin : Plugin { 16 | 17 | override fun apply(target: Project) { 18 | val task = target.tasks.create(TASK_NAME, TransitiveDependenciesTask::class.java) 19 | task.outputFile = File(target.projectDir, FILE_NAME) 20 | 21 | target.taskConfig { 22 | finalizedBy(TASK_NAME) 23 | } 24 | } 25 | 26 | companion object { 27 | 28 | const val TASK_NAME = "listTransitiveDependencies" 29 | const val FILE_NAME = "transitiveDependencies" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/utils/NodeListSequence.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.utils 8 | 9 | import org.w3c.dom.Node 10 | import org.w3c.dom.NodeList 11 | import kotlin.collections.Iterator as KIterator 12 | 13 | class NodeListSequence( 14 | private val nodeList: NodeList 15 | ) : Sequence { 16 | 17 | override fun iterator(): KIterator { 18 | return Iterator(nodeList) 19 | } 20 | 21 | @Suppress("IteratorNotThrowingNoSuchElementException") 22 | class Iterator( 23 | private val nodeList: NodeList 24 | ) : KIterator { 25 | private var i = 0 26 | override fun hasNext() = nodeList.length > i 27 | override fun next(): Node = nodeList.item(i++) 28 | } 29 | } 30 | 31 | fun NodeList.asSequence() = NodeListSequence(this) 32 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/utils/SystemUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.utils 8 | 9 | import org.gradle.api.Project 10 | import java.io.ByteArrayInputStream 11 | import java.io.ByteArrayOutputStream 12 | import java.io.InputStreamReader 13 | 14 | fun Project.execShell(vararg command: String): List { 15 | val outputStream = ByteArrayOutputStream() 16 | this.exec { 17 | commandLine(*command) 18 | standardOutput = outputStream 19 | } 20 | 21 | val reader = InputStreamReader(ByteArrayInputStream(outputStream.toByteArray())) 22 | return reader.readLines() 23 | } 24 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/com/datadog/gradle/utils/Version.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.utils 8 | 9 | data class Version( 10 | val major: Int, 11 | val minor: Int, 12 | val hotfix: Int, 13 | val type: Type = Type.Release 14 | ) { 15 | 16 | // region Type 17 | 18 | sealed class Type { 19 | 20 | abstract val suffix: String 21 | 22 | object Release : Type() { 23 | override val suffix: String = "" 24 | } 25 | 26 | data class ReleaseCandidate(val number: Int) : Type() { 27 | override val suffix: String = "-rc$number" 28 | } 29 | 30 | data class Beta(val number: Int) : Type() { 31 | override val suffix: String = "-beta$number" 32 | } 33 | 34 | data class Alpha(val number: Int) : Type() { 35 | override val suffix: String = "-alpha$number" 36 | } 37 | 38 | object Dev : Type() { 39 | override val suffix: String = "-dev" 40 | } 41 | 42 | object Snapshot : Type() { 43 | override val suffix: String = "-SNAPSHOT" 44 | } 45 | } 46 | 47 | // endregion 48 | 49 | init { 50 | require(major < MAX_MAJOR) { "The minor component must be smaller than $MAX_MAJOR" } 51 | require(minor < MAX_MINOR) { "The minor component must be smaller than $MAX_MINOR" } 52 | require(hotfix < MAX_HOTFIX) { "The hotfix component must be smaller than $MAX_HOTFIX" } 53 | } 54 | 55 | /** 56 | * @return a human readable Semantic Version name based on the information, with an optional suffix 57 | * (eg: 1.0.0, 2.3.0-rc1, 0.0.4-alpha1, etc...). 58 | * ** See also ** [Semantic Versioning](https://semver.org/) 59 | */ 60 | val name: String 61 | get() { 62 | return "$major.$minor.$hotfix${type.suffix}" 63 | } 64 | 65 | /** 66 | * @return an Android compatible version code as a unique integer. 67 | */ 68 | val code: Int 69 | get() { 70 | val minPart = minor * MAX_HOTFIX 71 | val majPart = major * MAX_MINOR * MAX_HOTFIX 72 | 73 | return hotfix + minPart + majPart 74 | } 75 | 76 | companion object { 77 | internal const val MAX_HOTFIX = 10 78 | internal const val MAX_MINOR = 100 79 | internal const val MAX_MAJOR = 100 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DatadogSite.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | /** 10 | * Defines the Datadog sites you can send tracked data to. 11 | */ 12 | enum class DatadogSite(internal val domain: String) { 13 | /** 14 | * The US1 site: [app.datadoghq.com](https://app.datadoghq.com) (legacy name). 15 | */ 16 | US("datadoghq.com"), 17 | 18 | /** 19 | * The US1 site: [app.datadoghq.com](https://app.datadoghq.com). 20 | */ 21 | US1("datadoghq.com"), 22 | 23 | /** 24 | * The US3 site: [us3.datadoghq.com](https://us3.datadoghq.com). 25 | */ 26 | US3("us3.datadoghq.com"), 27 | 28 | /** 29 | * The US5 site: [us5.datadoghq.com](https://us5.datadoghq.com). 30 | */ 31 | US5("us5.datadoghq.com"), 32 | 33 | /** 34 | * The US1_FED site (FedRAMP compatible): [app.ddog-gov.com](https://app.ddog-gov.com) (legacy name). 35 | */ 36 | GOV("ddog-gov.com"), 37 | 38 | /** 39 | * The US1_FED site (FedRAMP compatible): [app.ddog-gov.com](https://app.ddog-gov.com). 40 | */ 41 | US1_FED("ddog-gov.com"), 42 | 43 | /** 44 | * The EU1 site: [app.datadoghq.eu](https://app.datadoghq.eu) (legacy name). 45 | */ 46 | EU("datadoghq.eu"), 47 | 48 | /** 49 | * The EU1 site: [app.datadoghq.eu](https://app.datadoghq.eu). 50 | */ 51 | EU1("datadoghq.eu"), 52 | 53 | /** 54 | * The AP1 site: [ap1.datadoghq.com](https://ap1.datadoghq.com). 55 | */ 56 | AP1("ap1.datadoghq.com"), 57 | 58 | /** 59 | * The STAGING site (internal usage only): [app.datad0g.com](https://app.datad0g.com). 60 | */ 61 | STAGING("datad0g.com"); 62 | 63 | /** 64 | * Returns the endpoint to use to upload sourcemap to this site. 65 | */ 66 | internal fun uploadEndpoint(): String { 67 | return "https://sourcemap-intake.$domain/api/v2/srcmap" 68 | } 69 | 70 | internal fun apiKeyVerificationEndpoint(): String { 71 | return "https://api.$domain/api/v1/validate" 72 | } 73 | 74 | companion object { 75 | internal val validIds = DatadogSite.values().map { it.name } 76 | 77 | internal fun fromDomain(domain: String): DatadogSite? { 78 | return DatadogSite.values().firstOrNull { it.domain == domain } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/DdExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | import groovy.lang.Closure 10 | import org.gradle.api.model.ObjectFactory 11 | import javax.inject.Inject 12 | 13 | /** 14 | * Extension used to configure the `dd-android-gradle-plugin`. 15 | */ 16 | open class DdExtension( 17 | @Inject private val objectFactory: ObjectFactory 18 | ) : DdExtensionConfiguration() { 19 | 20 | /** 21 | * Whether the plugin should be enabled or not. 22 | */ 23 | var enabled: Boolean = true 24 | 25 | /** 26 | * Container for the variant's configurations. 27 | */ 28 | internal val variants = objectFactory.domainObjectContainer(DdExtensionConfiguration::class.java) 29 | 30 | /** 31 | * Closure method to create a groovy DSL for variant configurations. 32 | */ 33 | fun variants(configureClosure: Closure) { 34 | variants.configure(configureClosure) 35 | } 36 | 37 | /** 38 | * Method compatible with Kotlin Script to create a DSL for variant configurations. 39 | */ 40 | fun variants(configure: VariantScope.() -> Unit) { 41 | configure(VariantScope()) 42 | } 43 | 44 | /** 45 | * Inner class used for Kotlin DSL. 46 | */ 47 | inner class VariantScope { 48 | 49 | /** 50 | * Defines a new named object, which will be created and configured when it is required. 51 | * @param name the name of the variant to configure 52 | * @param configuration the action to run to configure the variant 53 | */ 54 | fun register(name: String, configuration: DdExtensionConfiguration.() -> Unit) { 55 | variants.register(name) { 56 | configuration(it) 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/InstrumentationMode.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.gradle.plugin 2 | 3 | /** 4 | * Defines the mode of instrumentation for the plugin. 5 | * 6 | * This enum controls how the plugin applies instrumentation to the code, based on the selected mode. 7 | */ 8 | enum class InstrumentationMode { 9 | 10 | /** 11 | * **AUTO** mode enables automatic instrumentation. 12 | * 13 | * In this mode, the plugin automatically instruments all required code 14 | * for the feature without requiring explicit annotations. 15 | */ 16 | AUTO, 17 | 18 | /** 19 | * **ANNOTATION** mode enables selective instrumentation. 20 | * 21 | * In this mode, only functions explicitly annotated with the required annotation 22 | * will be instrumented by the plugin. 23 | */ 24 | ANNOTATION, 25 | 26 | /** 27 | * **DISABLE** mode turns off instrumentation. 28 | * 29 | * When this mode is set, the plugin does not apply any instrumentation 30 | * for this feature, effectively disabling it. 31 | */ 32 | DISABLE; 33 | 34 | companion object { 35 | internal fun from(value: String): InstrumentationMode? { 36 | return entries.firstOrNull { it.name == value } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/RepositoryDetector.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | import org.gradle.api.Project 10 | import java.io.File 11 | 12 | /** 13 | * Describes a class which can detect information about the version control 14 | * repository associated with a Gradle [Project]. 15 | */ 16 | interface RepositoryDetector { 17 | 18 | /** 19 | * Perform a local analysis of the repository. 20 | * @param sourceSetRoots the list of relevant sourceSet root folders 21 | * @param extensionProvidedRemoteUrl the remote repository url provided in the plugin extension. If this 22 | * value is empty (not provided) we will automatically extract the default URL from GIT 23 | * configuration. 24 | * @return a list of [RepositoryInfo] describing the underlying Gradle [Project] 25 | */ 26 | fun detectRepositories( 27 | sourceSetRoots: List, 28 | extensionProvidedRemoteUrl: String = "" 29 | ): List 30 | } 31 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/RepositoryInfo.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | import org.json.JSONArray 10 | import org.json.JSONObject 11 | 12 | /** 13 | * Represents the information on the version control repository associated 14 | * with the current Gradle Project. 15 | * @param url Repository URL. 16 | * @param hash Commit hash. 17 | * @param sourceFiles Source files at the given commit. 18 | * @see [RepositoryDetector] 19 | */ 20 | data class RepositoryInfo( 21 | val url: String, 22 | val hash: String, 23 | val sourceFiles: List 24 | ) { 25 | /** 26 | * @return a JSON representation of this repository info. 27 | */ 28 | fun toJson(): JSONObject { 29 | val repository = JSONObject() 30 | repository.put(KEY_REMOTE_URL, url) 31 | repository.put(KEY_COMMIT_HASH, hash) 32 | repository.put(KEY_TRACKED_FILES, JSONArray(sourceFiles)) 33 | return repository 34 | } 35 | 36 | companion object { 37 | internal const val KEY_REMOTE_URL = "repository_url" 38 | internal const val KEY_COMMIT_HASH = "hash" 39 | internal const val KEY_TRACKED_FILES = "files" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/SdkCheckLevel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | /** 10 | * Defines the action which plugin should take if Datadog SDK is missing 11 | * in the project dependencies. 12 | */ 13 | enum class SdkCheckLevel { 14 | /** 15 | * Do nothing if SDK is missing in the dependencies. 16 | */ 17 | NONE, 18 | 19 | /** 20 | * Log a warning if SDK is missing in the dependencies. 21 | */ 22 | WARN, 23 | 24 | /** 25 | * Fail the build if SDK is missing in the dependencies. 26 | */ 27 | FAIL 28 | } 29 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/ApiKey.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | internal data class ApiKey(val value: String, val source: ApiKeySource) { 10 | companion object { 11 | val NONE = ApiKey("", ApiKeySource.NONE) 12 | } 13 | } 14 | 15 | /** 16 | * Source of API key. 17 | */ 18 | enum class ApiKeySource { 19 | GRADLE_PROPERTY, 20 | ENVIRONMENT, 21 | DATADOG_CI_CONFIG_FILE, 22 | NONE 23 | } 24 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/CurrentAgpVersion.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | import com.datadog.gradle.plugin.TaskUtils 10 | 11 | @Suppress("MagicNumber") 12 | internal object CurrentAgpVersion { 13 | 14 | // can work probably even with lower versions, but legacy Variant API is working fine there as well 15 | val CAN_ENABLE_NEW_VARIANT_API: Boolean 16 | get() = TaskUtils.isAgpAbove(major = 8, minor = 4, patch = 0) 17 | 18 | val SUPPORTS_KOTLIN_DIRECTORIES_SOURCE_PROVIDER: Boolean 19 | get() = TaskUtils.isAgpAbove(major = 7, minor = 0, patch = 0) 20 | 21 | val EXTERNAL_NATIVE_BUILD_SOFOLDER_IS_PUBLIC: Boolean 22 | get() = TaskUtils.isAgpAbove(major = 8, minor = 0, patch = 0) 23 | 24 | val CAN_QUERY_MAPPING_FILE_PROVIDER: Boolean 25 | get() = TaskUtils.isAgpAbove(major = 7, minor = 0, patch = 0) 26 | } 27 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/DdAppIdentifier.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | internal data class DdAppIdentifier( 10 | val serviceName: String, 11 | val version: String, 12 | val versionCode: Int, 13 | val variant: String, 14 | val buildId: String 15 | ) { 16 | 17 | override fun toString(): String { 18 | return "`service:$serviceName`, `version:$version`, `version_code:$versionCode`," + 19 | " `variant:$variant`, `build_id:$buildId`" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/MaxSizeExceededException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | internal class MaxSizeExceededException(message: String) : RuntimeException(message) 10 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/MissingSdkException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | internal class MissingSdkException(message: String) : RuntimeException(message) 10 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/ProjectExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | import com.datadog.gradle.plugin.DdAndroidGradlePlugin.Companion.LOGGER 10 | import org.gradle.process.ExecOperations 11 | import org.gradle.process.internal.ExecException 12 | import java.io.ByteArrayOutputStream 13 | 14 | internal fun ExecOperations.execShell(vararg command: String): String { 15 | val outputStream = ByteArrayOutputStream() 16 | val errorStream = ByteArrayOutputStream() 17 | try { 18 | this.exec { 19 | @Suppress("SpreadOperator") 20 | it.commandLine(*command) 21 | it.standardOutput = outputStream 22 | it.errorOutput = errorStream 23 | } 24 | } catch (e: ExecException) { 25 | LOGGER.error(errorStream.toString("UTF-8")) 26 | throw e 27 | } 28 | 29 | return outputStream.toString("UTF-8") 30 | } 31 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/TaskExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | import com.android.build.gradle.tasks.ExternalNativeBuildTask 10 | import com.datadog.gradle.plugin.GenerateBuildIdTask 11 | import org.gradle.api.file.DirectoryProperty 12 | import org.gradle.api.provider.Provider 13 | import org.gradle.api.provider.ProviderFactory 14 | import org.gradle.api.tasks.TaskProvider 15 | import java.io.File 16 | import kotlin.reflect.full.memberProperties 17 | 18 | internal fun TaskProvider.getSearchObjDirs(providerFactory: ProviderFactory): Provider { 19 | return flatMap { task -> task.getSearchObjDirs(providerFactory) } 20 | } 21 | 22 | internal fun ExternalNativeBuildTask.getSearchObjDirs(providerFactory: ProviderFactory): Provider { 23 | return if (CurrentAgpVersion.EXTERNAL_NATIVE_BUILD_SOFOLDER_IS_PUBLIC) { 24 | soFolder.map { it.asFile } 25 | } else { 26 | val soFolder = ExternalNativeBuildTask::class.memberProperties.find { 27 | it.name == "objFolder" 28 | }?.get(this) 29 | when (soFolder) { 30 | is File -> providerFactory.provider { soFolder } 31 | is DirectoryProperty -> soFolder.map { it.asFile } 32 | else -> providerFactory.provider { null } 33 | } 34 | } 35 | } 36 | 37 | internal fun TaskProvider.lazyBuildIdProvider(providerFactory: ProviderFactory): Provider { 38 | // upload task shouldn't depend on the build ID generation task, but only read its property, 39 | // because upload task may be triggered after assemble task and we don't want to re-generate 40 | // build ID, because it will be different then from the one which is already embedded in 41 | // the application package 42 | return flatMap { 43 | it.buildIdFile.flatMap { 44 | providerFactory.provider { 45 | val file = it.asFile 46 | if (file.exists()) { 47 | file.readText().trim() 48 | } else { 49 | "" 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/Uploader.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | import com.datadog.gradle.plugin.DatadogSite 10 | import com.datadog.gradle.plugin.RepositoryInfo 11 | import java.io.File 12 | 13 | internal interface Uploader { 14 | // region File Info 15 | 16 | data class UploadFileInfo( 17 | /** 18 | * The form key to use when uploading the file. 19 | */ 20 | val fileKey: String, 21 | 22 | /** 23 | * The file to upload. 24 | */ 25 | val file: File, 26 | 27 | /** 28 | * The encoding to use during upload of the file. 29 | */ 30 | val encoding: String, 31 | 32 | /** 33 | * The type of file given to intake, e.g. `jvm_mapping` or `ndk_symbol_file`. 34 | */ 35 | val fileType: String, 36 | 37 | /** 38 | * The name of the file to provide to intake. This can be different from the name 39 | * of the file on disk. 40 | */ 41 | val fileName: String, 42 | 43 | /** 44 | * Any extra attributes to provide to intake, such as the architecture of an NDK symbol file. 45 | */ 46 | val extraAttributes: Map = emptyMap() 47 | ) 48 | 49 | // endregion 50 | 51 | @Suppress("LongParameterList") 52 | fun upload( 53 | site: DatadogSite, 54 | fileInfo: UploadFileInfo, 55 | repositoryFile: File?, 56 | apiKey: String, 57 | identifier: DdAppIdentifier, 58 | repositoryInfo: RepositoryInfo?, 59 | useGzip: Boolean = true, 60 | emulateNetworkCall: Boolean = false 61 | ) 62 | } 63 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/VariantIterator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal 8 | 9 | /** 10 | * This Iterator will take a list of flavor name and trailing build type and iterate over all 11 | * possible (partial) variants from those. 12 | * 13 | * The partial variants will be iterated over in increasing order of priority. 14 | * Product flavors that belong to the first flavor dimension have a higher priority than 15 | * those belonging to the second flavor dimension. 16 | * 17 | * E.g.: for the variant with flavor names ["pro", "green", "release"], the iterator will 18 | * return the following values (in order): 19 | * "release", "green", "greenRelease", "pro", "proRelease", "proGreen", "proGreenRelease" 20 | */ 21 | internal class VariantIterator( 22 | private val names: List 23 | ) : Iterator { 24 | 25 | private var index = 1 26 | private val max = 1 shl names.size 27 | 28 | override fun hasNext(): Boolean { 29 | return index < max 30 | } 31 | 32 | override fun next(): String { 33 | if (index >= max) { 34 | throw NoSuchElementException() 35 | } 36 | 37 | // The idea of this algorithm is to generate all possible combination 38 | // while also keeping the order based on priorities. 39 | // Given a list of n names, we construct matching list of n booleans to decide 40 | // which of those name tokens we keep for the variant names. 41 | // Because the first name has a higher priority, the sequence would be (for 3 names): 42 | // false-false-true, false-true-false, false-true-true, true-false-false, and so on… 43 | // This sequence matches exactly the binary representation of integers starting from 1, so: 44 | // - the iterator iterates from 1 to (2^n - 1) 45 | // - at each step, we generate the binary representation of the current index 46 | // - we pad the binary with '0' to match the names size 47 | // - we convert the binary representation string into a boolean array 48 | // - we zip the array with the name 49 | val mask = index.toString(2).padStart(names.size, '0').map { it == '1' } 50 | val filteredNames = mask.zip(names) { bool, string -> if (bool) string else null } 51 | .filterNotNull() 52 | 53 | index++ 54 | 55 | return buildVariantName(filteredNames) 56 | } 57 | 58 | private fun buildVariantName(flavorNames: List): String { 59 | return flavorNames.first() + flavorNames.drop(1).joinToString("") { it.capitalize() } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/sanitizer/FullUriGitRemoteUrlSanitizer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal.sanitizer 8 | 9 | import java.net.URI 10 | import java.net.URISyntaxException 11 | import kotlin.jvm.Throws 12 | 13 | internal open class FullUriGitRemoteUrlSanitizer : UrlSanitizer { 14 | @Throws(exceptionClasses = [URISyntaxException::class]) 15 | override fun sanitize(url: String): String { 16 | val parsedUri = URI(url) 17 | return if (parsedUri.userInfo.isNullOrEmpty()) { 18 | url 19 | } else { 20 | val sanitizedUri = URI( 21 | parsedUri.scheme, 22 | null, 23 | parsedUri.host, 24 | parsedUri.port, 25 | parsedUri.path, 26 | parsedUri.query, 27 | parsedUri.fragment 28 | ) 29 | sanitizedUri.toString() 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/sanitizer/GitRemoteUrlSanitizer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal.sanitizer 8 | 9 | import java.util.Locale 10 | 11 | /** 12 | * It will strip out the user information from the provided URL by applying the following rules: 13 | * 1. In case the URL is a valid schema URL : ((ssh|http[s]?):\\) it will strip out the user 14 | * information if any from it 15 | * 2. In case the URL is a valid schema URL but by mistake the user forgot to add the schema: 16 | * [username]:[password]@github.com/(.+).git it will strip out the user information if any and will 17 | * return the new url 18 | * 3. In case the URL is of a GIT SSH short format: [user@]github.com:(.+).git it will do 19 | * nothing assuming that there is no password normally provided in a GIT SSH short format URL. 20 | */ 21 | internal class GitRemoteUrlSanitizer( 22 | private val sanitizerResolver: (String) -> UrlSanitizer = { 23 | if (it.matches(VALID_SCHEMA_URL_FORMAT_REGEX)) { 24 | FullUriGitRemoteUrlSanitizer() 25 | } else { 26 | ShortUriGitRemoteUrlSanitizer() 27 | } 28 | } 29 | ) : UrlSanitizer { 30 | 31 | @SuppressWarnings("TooGenericExceptionCaught") 32 | override fun sanitize(url: String): String { 33 | try { 34 | return sanitizerResolver(url).sanitize(url) 35 | } catch (e: Exception) { 36 | throw UriParsingException(WRONG_URL_FORMAT_ERROR_MESSAGE.format(url, Locale.US), e) 37 | } 38 | } 39 | 40 | companion object { 41 | const val WRONG_URL_FORMAT_ERROR_MESSAGE = 42 | "The detected GIT remote url: [%s] is not a valid GIT url and it " + 43 | "will not be browsable from the Error Tracking panel. " + 44 | "You can provide a different URL through the plugin extension." 45 | const val VALID_SCHEMA_URL_FORMAT_PATTERN = "^(ssh|http|https)://(.+)$" 46 | val VALID_SCHEMA_URL_FORMAT_REGEX = 47 | Regex(VALID_SCHEMA_URL_FORMAT_PATTERN, RegexOption.IGNORE_CASE) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/sanitizer/ShortUriGitRemoteUrlSanitizer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal.sanitizer 8 | 9 | internal class ShortUriGitRemoteUrlSanitizer : FullUriGitRemoteUrlSanitizer() { 10 | override fun sanitize(url: String): String { 11 | val sanitizedUri = super.sanitize("$SSH_SCHEMA_PREFIX$url") 12 | return sanitizedUri.removePrefix(SSH_SCHEMA_PREFIX) 13 | } 14 | 15 | companion object { 16 | const val SSH_SCHEMA_PREFIX = "ssh://" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/sanitizer/UriParsingException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal.sanitizer 8 | 9 | import java.lang.IllegalArgumentException 10 | 11 | internal class UriParsingException(message: String, throwable: Throwable) : 12 | IllegalArgumentException(message, throwable) 13 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/sanitizer/UrlSanitizer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal.sanitizer 8 | 9 | internal interface UrlSanitizer { 10 | fun sanitize(url: String): String 11 | } 12 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/internal/variant/AppVariant.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.internal.variant 8 | 9 | import com.android.build.gradle.AppExtension 10 | import com.datadog.gradle.plugin.GenerateBuildIdTask 11 | import com.datadog.gradle.plugin.MappingFileUploadTask 12 | import com.datadog.gradle.plugin.NdkSymbolFileUploadTask 13 | import org.gradle.api.Project 14 | import org.gradle.api.artifacts.Configuration 15 | import org.gradle.api.file.Directory 16 | import org.gradle.api.file.RegularFile 17 | import org.gradle.api.provider.Provider 18 | import org.gradle.api.tasks.TaskProvider 19 | import java.io.File 20 | import com.android.build.api.variant.ApplicationVariant as NewApplicationVariant 21 | import com.android.build.gradle.api.ApplicationVariant as LegacyApplicationVariant 22 | 23 | internal interface AppVariant { 24 | 25 | val name: String 26 | 27 | val applicationId: Provider 28 | 29 | val flavorName: String 30 | 31 | val versionCode: Provider 32 | 33 | val versionName: Provider 34 | 35 | val compileConfiguration: Configuration 36 | 37 | val isNativeBuildEnabled: Boolean 38 | 39 | val isMinifyEnabled: Boolean 40 | 41 | val buildTypeName: String 42 | 43 | val flavors: List 44 | 45 | val mappingFile: Provider 46 | 47 | fun collectJavaAndKotlinSourceDirectories(): Provider> 48 | 49 | fun bindWith(ndkUploadTask: NdkSymbolFileUploadTask) 50 | 51 | fun bindWith(mappingFileUploadTask: MappingFileUploadTask) 52 | 53 | // new variant API doesn't allow to run addGeneratedSourceDirectory from inside Task#configure, thus this 54 | fun bindWith(generateBuildIdTask: TaskProvider, buildIdDirectory: Provider) 55 | 56 | companion object { 57 | fun create( 58 | variant: NewApplicationVariant, 59 | target: Project 60 | ): AppVariant = NewApiAppVariant(variant, target) 61 | 62 | fun create( 63 | variant: LegacyApplicationVariant, 64 | appExtension: AppExtension, 65 | target: Project 66 | ): AppVariant = LegacyApiAppVariant(variant, appExtension, target) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/kcp/ComposeNavHostExtension.kt: -------------------------------------------------------------------------------- 1 | @file:OptIn(UnsafeDuringIrConstructionAPI::class) 2 | 3 | package com.datadog.gradle.plugin.kcp 4 | 5 | import com.datadog.gradle.plugin.InstrumentationMode 6 | import org.jetbrains.kotlin.backend.common.extensions.FirIncompatiblePluginAPI 7 | import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension 8 | import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext 9 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 10 | import org.jetbrains.kotlin.ir.declarations.IrModuleFragment 11 | import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI 12 | 13 | /** 14 | * The extension registers [ComposeNavHostTransformer] into the plugin. 15 | */ 16 | @FirIncompatiblePluginAPI 17 | internal class ComposeNavHostExtension( 18 | private val messageCollector: MessageCollector, 19 | private val internalInstrumentationMode: InstrumentationMode 20 | ) : IrGenerationExtension { 21 | 22 | override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { 23 | if (internalInstrumentationMode != InstrumentationMode.DISABLE) { 24 | registerNavHostTransformer( 25 | pluginContext = pluginContext, 26 | moduleFragment = moduleFragment, 27 | annotationModeEnabled = internalInstrumentationMode == InstrumentationMode.ANNOTATION 28 | ) 29 | } 30 | } 31 | 32 | private fun registerNavHostTransformer( 33 | pluginContext: IrPluginContext, 34 | moduleFragment: IrModuleFragment, 35 | annotationModeEnabled: Boolean 36 | ) { 37 | val composeNavHostTransformer = 38 | ComposeNavHostTransformer( 39 | messageCollector = messageCollector, 40 | pluginContext = pluginContext, 41 | annotationModeEnabled = annotationModeEnabled 42 | ) 43 | if (composeNavHostTransformer.initReferences()) { 44 | moduleFragment.accept(composeNavHostTransformer, null) 45 | } else { 46 | messageCollector.warnDependenciesError() 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/kcp/ComposeTagExtension.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.gradle.plugin.kcp 2 | 3 | import com.datadog.gradle.plugin.InstrumentationMode 4 | import org.jetbrains.kotlin.backend.common.extensions.FirIncompatiblePluginAPI 5 | import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension 6 | import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext 7 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 8 | import org.jetbrains.kotlin.ir.declarations.IrModuleFragment 9 | 10 | /** 11 | * The extension registers [ComposeTagTransformer] into the plugin. 12 | */ 13 | @FirIncompatiblePluginAPI 14 | internal class ComposeTagExtension( 15 | private val messageCollector: MessageCollector, 16 | private val internalInstrumentationMode: InstrumentationMode 17 | ) : 18 | IrGenerationExtension { 19 | 20 | override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { 21 | if (internalInstrumentationMode != InstrumentationMode.DISABLE) { 22 | registerTagTransformer( 23 | pluginContext = pluginContext, 24 | moduleFragment = moduleFragment, 25 | annotationModeEnabled = internalInstrumentationMode == InstrumentationMode.ANNOTATION 26 | ) 27 | } 28 | } 29 | 30 | private fun registerTagTransformer( 31 | pluginContext: IrPluginContext, 32 | moduleFragment: IrModuleFragment, 33 | annotationModeEnabled: Boolean 34 | ) { 35 | val composeTagTransformer = ComposeTagTransformer( 36 | messageCollector = messageCollector, 37 | pluginContext = pluginContext, 38 | annotationModeEnabled = annotationModeEnabled 39 | ) 40 | if (composeTagTransformer.initReferences()) { 41 | moduleFragment.accept(composeTagTransformer, null) 42 | } else { 43 | messageCollector.warnDependenciesError() 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/kcp/DatadogKotlinCompilerPluginCommandLineProcessor.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.gradle.plugin.kcp 2 | 3 | import com.google.auto.service.AutoService 4 | import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption 5 | import org.jetbrains.kotlin.compiler.plugin.CliOption 6 | import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor 7 | import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi 8 | import org.jetbrains.kotlin.config.CompilerConfiguration 9 | 10 | @OptIn(ExperimentalCompilerApi::class) 11 | @AutoService(CommandLineProcessor::class) 12 | internal class DatadogKotlinCompilerPluginCommandLineProcessor : CommandLineProcessor { 13 | override val pluginId: String = KOTLIN_COMPILER_PLUGIN_ID 14 | override val pluginOptions: Collection = listOf( 15 | CliOption( 16 | optionName = INSTRUMENTATION_MODE, 17 | valueDescription = STRING_VALUE_DESCRIPTION, 18 | description = INSTRUMENTATION_MODE_DESCRIPTION, 19 | required = false 20 | ) 21 | ) 22 | 23 | override fun processOption(option: AbstractCliOption, value: String, configuration: CompilerConfiguration) { 24 | if (option.optionName == INSTRUMENTATION_MODE) { 25 | configuration.put( 26 | DatadogPluginRegistrar.CONFIG_INSTRUMENTATION_MODE, 27 | value 28 | ) 29 | } 30 | } 31 | 32 | companion object { 33 | private const val STRING_VALUE_DESCRIPTION = "" 34 | internal const val KOTLIN_COMPILER_PLUGIN_ID = "com.datadoghq.kotlin.compiler" 35 | internal const val INSTRUMENTATION_MODE = "INSTRUMENTATION_MODE" 36 | private const val INSTRUMENTATION_MODE_DESCRIPTION = "Datadog compiler plugin instrumentation mode option." 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/kcp/MessageCollectorExt.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.gradle.plugin.kcp 2 | 3 | import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity 4 | import org.jetbrains.kotlin.cli.common.messages.MessageCollector 5 | 6 | internal fun MessageCollector.warnDependenciesError() { 7 | report(CompilerMessageSeverity.STRONG_WARNING, WARNING_MISSING_DEP) 8 | } 9 | 10 | private const val WARNING_MISSING_DEP = 11 | "The Datadog Plugin has detected missing dependencies required for Compose Instrumentation in this module. " + 12 | "Missing these dependencies may result in incomplete Compose Instrumentation functionality. " + 13 | "You can ignore this warning if you're certain that the missing dependencies " + 14 | "are not needed for your use case." 15 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/main/kotlin/com/datadog/gradle/plugin/kcp/PluginContextUtils.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.gradle.plugin.kcp 2 | 3 | import org.jetbrains.kotlin.ir.declarations.IrFunction 4 | import org.jetbrains.kotlin.ir.declarations.IrPackageFragment 5 | import org.jetbrains.kotlin.ir.symbols.IrClassSymbol 6 | import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol 7 | import org.jetbrains.kotlin.name.CallableId 8 | 9 | @Suppress("TooManyFunctions") 10 | internal interface PluginContextUtils { 11 | fun getModifierCompanionClass(): IrClassSymbol? 12 | fun getModifierClassSymbol(): IrClassSymbol? 13 | fun getDatadogModifierSymbol(): IrSimpleFunctionSymbol? 14 | fun getModifierThen(): IrSimpleFunctionSymbol? 15 | fun isComposableFunction(owner: IrFunction): Boolean 16 | fun referenceSingleFunction(callableId: CallableId, isCritical: Boolean = false): IrSimpleFunctionSymbol? 17 | fun getDatadogTrackEffectSymbol(): IrSimpleFunctionSymbol? 18 | fun isNavHostCall(owner: IrFunction): Boolean 19 | fun getNavHostControllerClassSymbol(): IrClassSymbol? 20 | fun getApplySymbol(): IrSimpleFunctionSymbol? 21 | fun isFoundationImage(owner: IrFunction, parent: IrPackageFragment): Boolean 22 | fun isMaterialIcon(owner: IrFunction, parent: IrPackageFragment): Boolean 23 | fun isCoilAsyncImage(owner: IrFunction, parent: IrPackageFragment): Boolean 24 | fun isComposeInstrumentationTargetFunc(irFunction: IrFunction, annotationModeEnabled: Boolean): Boolean 25 | } 26 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/compose/foundation/Image.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnusedParameter") 2 | 3 | package androidx.compose.foundation 4 | 5 | import androidx.compose.runtime.Composable 6 | import androidx.compose.ui.Modifier 7 | 8 | @Composable 9 | fun Image(modifier: Modifier = Modifier) { 10 | // fake function 11 | } 12 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/compose/material/Icon.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnusedParameter") 2 | 3 | package androidx.compose.material 4 | 5 | import androidx.compose.runtime.Composable 6 | import androidx.compose.ui.Modifier 7 | 8 | @Composable 9 | fun Icon( 10 | modifier: Modifier = Modifier 11 | ) { 12 | // fake function 13 | } 14 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/navigation/NavController.kt: -------------------------------------------------------------------------------- 1 | package androidx.navigation 2 | 3 | /** 4 | * This is a fake class of Android [androidx.navigation.NavController] for compilation testing purpose 5 | */ 6 | open class NavController 7 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/navigation/NavDestination.kt: -------------------------------------------------------------------------------- 1 | package androidx.navigation 2 | 3 | /** 4 | * This is a fake class of Android [androidx.navigation.NavDestination] for compilation testing purpose 5 | */ 6 | class NavDestination 7 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/navigation/NavHostController.kt: -------------------------------------------------------------------------------- 1 | package androidx.navigation 2 | 3 | /** 4 | * This is a fake class of Android [androidx.navigation.NavHostController] for compilation testing purpose 5 | */ 6 | class NavHostController : NavController() 7 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/navigation/compose/NavGraphBuilder.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnusedParameter") 2 | 3 | package androidx.navigation.compose 4 | 5 | /** 6 | * This is a fake class of Android [androidx.navigation.compose.NavGraphBuilder] for compilation 7 | * testing purpose. 8 | */ 9 | class NavGraphBuilder 10 | 11 | /** 12 | * This is a fake function of Android [androidx.navigation.compose.NavGraphBuilder.composable] for 13 | * compilation testing purpose. 14 | */ 15 | public fun NavGraphBuilder.composable(route: String) { 16 | // fake function 17 | } 18 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/navigation/compose/NavHost.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnusedParameter") 2 | 3 | package androidx.navigation.compose 4 | 5 | import androidx.navigation.NavHostController 6 | 7 | /** 8 | * This is a fake function of Android [androidx.navigation.compose.NavHost] for compilation testing purpose 9 | */ 10 | fun NavHost( 11 | navHostController: NavHostController, 12 | destination: String, 13 | builder: NavGraphBuilder.() -> Unit 14 | ) { 15 | // fake function 16 | } 17 | 18 | /** 19 | * This is a fake class of Android [androidx.navigation.compose.NavHost] for compilation testing purpose 20 | */ 21 | class NavHost 22 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/androidx/navigation/compose/NavHostController.kt: -------------------------------------------------------------------------------- 1 | package androidx.navigation.compose 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.navigation.NavHostController 5 | 6 | /** 7 | * This is a fake function of Android [androidx.navigation.compose.rememberNavController] for compilation testing purpose 8 | */ 9 | @Composable 10 | public fun rememberNavController(): NavHostController { 11 | return NavHostController() 12 | } 13 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/coil/compose/AsyncImage.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnusedParameter") 2 | 3 | package coil.compose 4 | 5 | import androidx.compose.runtime.Composable 6 | import androidx.compose.ui.Modifier 7 | 8 | @Composable 9 | fun AsyncImage( 10 | modifier: Modifier = Modifier 11 | ) { 12 | // fake function 13 | } 14 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/RepositoryInfoTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | import com.datadog.gradle.plugin.utils.forge.Configurator 10 | import fr.xgouchet.elmyr.annotation.Forgery 11 | import fr.xgouchet.elmyr.junit5.ForgeConfiguration 12 | import fr.xgouchet.elmyr.junit5.ForgeExtension 13 | import org.assertj.core.api.Assertions.assertThat 14 | import org.junit.jupiter.api.Test 15 | import org.junit.jupiter.api.extension.ExtendWith 16 | import org.junit.jupiter.api.extension.Extensions 17 | import org.mockito.junit.jupiter.MockitoExtension 18 | import org.mockito.junit.jupiter.MockitoSettings 19 | import org.mockito.quality.Strictness 20 | 21 | @Extensions( 22 | ExtendWith(MockitoExtension::class), 23 | ExtendWith(ForgeExtension::class) 24 | ) 25 | @MockitoSettings(strictness = Strictness.LENIENT) 26 | @ForgeConfiguration(Configurator::class) 27 | internal class RepositoryInfoTest { 28 | 29 | @Test 30 | fun `M serialize item to Json W toJson()`( 31 | @Forgery repositoryInfo: RepositoryInfo 32 | ) { 33 | // When 34 | val result = repositoryInfo.toJson() 35 | 36 | // Then 37 | assertThat(result.getString(RepositoryInfo.KEY_REMOTE_URL)) 38 | .isEqualTo(repositoryInfo.url) 39 | assertThat(result.getString(RepositoryInfo.KEY_COMMIT_HASH)) 40 | .isEqualTo(repositoryInfo.hash) 41 | val trackedFiles = result.getJSONArray(RepositoryInfo.KEY_TRACKED_FILES).toList() 42 | assertThat(trackedFiles) 43 | .containsAll(repositoryInfo.sourceFiles) 44 | .hasSize(repositoryInfo.sourceFiles.size) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/SystemExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | import java.lang.reflect.Field 10 | 11 | @Suppress("UNCHECKED_CAST") 12 | fun setEnv(key: String, value: String) { 13 | try { 14 | val env = System.getenv() 15 | val cl: Class<*> = env.javaClass 16 | val field: Field = cl.getDeclaredField("m") 17 | field.isAccessible = true 18 | val writableEnv = field.get(env) as MutableMap 19 | writableEnv[key] = value 20 | } catch (e: Exception) { 21 | throw IllegalStateException("Failed to set environment variable", e) 22 | } 23 | } 24 | 25 | @Suppress("UNCHECKED_CAST") 26 | fun removeEnv(key: String) { 27 | try { 28 | val env = System.getenv() 29 | val cl: Class<*> = env.javaClass 30 | val field: Field = cl.getDeclaredField("m") 31 | field.isAccessible = true 32 | val writableEnv = field.get(env) as MutableMap 33 | writableEnv.remove(key) 34 | } catch (e: Exception) { 35 | throw IllegalStateException("Failed to remove environment variable", e) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/TaskUtilsTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin 8 | 9 | import com.datadog.gradle.plugin.utils.forge.Configurator 10 | import fr.xgouchet.elmyr.Forge 11 | import fr.xgouchet.elmyr.junit5.ForgeConfiguration 12 | import fr.xgouchet.elmyr.junit5.ForgeExtension 13 | import org.assertj.core.api.Assertions 14 | import org.junit.jupiter.api.Test 15 | import org.junit.jupiter.api.extension.ExtendWith 16 | import org.junit.jupiter.api.extension.Extensions 17 | import org.junit.jupiter.api.io.TempDir 18 | import java.io.File 19 | 20 | @Extensions( 21 | ExtendWith(ForgeExtension::class) 22 | ) 23 | @ForgeConfiguration(Configurator::class) 24 | class TaskUtilsTest { 25 | 26 | @Test 27 | fun `M find datadog-ci file W findDatadogCiFile()`( 28 | @TempDir rootDir: File, 29 | forge: Forge 30 | ) { 31 | // Given 32 | val tree = buildDirectoryTree(rootDir, maxDepth = 3, forge = forge) 33 | 34 | File(tree[forge.anInt(0, tree.size)], "datadog-ci.json").createNewFile() 35 | 36 | // When 37 | val ciFile = TaskUtils.findDatadogCiFile(tree.last()) 38 | 39 | // Then 40 | Assertions.assertThat(ciFile).isNotNull() 41 | } 42 | 43 | @Test 44 | fun `M return null W findDatadogCiFile() { no ci file found }`( 45 | @TempDir rootDir: File, 46 | forge: Forge 47 | ) { 48 | // Given 49 | val tree = buildDirectoryTree(rootDir, maxDepth = 3, forge = forge) 50 | 51 | // When 52 | val ciFile = TaskUtils.findDatadogCiFile(tree.last()) 53 | 54 | // Then 55 | Assertions.assertThat(ciFile).isNull() 56 | } 57 | 58 | @Test 59 | fun `M return null W findDatadogCiFile() { beyond max levels up }`( 60 | @TempDir rootDir: File, 61 | forge: Forge 62 | ) { 63 | // Given 64 | val tree = buildDirectoryTree(rootDir, minDepth = 4, maxDepth = 7, forge = forge) 65 | 66 | // When 67 | val ciFile = TaskUtils.findDatadogCiFile(tree.last()) 68 | 69 | // Then 70 | Assertions.assertThat(ciFile).isNull() 71 | } 72 | 73 | private fun buildDirectoryTree( 74 | rootDir: File, 75 | minDepth: Int = 1, 76 | maxDepth: Int, 77 | forge: Forge 78 | ): List { 79 | var currentDir = rootDir 80 | val tree = mutableListOf(rootDir) 81 | val stopAt = forge.anInt(min = minDepth, max = maxDepth + 1) 82 | for (level in 1..maxDepth) { 83 | if (level == stopAt) break 84 | 85 | currentDir = File(currentDir, forge.anAlphabeticalString()) 86 | tree.add(currentDir) 87 | } 88 | 89 | tree.last().mkdirs() 90 | 91 | return tree 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/kcp/DatadogKotlinCompilerPluginCommandLineProcessorTest.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.gradle.plugin.kcp 2 | 3 | import com.datadog.gradle.plugin.kcp.DatadogKotlinCompilerPluginCommandLineProcessor.Companion.INSTRUMENTATION_MODE 4 | import com.datadog.gradle.plugin.utils.forge.Configurator 5 | import fr.xgouchet.elmyr.annotation.StringForgery 6 | import fr.xgouchet.elmyr.junit5.ForgeConfiguration 7 | import fr.xgouchet.elmyr.junit5.ForgeExtension 8 | import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption 9 | import org.jetbrains.kotlin.compiler.plugin.CliOption 10 | import org.jetbrains.kotlin.config.CompilerConfiguration 11 | import org.junit.jupiter.api.Test 12 | import org.junit.jupiter.api.extension.ExtendWith 13 | import org.junit.jupiter.api.extension.Extensions 14 | import org.mockito.Mock 15 | import org.mockito.junit.jupiter.MockitoExtension 16 | import org.mockito.junit.jupiter.MockitoSettings 17 | import org.mockito.kotlin.verify 18 | import org.mockito.quality.Strictness 19 | 20 | @Extensions( 21 | ExtendWith(MockitoExtension::class), 22 | ExtendWith(ForgeExtension::class) 23 | ) 24 | @MockitoSettings(strictness = Strictness.LENIENT) 25 | @ForgeConfiguration(Configurator::class) 26 | internal class DatadogKotlinCompilerPluginCommandLineProcessorTest { 27 | 28 | private val testedProcessor = DatadogKotlinCompilerPluginCommandLineProcessor() 29 | 30 | @Mock 31 | private lateinit var mockCompilerConfiguration: CompilerConfiguration 32 | 33 | @Test 34 | fun `M put value W option name is track actions`( 35 | @StringForgery fakeValue: String, 36 | @StringForgery fakeDescription: String 37 | ) { 38 | // Given 39 | val fakeCliOption: AbstractCliOption = CliOption( 40 | optionName = INSTRUMENTATION_MODE, 41 | valueDescription = "", 42 | description = fakeDescription 43 | ) 44 | 45 | // When 46 | testedProcessor.processOption(fakeCliOption, fakeValue, mockCompilerConfiguration) 47 | 48 | // Then 49 | verify(mockCompilerConfiguration).put(DatadogPluginRegistrar.CONFIG_INSTRUMENTATION_MODE, fakeValue) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/kcp/TestCallbackContainer.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.gradle.plugin.kcp 2 | 3 | /** 4 | * A container for storing callbacks passed from the unit test environment. 5 | * 6 | * This object should be loaded by the same class loader that loads the test target class file. 7 | * To ensure the test target function is invoked correctly, the function under test should 8 | * call [TestCallbackContainer.invokeCallback], allowing external verification of the callback invocation. 9 | */ 10 | object TestCallbackContainer { 11 | 12 | private var callback: (Boolean) -> Unit = {} 13 | 14 | /** 15 | * Sets the callback function to be invoked during testing. 16 | * 17 | * @param callback The function to be stored and later invoked. 18 | */ 19 | fun setCallback(callback: (Boolean) -> Unit) { 20 | this.callback = callback 21 | } 22 | 23 | /** 24 | * Invokes the stored callback function. 25 | */ 26 | fun invokeCallback(isImageRole: Boolean = false) { 27 | callback.invoke(isImageRole) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/CharUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils 8 | 9 | import java.util.Locale 10 | 11 | fun capitalizeChar(char: Char): CharSequence { 12 | return if (char.isLowerCase()) { 13 | char.titlecase(Locale.US) 14 | } else { 15 | char.toString() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/GitUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils 8 | 9 | import java.io.File 10 | import java.util.concurrent.TimeUnit 11 | 12 | internal fun initializeGit(remoteUrl: String, rootDirectory: File) { 13 | val readme = File(rootDirectory, "README.md") 14 | readme.writeText("# Fake project") 15 | 16 | check( 17 | ProcessBuilder("git", "init") 18 | .directory(rootDirectory) 19 | .start() 20 | .waitForSuccess(5, TimeUnit.SECONDS) 21 | ) 22 | check( 23 | ProcessBuilder("git", "add", ".") 24 | .directory(rootDirectory) 25 | .start() 26 | .waitForSuccess(5, TimeUnit.SECONDS) 27 | ) 28 | check( 29 | ProcessBuilder("git", "config", "commit.gpgsign", "false") 30 | .directory(rootDirectory) 31 | .start() 32 | .waitForSuccess(5, TimeUnit.SECONDS) 33 | ) 34 | check( 35 | ProcessBuilder("git", "config", "user.name", "\"Some User\"") 36 | .directory(rootDirectory) 37 | .start() 38 | .waitForSuccess(5, TimeUnit.SECONDS) 39 | ) 40 | check( 41 | ProcessBuilder("git", "config", "user.email", "\"user@example.com\"") 42 | .directory(rootDirectory) 43 | .start() 44 | .waitForSuccess(5, TimeUnit.SECONDS) 45 | ) 46 | check( 47 | ProcessBuilder("git", "commit", "-m", "Init") 48 | .directory(rootDirectory) 49 | .start() 50 | .waitForSuccess(5, TimeUnit.SECONDS) 51 | ) 52 | check( 53 | ProcessBuilder("git", "remote", "add", "origin", remoteUrl) 54 | .directory(rootDirectory) 55 | .start() 56 | .waitForSuccess(5, TimeUnit.SECONDS) 57 | ) 58 | } 59 | 60 | fun headHash(rootDirectory: File): String { 61 | val process = ProcessBuilder("git", "rev-parse", "HEAD") 62 | .directory(rootDirectory) 63 | .start() 64 | 65 | check(process.waitForSuccess(5, TimeUnit.SECONDS)) 66 | 67 | return process.inputReader().readText().trim() 68 | } 69 | 70 | private fun Process.waitForSuccess(timeout: Long, unit: TimeUnit): Boolean { 71 | val haveNoTimeout = waitFor(timeout, unit) 72 | return haveNoTimeout && exitValue() == 0 73 | } 74 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/assertj/BuildResultAssert.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils.assertj 8 | 9 | import com.datadog.gradle.plugin.DdAndroidGradlePlugin 10 | import com.datadog.gradle.plugin.NdkSymbolFileUploadTask 11 | import org.assertj.core.api.AbstractAssert 12 | import org.assertj.core.api.Assertions.assertThat 13 | import org.gradle.testkit.runner.BuildResult 14 | import org.gradle.testkit.runner.TaskOutcome 15 | 16 | internal class BuildResultAssert(actual: BuildResult) : 17 | AbstractAssert(actual, BuildResultAssert::class.java) { 18 | 19 | fun containsInOutput(text: String): BuildResultAssert { 20 | assertThat(actual.output).contains(text) 21 | return this 22 | } 23 | 24 | fun hasSuccessfulTaskOutcome(taskName: String): BuildResultAssert { 25 | val task = actual.task(taskName) 26 | assertThat(task) 27 | .overridingErrorMessage( 28 | "Expected to have task with name=$taskName to" + 29 | " be present in execution graph, but it wasn't found there." 30 | ) 31 | .isNotNull 32 | 33 | assertThat(task?.outcome) 34 | .overridingErrorMessage( 35 | "Expected task with name=$taskName" + 36 | " to have outcome=${TaskOutcome.SUCCESS}, but the actual outcome was ${task?.outcome}" 37 | ) 38 | .isEqualTo(TaskOutcome.SUCCESS) 39 | 40 | return this 41 | } 42 | 43 | fun hasNoUploadTasks(): BuildResultAssert { 44 | assertThat(actual.tasks).noneMatch { 45 | it.path.contains(DdAndroidGradlePlugin.UPLOAD_TASK_NAME) 46 | } 47 | assertThat(actual.tasks).noneMatch { 48 | it.path.contains(NdkSymbolFileUploadTask.TASK_NAME) 49 | } 50 | return this 51 | } 52 | 53 | fun hasNoNdkSymbolUploadTasks(): BuildResultAssert { 54 | assertThat(actual.tasks).noneMatch { 55 | it.path.contains(NdkSymbolFileUploadTask.TASK_NAME) 56 | } 57 | return this 58 | } 59 | 60 | companion object { 61 | 62 | fun assertThat(actual: BuildResult) = BuildResultAssert(actual) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/forge/Configurator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils.forge 8 | 9 | import fr.xgouchet.elmyr.Forge 10 | import fr.xgouchet.elmyr.ForgeConfigurator 11 | import fr.xgouchet.elmyr.jvm.useJvmFactories 12 | 13 | internal class Configurator : ForgeConfigurator { 14 | 15 | override fun configure(forge: Forge) { 16 | forge.addFactory(IdentifierForgeryFactory()) 17 | forge.addFactory(DdExtensionForgeryFactory()) 18 | forge.addFactory(DdExtensionConfigurationForgeryFactory()) 19 | forge.addFactory(RepositoryInfoForgeryFactory()) 20 | forge.useJvmFactories() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/forge/DdExtensionConfigurationForgeryFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils.forge 8 | 9 | import com.datadog.gradle.plugin.DatadogSite 10 | import com.datadog.gradle.plugin.DdExtensionConfiguration 11 | import com.datadog.gradle.plugin.SdkCheckLevel 12 | import fr.xgouchet.elmyr.Forge 13 | import fr.xgouchet.elmyr.ForgeryFactory 14 | 15 | internal class DdExtensionConfigurationForgeryFactory : ForgeryFactory { 16 | override fun getForgery(forge: Forge): DdExtensionConfiguration { 17 | return DdExtensionConfiguration().apply { 18 | serviceName = forge.aStringMatching("[a-z]{3}(\\.[a-z]{5,10}){2,4}") 19 | versionName = forge.aStringMatching("\\d\\.\\d{1,2}\\.\\d{1,3}") 20 | site = forge.aValueFrom(DatadogSite::class.java).name 21 | remoteRepositoryUrl = forge.aStringMatching( 22 | "https://[a-z]{4,10}\\.[com|org]/[a-z]{4,10}/[a-z]{4,10}\\.git" 23 | ) 24 | checkProjectDependencies = forge.aValueFrom(SdkCheckLevel::class.java) 25 | mappingFilePath = forge.aStringMatching( 26 | "([a-z]+)/([a-z]+)/([a-z]+)/mapping.txt" 27 | ) 28 | mappingFilePackageAliases = forge.aMap { 29 | forge.aStringMatching("[a-z]{3}(\\.[a-z]{5,10}){2,4}") to 30 | forge.anAlphabeticalString() 31 | } 32 | mappingFileTrimIndents = forge.aBool() 33 | ignoreDatadogCiFileConfig = forge.aBool() 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/forge/DdExtensionForgeryFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils.forge 8 | 9 | import com.datadog.gradle.plugin.DatadogSite 10 | import com.datadog.gradle.plugin.DdExtension 11 | import com.datadog.gradle.plugin.SdkCheckLevel 12 | import fr.xgouchet.elmyr.Forge 13 | import fr.xgouchet.elmyr.ForgeryFactory 14 | import org.gradle.api.model.ObjectFactory 15 | import org.mockito.kotlin.any 16 | import org.mockito.kotlin.doReturn 17 | import org.mockito.kotlin.mock 18 | import org.mockito.kotlin.whenever 19 | 20 | internal class DdExtensionForgeryFactory : ForgeryFactory { 21 | override fun getForgery(forge: Forge): DdExtension { 22 | val objectFactory: ObjectFactory = mock() 23 | 24 | whenever(objectFactory.domainObjectContainer(any())) doReturn mock() 25 | 26 | return DdExtension(objectFactory).apply { 27 | serviceName = forge.aStringMatching("[a-z]{3}(\\.[a-z]{5,10}){2,4}") 28 | versionName = forge.aStringMatching("\\d\\.\\d{1,2}\\.\\d{1,3}") 29 | site = forge.aValueFrom(DatadogSite::class.java).name 30 | checkProjectDependencies = forge.aValueFrom(SdkCheckLevel::class.java) 31 | remoteRepositoryUrl = forge.aStringMatching( 32 | "https://[a-z]{4,10}\\.[com|org]/[a-z]{4,10}/[a-z]{4,10}\\.git" 33 | ) 34 | mappingFilePath = forge.aStringMatching( 35 | "([a-z]+)/([a-z]+)/([a-z]+)/mapping.txt" 36 | ) 37 | mappingFilePackageAliases = forge.aMap { 38 | forge.aStringMatching("[a-z]{3}(\\.[a-z]{5,10}){2,4}") to 39 | forge.anAlphabeticalString() 40 | } 41 | mappingFileTrimIndents = forge.aBool() 42 | ignoreDatadogCiFileConfig = forge.aBool() 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/forge/IdentifierForgeryFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils.forge 8 | 9 | import com.datadog.gradle.plugin.internal.DdAppIdentifier 10 | import fr.xgouchet.elmyr.Forge 11 | import fr.xgouchet.elmyr.ForgeryFactory 12 | import java.util.UUID 13 | 14 | internal class IdentifierForgeryFactory : ForgeryFactory { 15 | override fun getForgery(forge: Forge): DdAppIdentifier { 16 | return DdAppIdentifier( 17 | serviceName = forge.aStringMatching("[a-z]{3}(\\.[a-z]{5,10}){2,4}"), 18 | version = forge.aStringMatching("\\d\\.\\d{1,2}\\.\\d{1,3}"), 19 | versionCode = forge.aPositiveInt(), 20 | variant = forge.anAlphabeticalString(), 21 | buildId = forge.getForgery().toString() 22 | ) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/kotlin/com/datadog/gradle/plugin/utils/forge/RepositoryInfoForgeryFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | package com.datadog.gradle.plugin.utils.forge 8 | 9 | import com.datadog.gradle.plugin.RepositoryInfo 10 | import fr.xgouchet.elmyr.Case 11 | import fr.xgouchet.elmyr.Forge 12 | import fr.xgouchet.elmyr.ForgeryFactory 13 | 14 | class RepositoryInfoForgeryFactory : ForgeryFactory { 15 | override fun getForgery(forge: Forge): RepositoryInfo { 16 | return RepositoryInfo( 17 | url = forge.aStringMatching("git@github\\.com:[a-z]+/[a-z][a-z0-9_-]+\\.git"), 18 | hash = forge.anHexadecimalString(Case.LOWER), 19 | sourceFiles = forge.aList { aStringMatching("\\w+(/\\w+)/\\w+\\.[a-z]{3}") } 20 | ) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_android_components.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | extensions.configure("androidComponents") { extension -> 13 | extension.onVariants(extension.selector().all()) { variant -> 14 | // just request assets, this will be enough to reproduce 15 | // https://issuetracker.google.com/issues/342428022 when using new Variant API + legacy one 16 | // with AGP 8.4.0 17 | if (variant.metaClass.respondsTo(variant, "getSources")) { 18 | // available only since AGP 7.2.0 19 | variant.getSources().getAssets() 20 | } 21 | } 22 | } 23 | 24 | android { 25 | compileSdkVersion = rootProject.ext.targetSdkVersion 26 | buildToolsVersion = rootProject.ext.buildToolsVersion 27 | 28 | defaultConfig { 29 | applicationId "com.example.variants" 30 | minSdkVersion 21 31 | targetSdkVersion rootProject.ext.targetSdkVersion 32 | versionCode 1 33 | versionName "1.0" 34 | multiDexEnabled = true 35 | } 36 | 37 | buildTypes { 38 | release { 39 | minifyEnabled true 40 | proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' 41 | } 42 | } 43 | 44 | namespace = "com.example.variants" 45 | 46 | compileOptions { 47 | sourceCompatibility = rootProject.ext.jvmTarget 48 | targetCompatibility = rootProject.ext.jvmTarget 49 | } 50 | 51 | kotlinOptions { 52 | jvmTarget = rootProject.ext.jvmTarget 53 | } 54 | } 55 | 56 | dependencies { 57 | implementation(rootProject.ext.datadogSdkDependency) 58 | } 59 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_check_deps_disabled.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | datadog { 66 | checkProjectDependencies = "none" 67 | } 68 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_check_deps_set_to_warn.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | datadog { 66 | checkProjectDependencies = "warn" 67 | } 68 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_custom_remote_repos_url.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | dependencies { 66 | implementation(rootProject.ext.datadogSdkDependency) 67 | } 68 | 69 | datadog { 70 | remoteRepositoryUrl = "http://github.com:fakeapp/repository.git" 71 | } 72 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_datadog_dep.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | dependencies { 66 | implementation(rootProject.ext.datadogSdkDependency) 67 | } 68 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_lib_module_attached.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | dependencies { 66 | implementation(project(':samples:lib-module')) 67 | implementation(rootProject.ext.datadogSdkDependency) 68 | } 69 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_minify_not_enabled.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | namespace = "com.example.variants" 26 | 27 | compileOptions { 28 | sourceCompatibility = rootProject.ext.jvmTarget 29 | targetCompatibility = rootProject.ext.jvmTarget 30 | } 31 | 32 | kotlinOptions { 33 | jvmTarget = rootProject.ext.jvmTarget 34 | } 35 | 36 | flavorDimensions("version", "colour") 37 | productFlavors { 38 | demo { 39 | dimension "version" 40 | applicationIdSuffix ".demo" 41 | versionNameSuffix "-demo" 42 | } 43 | full { 44 | dimension "version" 45 | applicationIdSuffix ".full" 46 | versionNameSuffix "-full" 47 | } 48 | 49 | green { 50 | dimension "colour" 51 | } 52 | blue { 53 | dimension "colour" 54 | } 55 | } 56 | } 57 | 58 | dependencies { 59 | implementation(rootProject.ext.datadogSdkDependency) 60 | } 61 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_non_default_obfuscation.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | dependencies { 66 | implementation(rootProject.ext.datadogSdkDependency) 67 | } 68 | 69 | datadog { 70 | nonDefaultObfuscation = true 71 | } 72 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_optimized_mapping.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | namespace = "com.example.variants" 26 | 27 | buildTypes { 28 | release { 29 | minifyEnabled true 30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | dependencies { 66 | implementation(rootProject.ext.datadogSdkDependency) 67 | } 68 | 69 | datadog { 70 | mappingFilePackageAliases = ["java.lang": "jl"] 71 | mappingFileTrimIndents = true 72 | } 73 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_plugin_disabled.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | 65 | dependencies { 66 | implementation(rootProject.ext.datadogSdkDependency) 67 | } 68 | 69 | datadog { 70 | enabled = false 71 | } 72 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_with_variant_override.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | namespace = "com.example.variants" 26 | 27 | buildTypes { 28 | release { 29 | minifyEnabled true 30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | pro { 46 | dimension "version" 47 | applicationIdSuffix ".pro" 48 | versionNameSuffix "-pro" 49 | } 50 | 51 | green { 52 | dimension "colour" 53 | } 54 | blue { 55 | dimension "colour" 56 | } 57 | } 58 | } 59 | 60 | dependencies { 61 | implementation(rootProject.ext.datadogSdkDependency) 62 | } 63 | 64 | datadog { 65 | remoteRepositoryUrl = "http://github.com:fakeapp/repository.git" 66 | 67 | variants { 68 | pro { 69 | remoteRepositoryUrl = "http://github.com:fakeapp-another/repository.git" 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/build_without_datadog_dep.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | namespace = "com.example.variants" 26 | 27 | buildTypes { 28 | release { 29 | minifyEnabled true 30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | flavorDimensions("version", "colour") 44 | productFlavors { 45 | demo { 46 | dimension "version" 47 | applicationIdSuffix ".demo" 48 | versionNameSuffix "-demo" 49 | } 50 | full { 51 | dimension "version" 52 | applicationIdSuffix ".full" 53 | versionNameSuffix "-full" 54 | } 55 | 56 | green { 57 | dimension "colour" 58 | } 59 | blue { 60 | dimension "colour" 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/lib_module_build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | } 5 | 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | 11 | android { 12 | compileSdkVersion = rootProject.ext.targetSdkVersion 13 | buildToolsVersion = rootProject.ext.buildToolsVersion 14 | 15 | defaultConfig { 16 | minSdkVersion 21 17 | targetSdkVersion rootProject.ext.targetSdkVersion 18 | versionName "1.0" 19 | versionCode 1 20 | multiDexEnabled = true 21 | } 22 | 23 | namespace = "com.example.lib" 24 | 25 | compileOptions { 26 | sourceCompatibility = rootProject.ext.jvmTarget 27 | targetCompatibility = rootProject.ext.jvmTarget 28 | } 29 | 30 | kotlinOptions { 31 | jvmTarget = rootProject.ext.jvmTarget 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/native_gradle_files/build_with_custom_ndk.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | namespace = "com.example.variants" 26 | 27 | compileOptions { 28 | sourceCompatibility = rootProject.ext.jvmTarget 29 | targetCompatibility = rootProject.ext.jvmTarget 30 | } 31 | 32 | kotlinOptions { 33 | jvmTarget = rootProject.ext.jvmTarget 34 | } 35 | externalNativeBuild { 36 | cmake { 37 | path file('src/main/cpp/CMakeLists.txt') 38 | version '3.22.1' 39 | } 40 | } 41 | 42 | flavorDimensions("version", "colour") 43 | productFlavors { 44 | demo { 45 | dimension "version" 46 | applicationIdSuffix ".demo" 47 | versionNameSuffix "-demo" 48 | } 49 | full { 50 | dimension "version" 51 | applicationIdSuffix ".full" 52 | versionNameSuffix "-full" 53 | } 54 | 55 | green { 56 | dimension "colour" 57 | } 58 | blue { 59 | dimension "colour" 60 | } 61 | } 62 | } 63 | 64 | dependencies { 65 | implementation(rootProject.ext.datadogSdkDependency) 66 | } 67 | 68 | datadog { 69 | additionalSymbolFilesLocations = [ 70 | "custom" 71 | ] 72 | } 73 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/native_gradle_files/build_with_custom_ndk_no_externalNativeBuild.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | namespace = "com.example.variants" 26 | 27 | compileOptions { 28 | sourceCompatibility = rootProject.ext.jvmTarget 29 | targetCompatibility = rootProject.ext.jvmTarget 30 | } 31 | 32 | kotlinOptions { 33 | jvmTarget = rootProject.ext.jvmTarget 34 | } 35 | 36 | flavorDimensions("version", "colour") 37 | productFlavors { 38 | demo { 39 | dimension "version" 40 | applicationIdSuffix ".demo" 41 | versionNameSuffix "-demo" 42 | } 43 | full { 44 | dimension "version" 45 | applicationIdSuffix ".full" 46 | versionNameSuffix "-full" 47 | } 48 | 49 | green { 50 | dimension "colour" 51 | } 52 | blue { 53 | dimension "colour" 54 | } 55 | } 56 | } 57 | 58 | dependencies { 59 | implementation(rootProject.ext.datadogSdkDependency) 60 | } 61 | 62 | datadog { 63 | additionalSymbolFilesLocations = [ 64 | "custom" 65 | ] 66 | } 67 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/native_gradle_files/build_with_native_and_datadog_dep.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | namespace = "com.example.variants" 26 | 27 | compileOptions { 28 | sourceCompatibility = rootProject.ext.jvmTarget 29 | targetCompatibility = rootProject.ext.jvmTarget 30 | } 31 | 32 | kotlinOptions { 33 | jvmTarget = rootProject.ext.jvmTarget 34 | } 35 | externalNativeBuild { 36 | cmake { 37 | path file('src/main/cpp/CMakeLists.txt') 38 | version '3.22.1' 39 | } 40 | } 41 | 42 | flavorDimensions("version", "colour") 43 | productFlavors { 44 | demo { 45 | dimension "version" 46 | applicationIdSuffix ".demo" 47 | versionNameSuffix "-demo" 48 | } 49 | full { 50 | dimension "version" 51 | applicationIdSuffix ".full" 52 | versionNameSuffix "-full" 53 | } 54 | 55 | green { 56 | dimension "colour" 57 | } 58 | blue { 59 | dimension "colour" 60 | } 61 | } 62 | } 63 | 64 | dependencies { 65 | implementation(rootProject.ext.datadogSdkDependency) 66 | } 67 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/src/test/resources/native_gradle_files/build_with_proguard_native_and_datadog_dep.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | id("com.datadoghq.dd-sdk-android-gradle-plugin") 5 | } 6 | 7 | repositories { 8 | google() 9 | mavenCentral() 10 | } 11 | 12 | android { 13 | compileSdkVersion = rootProject.ext.targetSdkVersion 14 | buildToolsVersion = rootProject.ext.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId "com.example.variants" 18 | minSdkVersion 21 19 | targetSdkVersion rootProject.ext.targetSdkVersion 20 | versionCode 1 21 | versionName "1.0" 22 | multiDexEnabled = true 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.example.variants" 33 | 34 | compileOptions { 35 | sourceCompatibility = rootProject.ext.jvmTarget 36 | targetCompatibility = rootProject.ext.jvmTarget 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = rootProject.ext.jvmTarget 41 | } 42 | 43 | externalNativeBuild { 44 | cmake { 45 | path file('src/main/cpp/CMakeLists.txt') 46 | version '3.22.1' 47 | } 48 | } 49 | 50 | flavorDimensions("version", "colour") 51 | productFlavors { 52 | demo { 53 | dimension "version" 54 | applicationIdSuffix ".demo" 55 | versionNameSuffix "-demo" 56 | } 57 | full { 58 | dimension "version" 59 | applicationIdSuffix ".full" 60 | versionNameSuffix "-full" 61 | } 62 | 63 | green { 64 | dimension "colour" 65 | } 66 | blue { 67 | dimension "colour" 68 | } 69 | } 70 | } 71 | 72 | dependencies { 73 | implementation(rootProject.ext.datadogSdkDependency) 74 | } 75 | -------------------------------------------------------------------------------- /dd-sdk-android-gradle-plugin/transitiveDependencies: -------------------------------------------------------------------------------- 1 | Dependencies List 2 | 3 | com.squareup.okhttp3:okhttp:4.12.0 : 771 Kb 4 | com.squareup.okio:okio-jvm:3.6.0 : 351 Kb 5 | org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10 : 959 b 6 | org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10 : 965 b 7 | org.jetbrains.kotlin:kotlin-stdlib:2.0.21 : 1706 Kb 8 | org.jetbrains:annotations:13.0 : 17 Kb 9 | org.json:json:20231013 : 72 Kb 10 | 11 | Total transitive dependencies size : 2 Mb 12 | 13 | -------------------------------------------------------------------------------- /docs/images/deobfuscated_stacktrace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/docs/images/deobfuscated_stacktrace.png -------------------------------------------------------------------------------- /docs/images/obfuscated_stacktrace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/docs/images/obfuscated_stacktrace.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | # This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | # Copyright 2020-Present Datadog, Inc. 5 | # 6 | org.gradle.jvmargs=-Xmx2560m 7 | android.useAndroidX=true 8 | # Leave the next line blank for CI 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /instrumented/src/androidTest/java/com/datadog/android/instrumented/SemanticsTest.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.android.instrumented 2 | 3 | import androidx.compose.ui.test.SemanticsMatcher 4 | import androidx.compose.ui.test.assertCountEquals 5 | import androidx.compose.ui.test.junit4.createComposeRule 6 | import fr.xgouchet.elmyr.junit5.ForgeExtension 7 | import org.junit.Rule 8 | import org.junit.Test 9 | import org.junit.jupiter.api.extension.ExtendWith 10 | import org.junit.jupiter.api.extension.Extensions 11 | import org.mockito.junit.jupiter.MockitoExtension 12 | import org.mockito.junit.jupiter.MockitoSettings 13 | import org.mockito.quality.Strictness 14 | 15 | @Extensions( 16 | ExtendWith(MockitoExtension::class), 17 | ExtendWith(ForgeExtension::class) 18 | ) 19 | @MockitoSettings(strictness = Strictness.LENIENT) 20 | class SemanticsTest { 21 | 22 | @get:Rule 23 | val composeTestRule = createComposeRule() 24 | 25 | @Test 26 | fun `M have datadog semantics tag W modifier is absent`() { 27 | composeTestRule.setContent { 28 | ScreenWithoutModifier() 29 | } 30 | val columnSemanticsMatcher = hasSemanticsValue(DD_SEMANTICS_KEY_NAME, "Column") 31 | composeTestRule.onAllNodes(columnSemanticsMatcher).assertCountEquals(1) 32 | val textSemanticsMatcher = hasSemanticsValue(DD_SEMANTICS_KEY_NAME, "Text") 33 | composeTestRule.onAllNodes(textSemanticsMatcher).assertCountEquals(1) 34 | } 35 | 36 | @Test 37 | fun `M have datadog semantics tag W modifier is default`() { 38 | composeTestRule.setContent { 39 | ScreenWithDefaultModifier() 40 | } 41 | val textSemanticsMatcher = hasSemanticsValue(DD_SEMANTICS_KEY_NAME, "Text") 42 | composeTestRule.onAllNodes(textSemanticsMatcher).assertCountEquals(1) 43 | val columnSemanticsMatcher = hasSemanticsValue(DD_SEMANTICS_KEY_NAME, "Column") 44 | composeTestRule.onAllNodes(columnSemanticsMatcher).assertCountEquals(1) 45 | } 46 | 47 | @Test 48 | fun `M have datadog semantics tag W modifier is custom`() { 49 | composeTestRule.setContent { 50 | ScreenWithCustomModifier() 51 | } 52 | val textSemanticsMatcher = hasSemanticsValue(DD_SEMANTICS_KEY_NAME, "Text") 53 | composeTestRule.onAllNodes(textSemanticsMatcher).assertCountEquals(1) 54 | val columnSemanticsMatcher = hasSemanticsValue(DD_SEMANTICS_KEY_NAME, "Column") 55 | composeTestRule.onAllNodes(columnSemanticsMatcher).assertCountEquals(1) 56 | } 57 | 58 | private fun hasSemanticsValue( 59 | keyName: String, 60 | expectedValue: T 61 | ): SemanticsMatcher { 62 | return SemanticsMatcher("$keyName = $expectedValue") { node -> 63 | val entry = node.config.firstOrNull { it.key.name == keyName } 64 | entry != null && entry.value == expectedValue 65 | } 66 | } 67 | 68 | companion object { 69 | private const val DD_SEMANTICS_KEY_NAME = "_dd_semantics" 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /instrumented/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /instrumented/src/main/java/com/datadog/android/instrumented/NavHostTestScreen.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.android.instrumented 2 | 3 | import androidx.compose.foundation.layout.Column 4 | import androidx.compose.foundation.layout.Row 5 | import androidx.compose.material3.Text 6 | import androidx.compose.runtime.Composable 7 | import androidx.compose.runtime.DisposableEffect 8 | import androidx.compose.ui.platform.LocalLifecycleOwner 9 | import androidx.lifecycle.Lifecycle 10 | import androidx.lifecycle.LifecycleEventObserver 11 | import androidx.navigation.NavHostController 12 | import androidx.navigation.compose.NavHost 13 | import androidx.navigation.compose.composable 14 | import androidx.navigation.compose.rememberNavController 15 | 16 | @Composable 17 | internal fun ScreenWithNavHost(onEvent: (NavHostController, Lifecycle.Event) -> Unit) { 18 | val navHost = rememberNavController() 19 | NavHost(navHost, TEST_DESTINATION) { 20 | composable(TEST_DESTINATION) { 21 | Text(text = TEST_TEXT) 22 | } 23 | } 24 | val lifecycleOwner = LocalLifecycleOwner.current 25 | DisposableEffect(lifecycleOwner) { 26 | val observer = LifecycleEventObserver { source, event -> 27 | onEvent(navHost, event) 28 | } 29 | lifecycleOwner.lifecycle.addObserver(observer) 30 | onDispose { 31 | lifecycleOwner.lifecycle.removeObserver(observer) 32 | } 33 | } 34 | } 35 | 36 | @Composable 37 | internal fun ScreenWithNavHostNested(onEvent: (NavHostController, Lifecycle.Event) -> Unit) { 38 | Column { 39 | Row { 40 | val navHost = rememberNavController() 41 | NavHost(navHost, TEST_DESTINATION) { 42 | composable(TEST_DESTINATION) { 43 | Text(text = TEST_TEXT) 44 | } 45 | } 46 | val lifecycleOwner = LocalLifecycleOwner.current 47 | DisposableEffect(lifecycleOwner) { 48 | val observer = LifecycleEventObserver { source, event -> 49 | onEvent(navHost, event) 50 | } 51 | lifecycleOwner.lifecycle.addObserver(observer) 52 | onDispose { 53 | lifecycleOwner.lifecycle.removeObserver(observer) 54 | } 55 | } 56 | } 57 | } 58 | } 59 | 60 | internal const val TEST_TEXT = "ScreenWithNavHost" 61 | internal const val TEST_DESTINATION = "destination" 62 | -------------------------------------------------------------------------------- /instrumented/src/main/java/com/datadog/android/instrumented/TagTestScreen.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.android.instrumented 2 | 3 | import androidx.compose.foundation.background 4 | import androidx.compose.foundation.layout.Column 5 | import androidx.compose.foundation.layout.fillMaxSize 6 | import androidx.compose.material3.Text 7 | import androidx.compose.runtime.Composable 8 | import androidx.compose.ui.Alignment 9 | import androidx.compose.ui.Modifier 10 | import androidx.compose.ui.graphics.Color 11 | 12 | @Composable 13 | internal fun ScreenWithoutModifier() { 14 | Column { 15 | Text( 16 | text = "ScreenWithoutModifier" 17 | ) 18 | } 19 | } 20 | 21 | @Composable 22 | internal fun ScreenWithDefaultModifier() { 23 | Column(modifier = Modifier) { 24 | Text( 25 | modifier = Modifier, 26 | text = "ScreenWithDefaultModifier" 27 | ) 28 | } 29 | } 30 | 31 | @Composable 32 | internal fun ScreenWithCustomModifier() { 33 | Column( 34 | modifier = Modifier 35 | .fillMaxSize() 36 | .background(color = Color.Red) 37 | ) { 38 | Text( 39 | modifier = Modifier.align(Alignment.CenterHorizontally), 40 | text = "ScreenWithCustomModifier" 41 | ) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libs/dd-java-agent-1.26.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/libs/dd-java-agent-1.26.1.jar -------------------------------------------------------------------------------- /samples/basic/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /samples/basic/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | //apply plugin: 'com.datadoghq.dd-sdk-android-gradle-plugin' 4 | 5 | import com.datadog.gradle.config.AndroidConfig 6 | 7 | android { 8 | compileSdkVersion = AndroidConfig.TARGET_SDK 9 | buildToolsVersion = AndroidConfig.BUILD_TOOLS_VERSION 10 | 11 | defaultConfig { 12 | applicationId "com.datadog.example.basic" 13 | minSdkVersion AndroidConfig.MIN_SDK 14 | targetSdkVersion AndroidConfig.TARGET_SDK 15 | versionCode 1 16 | versionName "1.0" 17 | 18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 19 | } 20 | 21 | buildTypes { 22 | release { 23 | minifyEnabled true 24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | 28 | namespace = "com.datadog.example.basic" 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_17 32 | targetCompatibility JavaVersion.VERSION_17 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = '17' 37 | } 38 | } 39 | 40 | dependencies { 41 | implementation(project(':samples:lib-module')) 42 | implementation(libs.kotlin) 43 | 44 | implementation(libs.androidx.core) 45 | implementation(libs.androidx.appcompat) 46 | implementation(libs.androidx.constraintlayout) 47 | 48 | // implementation(libs.datadogSdkRum) 49 | } 50 | 51 | 52 | //datadog { 53 | // site = "US" 54 | // versionName = "prod" 55 | //} -------------------------------------------------------------------------------- /samples/basic/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /samples/basic/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/basic/src/main/java/com/datadog/example/basic/MainActivity.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnusedImports", "ktlint:standard:no-unused-imports") 2 | 3 | package com.datadog.example.basic 4 | 5 | import android.os.Bundle 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.datadog.example.lib.Placeholder // unused import is on purpose 8 | 9 | /** 10 | * Main Activity for the sample app. 11 | */ 12 | class MainActivity : AppCompatActivity() { 13 | 14 | private lateinit var toaster: Toaster 15 | 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | 19 | toaster = Toaster(this) 20 | setContentView(R.layout.activity_main) 21 | } 22 | 23 | override fun onResume() { 24 | super.onResume() 25 | toaster.toast("Hello world !") 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/basic/src/main/java/com/datadog/example/basic/Toaster.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.basic 2 | 3 | import android.content.Context 4 | import android.widget.Toast 5 | 6 | internal class Toaster(context: Context) { 7 | 8 | val appContext = context.applicationContext 9 | 10 | fun toast(msg: String) { 11 | Toast.makeText(appContext, msg, Toast.LENGTH_LONG).show() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/basic/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 15 | 16 | 22 | 25 | 28 | 29 | 30 | 31 | 37 | -------------------------------------------------------------------------------- /samples/basic/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/basic/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/basic/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | #6200EE 10 | #3700B3 11 | #03DAC5 12 | -------------------------------------------------------------------------------- /samples/basic/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Sample App 9 | -------------------------------------------------------------------------------- /samples/basic/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /samples/lib-module/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /samples/lib-module/build.gradle: -------------------------------------------------------------------------------- 1 | import com.datadog.gradle.config.AndroidConfig 2 | 3 | plugins { 4 | id 'com.android.library' 5 | id 'kotlin-android' 6 | } 7 | 8 | android { 9 | compileSdk AndroidConfig.TARGET_SDK 10 | 11 | defaultConfig { 12 | minSdk AndroidConfig.MIN_SDK 13 | targetSdk AndroidConfig.TARGET_SDK 14 | versionCode 1 15 | versionName "1.0" 16 | } 17 | 18 | namespace = "com.datadog.example.lib" 19 | 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_17 22 | targetCompatibility JavaVersion.VERSION_17 23 | } 24 | 25 | kotlinOptions { 26 | jvmTarget = '17' 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation(platform(libs.androidx.compose.bom)) 32 | implementation(libs.androidx.ui) 33 | implementation(libs.androidx.ui.graphics) 34 | implementation(libs.androidx.ui.tooling.preview) 35 | implementation(libs.androidx.material3) 36 | } 37 | -------------------------------------------------------------------------------- /samples/lib-module/src/main/kotlin/com/datadog/android/compose/ComposeInstrumentation.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.android.compose 2 | 3 | /** 4 | * Fake annotation for kotlin compiler plugin testing purpose. 5 | */ 6 | @Retention(AnnotationRetention.BINARY) 7 | annotation class ComposeInstrumentation 8 | -------------------------------------------------------------------------------- /samples/lib-module/src/main/kotlin/com/datadog/android/compose/DatadogModifier.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.android.compose 2 | 3 | import androidx.compose.ui.Modifier 4 | import androidx.compose.ui.semantics.Role 5 | import androidx.compose.ui.semantics.SemanticsProperties 6 | import androidx.compose.ui.semantics.SemanticsPropertyKey 7 | import androidx.compose.ui.semantics.SemanticsPropertyReceiver 8 | import androidx.compose.ui.semantics.semantics 9 | 10 | /** 11 | * Function to simulate production function in SDK code base for instrumented testing purpose. 12 | * This function should have exactly the same package name, function signature and return type 13 | * with the production one. 14 | */ 15 | internal fun Modifier.instrumentedDatadog(name: String, isImageRole: Boolean = false): Modifier { 16 | return this.semantics { 17 | this.datadog = name 18 | if (isImageRole) { 19 | this[SemanticsProperties.Role] = Role.Image 20 | } 21 | } 22 | } 23 | 24 | internal val DatadogSemanticsPropertyKey: SemanticsPropertyKey = SemanticsPropertyKey( 25 | name = "_dd_semantics", 26 | mergePolicy = { parentValue, _ -> 27 | parentValue 28 | } 29 | ) 30 | 31 | private var SemanticsPropertyReceiver.datadog by DatadogSemanticsPropertyKey 32 | -------------------------------------------------------------------------------- /samples/lib-module/src/main/kotlin/com/datadog/example/lib/Placeholder.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.lib 2 | 3 | /** 4 | * Placeholder class to showcase the use of a multi-module project. 5 | */ 6 | class Placeholder { 7 | // no-op class, just to have a compilation unit 8 | // this module exists to test multi-module resolution for the dependency check task 9 | } 10 | -------------------------------------------------------------------------------- /samples/ndk/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /samples/ndk/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | 4 | import com.datadog.gradle.config.AndroidConfig 5 | 6 | android { 7 | compileSdkVersion = AndroidConfig.TARGET_SDK 8 | buildToolsVersion = AndroidConfig.BUILD_TOOLS_VERSION 9 | 10 | defaultConfig { 11 | applicationId "com.datadog.example.ndk" 12 | minSdkVersion AndroidConfig.MIN_SDK 13 | targetSdkVersion AndroidConfig.TARGET_SDK 14 | versionCode 1 15 | versionName "1.0" 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | externalNativeBuild { 19 | cmake { 20 | cppFlags '' 21 | } 22 | } 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | namespace = "com.datadog.example.ndk" 33 | 34 | compileOptions { 35 | sourceCompatibility JavaVersion.VERSION_17 36 | targetCompatibility JavaVersion.VERSION_17 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = '17' 41 | } 42 | externalNativeBuild { 43 | cmake { 44 | path file('src/main/cpp/CMakeLists.txt') 45 | version '3.22.1' 46 | } 47 | } 48 | } 49 | 50 | dependencies { 51 | implementation(project(':samples:lib-module')) 52 | implementation(libs.kotlin) 53 | 54 | implementation(libs.androidx.core) 55 | implementation(libs.androidx.appcompat) 56 | implementation(libs.androidx.constraintlayout) 57 | 58 | // implementation(libs.datadogSdkRum) 59 | } 60 | -------------------------------------------------------------------------------- /samples/ndk/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /samples/ndk/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 10 | 11 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/ndk/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # For more information about using CMake with Android Studio, read the 3 | # documentation: https://d.android.com/studio/projects/add-native-code.html. 4 | # For more examples on how to use CMake, see https://github.com/android/ndk-samples. 5 | 6 | # Sets the minimum CMake version required for this project. 7 | cmake_minimum_required(VERSION 3.22.1) 8 | 9 | # Declares the project name. The project name can be accessed via ${ PROJECT_NAME}, 10 | # Since this is the top level CMakeLists.txt, the project name is also accessible 11 | # with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level 12 | # build script scope). 13 | project("ndk") 14 | 15 | # Creates and names a library, sets it as either STATIC 16 | # or SHARED, and provides the relative paths to its source code. 17 | # You can define multiple libraries, and CMake builds them for you. 18 | # Gradle automatically packages shared libraries with your APK. 19 | # 20 | # In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define 21 | # the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME} 22 | # is preferred for the same purpose. 23 | # 24 | # In order to load a library into your app from Java/Kotlin, you must call 25 | # System.loadLibrary() and pass the name of the library defined here; 26 | # for GameActivity/NativeActivity derived applications, the same library name must be 27 | # used in the AndroidManifest.xml file. 28 | add_library(${CMAKE_PROJECT_NAME} SHARED 29 | # List C/C++ source files with relative paths to this CMakeLists.txt. 30 | native_code.cpp) 31 | 32 | # Specifies libraries CMake should link to your target library. You 33 | # can link libraries from various origins, such as libraries defined in this 34 | # build script, prebuilt third-party libraries, or Android system libraries. 35 | target_link_libraries(${CMAKE_PROJECT_NAME} 36 | # List libraries link to the target library 37 | android 38 | log) 39 | -------------------------------------------------------------------------------- /samples/ndk/src/main/cpp/native_code.cpp: -------------------------------------------------------------------------------- 1 | // Write C++ code here. 2 | // 3 | // Do not forget to dynamically load the C++ library into your application. 4 | // 5 | // For instance, 6 | // 7 | // In MainActivity.java: 8 | // static { 9 | // System.loadLibrary("ndk"); 10 | // } 11 | // 12 | // Or, in MainActivity.kt: 13 | // companion object { 14 | // init { 15 | // System.loadLibrary("ndk") 16 | // } 17 | // } 18 | 19 | #include 20 | 21 | extern "C" JNIEXPORT jstring JNICALL 22 | Java_com_datadog_example_ndk_MainActivity_stringFromJNI( JNIEnv* env, 23 | jobject object ) { 24 | return env->NewStringUTF("Hello from JNI!"); 25 | } -------------------------------------------------------------------------------- /samples/ndk/src/main/java/com/datadog/example/ndk/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.ndk 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | 6 | /** 7 | * Main Activity for the sample app. 8 | */ 9 | class MainActivity : AppCompatActivity() { 10 | 11 | private lateinit var toaster: Toaster 12 | 13 | override fun onCreate(savedInstanceState: Bundle?) { 14 | super.onCreate(savedInstanceState) 15 | 16 | toaster = Toaster(this) 17 | setContentView(R.layout.activity_main) 18 | } 19 | 20 | override fun onResume() { 21 | super.onResume() 22 | toaster.toast(stringFromJNI()) 23 | } 24 | 25 | private external fun stringFromJNI(): String 26 | 27 | companion object { 28 | init { 29 | System.loadLibrary("ndk") 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/ndk/src/main/java/com/datadog/example/ndk/Toaster.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.ndk 2 | 3 | import android.content.Context 4 | import android.widget.Toast 5 | 6 | internal class Toaster(context: Context) { 7 | 8 | val appContext = context.applicationContext 9 | 10 | fun toast(msg: String) { 11 | Toast.makeText(appContext, msg, Toast.LENGTH_LONG).show() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/ndk/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 15 | 16 | 22 | 25 | 28 | 29 | 30 | 31 | 37 | -------------------------------------------------------------------------------- /samples/ndk/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/ndk/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/ndk/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | #6200EE 10 | #3700B3 11 | #03DAC5 12 | -------------------------------------------------------------------------------- /samples/ndk/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Sample App 9 | -------------------------------------------------------------------------------- /samples/ndk/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /samples/variants-kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /samples/variants-kotlin/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle.kts. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /samples/variants-kotlin/src/demo/java/com/datadog/example/variants/VaryingClass.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal class VaryingClass : VaryingInfo { 4 | override fun getName(): String = "demo" 5 | } 6 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/full/java/com/datadog/example/variants/VaryingClass.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal class VaryingClass : VaryingInfo { 4 | override fun getName(): String = "full" 5 | } 6 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/java/com/datadog/example/variants/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.datadog.example.variants.ext.toast 6 | 7 | /** 8 | * Main Activity for the sample app. 9 | */ 10 | class MainActivity : AppCompatActivity() { 11 | 12 | private val varyingClass: VaryingInfo = VaryingClass() 13 | 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | setContentView(R.layout.activity_main) 17 | } 18 | 19 | override fun onResume() { 20 | super.onResume() 21 | toast("Hello World, with ${varyingClass.getName()}") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/java/com/datadog/example/variants/VaryingInfo.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal interface VaryingInfo { 4 | fun getName(): String 5 | } 6 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/kotlin/com/datadog/example/variants/ext/ActivityExt.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants.ext 2 | 3 | import android.app.Activity 4 | import android.widget.Toast 5 | 6 | internal fun Activity.toast(message: String) { 7 | Toast.makeText(this, message, Toast.LENGTH_LONG).show() 8 | } 9 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 15 | 16 | 22 | 25 | 28 | 29 | 30 | 31 | 37 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants-kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | #6200EE 10 | #3700B3 11 | #03DAC5 12 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Sample App 9 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /samples/variants-kotlin/src/pro/java/com/datadog/example/variants/VaryingClass.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal class VaryingClass : VaryingInfo { 4 | override fun getName(): String = "pro" 5 | } 6 | -------------------------------------------------------------------------------- /samples/variants/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /samples/variants/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | //apply plugin: 'com.datadoghq.dd-sdk-android-gradle-plugin' 4 | 5 | import com.datadog.gradle.config.AndroidConfig 6 | 7 | android { 8 | compileSdkVersion = AndroidConfig.TARGET_SDK 9 | buildToolsVersion = AndroidConfig.BUILD_TOOLS_VERSION 10 | 11 | defaultConfig { 12 | applicationId "com.datadog.example.variants" 13 | minSdkVersion AndroidConfig.MIN_SDK 14 | targetSdkVersion AndroidConfig.TARGET_SDK 15 | versionCode 1 16 | versionName "1.0" 17 | 18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 19 | } 20 | 21 | buildTypes { 22 | release { 23 | minifyEnabled true 24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | 28 | namespace = "com.datadog.example.variants" 29 | 30 | sourceSets.named("main") { 31 | java.srcDir("src/main/kotlin") 32 | } 33 | 34 | flavorDimensions("version", "colour") 35 | productFlavors { 36 | demo { 37 | dimension "version" 38 | applicationIdSuffix ".demo" 39 | versionNameSuffix "-demo" 40 | } 41 | full { 42 | dimension "version" 43 | applicationIdSuffix ".full" 44 | versionNameSuffix "-full" 45 | } 46 | pro { 47 | dimension "version" 48 | applicationIdSuffix ".pro" 49 | versionNameSuffix "-pro" 50 | } 51 | 52 | red { 53 | dimension "colour" 54 | } 55 | green { 56 | dimension "colour" 57 | } 58 | blue { 59 | dimension "colour" 60 | } 61 | } 62 | 63 | compileOptions { 64 | sourceCompatibility JavaVersion.VERSION_17 65 | targetCompatibility JavaVersion.VERSION_17 66 | } 67 | 68 | kotlinOptions { 69 | jvmTarget = '17' 70 | } 71 | } 72 | 73 | dependencies { 74 | implementation(project(':samples:lib-module')) 75 | implementation(libs.kotlin) 76 | 77 | implementation(libs.androidx.core) 78 | implementation(libs.androidx.appcompat) 79 | implementation(libs.androidx.constraintlayout) 80 | 81 | // implementation(libs.datadogSdkRum) 82 | } 83 | 84 | //datadog { 85 | // site = "US" 86 | // checkProjectDependencies = "fail" 87 | // mappingFilePath = "path/to/mapping.txt" 88 | // variants { 89 | // demo { 90 | // versionName = "demo" 91 | // } 92 | // full { 93 | // versionName = "full" 94 | // } 95 | // pro { 96 | // site = "GOV" 97 | // versionName = "pro" 98 | // } 99 | // } 100 | //} 101 | -------------------------------------------------------------------------------- /samples/variants/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /samples/variants/src/demo/java/com/datadog/example/variants/VaryingClass.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal class VaryingClass : VaryingInfo { 4 | override fun getName(): String = "demo" 5 | } 6 | -------------------------------------------------------------------------------- /samples/variants/src/full/java/com/datadog/example/variants/VaryingClass.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal class VaryingClass : VaryingInfo { 4 | override fun getName(): String = "full" 5 | } 6 | -------------------------------------------------------------------------------- /samples/variants/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/variants/src/main/java/com/datadog/example/variants/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.datadog.example.variants.ext.toast 6 | 7 | /** 8 | * Main Activity for the sample app. 9 | */ 10 | class MainActivity : AppCompatActivity() { 11 | 12 | private val varyingClass: VaryingInfo = VaryingClass() 13 | 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | setContentView(R.layout.activity_main) 17 | } 18 | 19 | override fun onResume() { 20 | super.onResume() 21 | toast("Hello World, with ${varyingClass.getName()}") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/variants/src/main/java/com/datadog/example/variants/VaryingInfo.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal interface VaryingInfo { 4 | fun getName(): String 5 | } 6 | -------------------------------------------------------------------------------- /samples/variants/src/main/kotlin/com/datadog/example/variants/ext/ActivityExt.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants.ext 2 | 3 | import android.app.Activity 4 | import android.widget.Toast 5 | 6 | internal fun Activity.toast(message: String) { 7 | Toast.makeText(this, message, Toast.LENGTH_LONG).show() 8 | } 9 | -------------------------------------------------------------------------------- /samples/variants/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 15 | 16 | 22 | 25 | 28 | 29 | 30 | 31 | 37 | -------------------------------------------------------------------------------- /samples/variants/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataDog/dd-sdk-android-gradle-plugin/985a7ab536f3143b3b2e5f104e792a8cdae5ea72/samples/variants/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /samples/variants/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | #6200EE 10 | #3700B3 11 | #03DAC5 12 | -------------------------------------------------------------------------------- /samples/variants/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Sample App 9 | -------------------------------------------------------------------------------- /samples/variants/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /samples/variants/src/pro/java/com/datadog/example/variants/VaryingClass.kt: -------------------------------------------------------------------------------- 1 | package com.datadog.example.variants 2 | 3 | internal class VaryingClass : VaryingInfo { 4 | override fun getName(): String = "pro" 5 | } 6 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. 3 | * This product includes software developed at Datadog (https://www.datadoghq.com/). 4 | * Copyright 2020-Present Datadog, Inc. 5 | */ 6 | 7 | include(":dd-sdk-android-gradle-plugin") 8 | 9 | include(":samples:basic") 10 | include(":samples:ndk") 11 | include(":samples:variants") 12 | include(":samples:variants-kotlin") 13 | include(":samples:lib-module") 14 | include(":instrumented") 15 | --------------------------------------------------------------------------------