Skip to content

Properties of extensions that are containers should have Kotlin DSL accessors for existing elements #9264

@eskatos

Description

@eskatos

so they are easily discoverable and configurable.

Example below configuring the Android Gradle Plugin.

Expected Behavior

plugins {
  id("com.android.application")
}

android {
    buildTypes {
        debug {
            // ...
        }
        release {
            // ...
        }
    }
    signingConfigs {
        debug {
            // ...
        }
        release {
            // ...
        }
    }
}

Current Behavior

plugins {
  id("com.android.application")
}

android {
    buildTypes {
        named("debug") {
            // ...
        }
        named("release") {
            // ...
        }
    }
    signingConfigs {
        named("debug") {
            // ...
        }
        named("release") {
            // ...
        }
    }
}

Open questions

  • project schema collection rules
  • performance impact
  • adding more element accessors raises the chance of accessor target conflict if container type isn't specialized, and there's no public api to do it

Implementation notes

Implementation wise the ProjectSchemaProvider should be enhanced to iterate on the properties of each extension and handle those that are assignable to NamedDomainObjectContainer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions