Javi
11/30/2024, 4:51 PM.dcl files.
The use case is configuring the X plugin from the Y plugin without having to create a middleware project extension or something similar which complicates the setup a lot.Sergey Igushkin
12/02/2024, 1:05 PMSergey Igushkin
12/02/2024, 1:08 PMJavi
12/02/2024, 1:54 PMhubdle {
configuration {
documentation {
readmeBadges {
kotlinBadgeEnabled = true
mavenCentralBadgeEnabled = true
...
}
}
}
kotlin {
jvm { ... }
}
}
I have a hubdle parent plugin, another for documentation, etc.
Even though readmeBadges is a plugin itself, it can be applied by the parent ones, even if at the end everything will be configured using the hubdle plugin.
I have implemented readmeBadges and documentation (and the wiring with readmeBadges).
The software type for documentation has a @Configuring for a readmeBadges method and the readmeBadges software type from the child project, in order to avoid "duplicating default setups" is being overridden so:
val readmeBadgesPlugin = project.plugins.apply(ReadmeBadgesPlugin::class)
documentation.readmeBadges = readmeBadgesPlugin.readmeBadge
The documentation plugin has a
abstract var readmeBadges: ReadmeBadges // check it is using `var`
@Configuring fun readmeBadges(action: Action<ReadmeBadges>) { ... }
Which allows reassigning it from the ReadmeBadgesPlugin.
I would like to directly get the child ReadmeBadges from the applied plugin without needing this var plus manual assignation. Something like:
@get:RestrictiveFromPlugin(ReadmeBadgesPlugin::class) abstract val readmeBadges: ReadmeBadges
Another pain point is making decisions based on a configuration but in the configuration phase. For example, based on a Boolean flag, applying or not a plugin or registering or not some tasks. This Boolean flag can be changed by the consumer in the .dcl file, but I haven't a simple way to get that info without using afterEvaluate { }
For this last, I have created an issue hereJavi
12/02/2024, 2:07 PMdependencies block
But it can be a blocker for early adopters.Sergey Igushkin
12/03/2024, 9:56 AMJavi
12/12/2024, 11:48 AMJavi
12/12/2024, 12:23 PMSergey Igushkin
12/13/2024, 2:21 PM@Configuring (note that they should not modify any other parts of the declarative model, but they can register anything else in the lower-level build model).
By reacting to function application instead of property changes, a plugin can avoid waiting for all changes to get applied.Javi
12/13/2024, 2:24 PM@Configuring does not allow passing flags but just Action<T>, the only way to enable/disable things is by commenting the lambda in the DCL.
An additional issue is, that you are forced to run a function to enable anything. Still, if the default behavior is enabled there is no workaround to disable it with the function approach.