DEV Community

Discussion on: Gradle plugins and extensions: A primer for the bemused

Collapse
 
martinbonnin profile image
Martin Bonnin

Yep, sorry String was a bad example. The question was about exposing internal Properties.

Assuming you have an @get:OutputFile val outputFile: RegularFileProperty, how do you forward that to other parts of the build? I find it somewhat convenient to expose the outputFile itself which then makes it possible to set it without going through the functions and disallowChanges. Maybe not a huge problem but I bumped into this lately and wasn't sure if there was a more idiomatic way.

Thread Thread
 
autonomousapps profile image
Tony Robalik

I think that disallowChanges() is more for user-facing API. I do what you're suggesting all the time. E.g., in a task configuration block:

consumerTask.someInputFile.set(producerTask.flatMap { it.someOutputFile })
Enter fullscreen mode Exit fullscreen mode

Those properties aren't meant to be used by users, so if they mess with the properties, that's on them, Undefined Behavior.

Thread Thread
 
martinbonnin profile image
Martin Bonnin

I see, thanks!