Thomas Broyer
07/16/2025, 3:40 PMconvention() or putAll()? (my use-case is initializing it with providers.gradlePropertiesPrefixedBy(…))
I've found one instance of MapProperty in the Gradle codebase that's not left empty, and it's in the build logic (so not in a "public" plugin), and it uses a few calls to `put()`: https://github.com/gradle/gradle/blob/56ac845808133d19b7e03a3fcc1264f21122e37e/bui[…]/src/main/groovy/gradlebuild/docs/GradleReleaseNotesPlugin.javaMartin
07/16/2025, 4:54 PMMapProperty is not unset by default unlike other properties...
That being said, and to answer your question, I tend to avoid convention() altogether, makes the properties code a bit easier to follow IMOMartin
07/16/2025, 4:57 PMConfigurableFileCollection, I have never really managed to wrap my head around it (cf your questions in the other message)Martin
07/16/2025, 4:58 PMMartin
07/16/2025, 5:02 PMconvention() could be useful are
• If the user code needs to read the default value
• Or because it acts as a self-documenting place to put the default for people reading the plugin codeMartin
07/16/2025, 5:05 PMSergej Koščejev
07/17/2025, 7:00 AMThomas Broyer
07/17/2025, 7:06 AMThomas Broyer
07/17/2025, 2:26 PMtask.prop.set(extension.prop) followed by task.prop.put("foo", "bar") will have task.prop contain both the extension.prop entries and the foo: bar entry. Keys can be added to the extension, the extension map can be emptied, this will be reflected in the task (entries configured on the task will stay on the task)
I'll use .set() then (in both places: extension and tasks) as that's the behavior I want.