DynatraceExtension

API Documentation:DynatraceExtension

The dynatrace extension for specifying the auto-instrumentor configuration

Properties

PropertyDescription
configurations

Specifies multiple variant-specific configurations, where each variant-specific configuration can be applied to multiple Android build variants.

pluginEnabled

Specifies if the plugin should be enabled.

strictMode

Specifies if the build should fail, when the current variant has no variant-specific configuration.

Methods

No methods

Script blocks

BlockDescription
configurations

Specifies multiple variant-specific configurations, where each variant-specific configuration can be applied to multiple Android build variants.

Property details

Specifies multiple variant-specific configurations, where each variant-specific configuration can be applied to multiple Android build variants.

boolean pluginEnabled

Specifies if the plugin should be enabled.

If set to false, the plugin is applied but it does not insert the auto-instrumentation task into the Android build and it does not verify if the configuration of the extension is valid. It provides an easy way to temporarily deactivate the plugin.

The default value is true.

boolean strictMode

Specifies if the build should fail, when the current variant has no variant-specific configuration.

If set to false, the build will not fail and the plugin assumes that instrumentation was disabled for this build

The default value is true.

Script block details

configurations { }

Specifies multiple variant-specific configurations, where each variant-specific configuration can be applied to multiple Android build variants.

The association is determined by the regex, that is specified in the variantFilter property, and the variant name of the Android build variant. The regex is case sensitivity and if no product flavor is defined, the build type in the variant name is lower case. If multiple variant-specific configurations match the same variant, then the first specified configuration is selected and applied.

For example, you can have an app that has two product flavors 'demo' and 'paid' and the two default build types 'debug' and 'release'. The Dynatrace Android Gradle plugin allows you to specify a variant-specific configuration for all debug build variants ('demoDebug' and 'paidRelease') and another two variant-specific configurations for your variants 'demoRelease' and 'paidRelease'. The sample below shows how to specify the variant-specific configuration in the dynatrace block.

dynatrace {
    configurations {
        dev {
            variantFilter "Debug" // build type name is upper case because a product flavor is used
            // other variant-specific properties
        }
        demo {
            variantFilter "demo" // the first product flavor name is always lower case
            // other variant-specific properties
        }
        prod {
            variantFilter "Release" // build type name is upper case because a product flavor is used
            // other variant-specific properties
       }
   }
}

The association between variant-specific configurations from the Dynatrace Android Gradle plugin and the Android build variants can be printed with the task printVariantAffiliation. For example, the sample below shows you the console output for the above example.

> Task :app:printVariantAffiliation
Variant 'demoDebug' will use configuration 'dev'
Variant 'demoRelease' will use configuration 'demo'
Variant 'paidDebug' will use configuration 'dev'
Variant 'paidRelease' will use configuration 'prod'