For sharing information between tasks, I rely entirely on writing output to disk. I don't think any of Gradle's @Output... annotations support non-File types. In your case, I would just write the String to disk in a file that was pointed to by @get:OutputFile abstract val output: RegularFileProperty and then use that output as a file input to the other task. You could write it to disk however you like, but I normally use moshi + json.
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.
For sharing information between tasks, I rely entirely on writing output to disk. I don't think any of Gradle's
@Output...
annotations support non-File types. In your case, I would just write theString
to disk in a file that was pointed to by@get:OutputFile abstract val output: RegularFileProperty
and then use that output as a file input to the other task. You could write it to disk however you like, but I normally use moshi + json.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 theoutputFile
itself which then makes it possible to set it without going through the functions anddisallowChanges
. Maybe not a huge problem but I bumped into this lately and wasn't sure if there was a more idiomatic way.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:Those properties aren't meant to be used by users, so if they mess with the properties, that's on them, Undefined Behavior.
I see, thanks!