Class DynatraceExtension


  • public class DynatraceExtension
    extends Object
    The dynatrace extension for specifying the auto-instrumentor configuration
    • Constructor Detail

      • DynatraceExtension

        public DynatraceExtension​(Project project,
                                  org.gradle.internal.reflect.Instantiator instantiator)
    • Method Detail

      • pluginEnabled

        public void pluginEnabled​(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.

        Parameters:
        pluginEnabled - true, if the plugin should be enabled
      • strictMode

        public void strictMode​(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.

        Parameters:
        strictMode - true, if the build should fail, when the current variant has no variant-specific configuration
      • configurations

        public void configurations​(Action<? super NamedDomainObjectContainer<VariantConfiguration>> action)
        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'
         
        Parameters:
        action - action object to specific the VariantConfiguration
      • isPluginEnabled

        public boolean isPluginEnabled()
        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.

        Returns:
        true, if the plugin should be enabled
      • isStrictMode

        public boolean isStrictMode()
        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.

        Returns:
        true, if the build should fail, when the current variant has no variant-specific configuration
      • getConfigurations

        public NamedDomainObjectContainer<VariantConfiguration> getConfigurations()
        Specifies multiple variant-specific configurations, where each variant-specific configuration can be applied to multiple Android build variants.
        Returns:
        a list of variant-specific configurations