Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to generate plugin extensions #1

Open
JavierSegoviaCordoba opened this issue Feb 20, 2024 · 0 comments
Open

Add support to generate plugin extensions #1

JavierSegoviaCordoba opened this issue Feb 20, 2024 · 0 comments

Comments

@JavierSegoviaCordoba
Copy link
Contributor

JavierSegoviaCordoba commented Feb 20, 2024

The extensions are isolated so they can be seen as a data class to contain all properties and any behavior on it can be a method.

Any knowledge about lazy APIs and Gradle internal could be ignored and just use Kotlin basic types, under the hood they will be mapped to lazy APIs.

An example could be:

@GExtension
data class MyFancyExtension(
    val prop1: String,
    val prop2: GFile, // or `GInputFile` ?
    @GAssisted val randomThing: RandomThing,
) {
    fun foo() {
         // do something with props
    }
}
// generated, automatically add `ProjectLayout`, `ObjectFactory`, 
// and any `@GAssisted` value.
open class MyFancyExtension @Inject constructor(...) {

    val prop1: Property<String> = ...

    val prop2: FileProperty = ...

    fun foo() {
        // do something with props
    }
}

The annotation @GAssisted would help to enable doing anything in complex use cases.

Nested extensions should be supported automatically:

@GExtension
data class RootFancyExtension(val nestedFancy: NestedFancyExtension, ...)

@GExtension
data class NestedFancyExtension(...)

should be consumed on the user side:

rootFancy {
    // ...
    
    nestedFancy {
        // ...
    }
}

The annotation @GExtension could support specifying a name: String? = null. If it is not indicated, the name should be extracted from the class name by decapitalizing and removing the suffix Extension from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant