Search code examples
androidkotlingroovygradle-kotlin-dslappdynamics

Convert groovy to kotlin dsl


Hi everyone I use appDynamics library and the documentation only explains with groovy Gradle, I have a problem with converting the groovy Gradle script to kotlin Gradle DSL and I have tried several ways and several syntaxes and I even used converting tools from groovy to Kotlin Gradle also didn't solve the problem following script with groovy Gradle

adeum {
    
    account {
        name 'xxx'
        licenseKey 'yyyy'
    }
    proguardMappingFileUpload {
        failBuildOnUploadFailure true //should build fail if upload fails? Defaults to false.
        enabled true //enables automatic uploads. Defaults to true.
    }
}

[Error][1] [1]: https://i.sstatic.net/tet7q.png

and also i have to mention that the groovy is working fine


Solution

  • The problem is in some plugins in kts you have to use closure to determine the plugin packages

     adeum {
               account(closureOf<com.appdynamics.android.gradle.ADPluginExtension.Account> {
                this.name ="xxx"
                this.licenseKey ="yyy"
        
            })
            proguardMappingFileUpload(closureOf<com.appdynamics.android.gradle.ADPluginExtension.ProguardConfig> {
                this.failBuildOnUploadFailure = true
                this.enabled = true
            })
        }