简体   繁体   中英

Migrating from build.gradle to build.gradle.kts having issue with some code snippets

Kotlin 1.4.10
AS 4.1

I have a build.gradle (app) that I am migrating to build.gradle.kts . The only 2 code snippets I haven't been able to change is the following.

Just wondering what the following should be in build.gradle.kts

productFlavors {
    project.android.buildTypes.all { buildType ->
        buildType.javaCompileOptions.annotationProcessorOptions.arguments =
            [
                    enableParallelEpoxyProcessing: "true"
            ]
    }

    variantFilter { variant ->
        def names = variant.flavors*.name

        if ((names.contains("sit") && variant.buildType.name == "release")
                || (names.contains("staging") && variant.buildType.name == "release")) {
            variant.ignore = true
        }
    }
}

Many thanks for any suggestions,

I thinks it should be like this:

    productFlavors {
        project.android.buildTypes.forEach { buildType ->
            buildType.javaCompileOptions {
                annotationProcessorOptions {
                    argument("enableParallelEpoxyProcessing", "true")
                }
            }
        }

        variantFilter {
            val names = this.flavors.map { name }
            if ((names.contains("sit") && this.buildType.name == "release") ||
 (names.contains("staging") && this.buildType.name == "release")) {
                this.ignore = true
            }
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM