-
Notifications
You must be signed in to change notification settings - Fork 434
Fix usabililty of Configuration accessors in the configurations {}
block
#1129
Conversation
Signed-off-by: Paul Merlin <[email protected]>
and introduce deprecated extensions to keep source-compatibility Signed-off-by: Paul Merlin <[email protected]>
@@ -125,6 +140,10 @@ private | |||
val typeOfProject = typeOf<Project>() | |||
|
|||
|
|||
private | |||
val typeOfConfigurationContainer = typeOf<NamedDomainObjectContainer<Configuration>>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Since we're getting those elements specifically from project.configurations
, wouldn't it be better to limit the extensions to ConfigurationContainer
only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't because configurations {}
receiver is NamedDomainObjectContainerScope<Configuration>
.
|
||
|
||
@Deprecated(deprecationMessage, replaceWith = ReplaceWith("get().buildDependencies")) | ||
val <T : Configuration> NamedDomainObjectProvider<T>.buildDependencies: TaskDependency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ should have kdoc pointing to the delegate method
@@ -46,8 +47,8 @@ class ScriptHandlerScope(scriptHandler: ScriptHandler) : ScriptHandler by script | |||
/** | |||
* The script classpath configuration. | |||
*/ | |||
val ConfigurationContainer.classpath: Configuration | |||
get() = getByName(CLASSPATH_CONFIGURATION) | |||
val NamedDomainObjectContainer<Configuration>.classpath: NamedDomainObjectProvider<Configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because configurations {}
receiver is NamedDomainObjectContainerScope<Configuration>
.
configurations = emptyList() | ||
) | ||
} | ||
|
||
|
||
private | ||
enum class EntryKind { Extension, Convention } | ||
fun <T> ProjectSchema<T>.flatMapGroupedByEntryKind() = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ entriesPairedWithEntryKind()
?
...test/kotlin/org/gradle/kotlin/dsl/accessors/KotlinDslAccessorsSnapshotTaskIntegrationTest.kt
Show resolved
Hide resolved
Signed-off-by: Paul Merlin <[email protected]>
by renaming function for clarity Signed-off-by: Paul Merlin <[email protected]>
@bamboo this is ready for another round |
by generating accessors to the existing container elements, leveraging
NamedDomainObjectCollection.collectionSchema
.Those extensions expose the internal
DefaultConfiguration
type because of gradle/gradle-native#856Old accessors removed as they conflict with the new and work in less situations. Extensions were added to provide source-compatibility to scripts that were using the old accessors, marked as deprecated and with IDE guidance for replacement.
With the example from the original report in #1118 this is now possible: