Hi everyone. The gradle plugin I'm building (in ko...
# community-support
p
Hi everyone. The gradle plugin I'm building (in kotlin) has a task that takes a directory as an input, however the contents of that directory are not supposed to be considered inputs to the task. If I use the
DirectoryProperty
type I also need to declare it
@InputDirectory
and now the contents are considered part of the input. When I declare it as a
Property<File>
with
@Input
works as I want it to, but I'd prefer a type that requires it to be a directory. Is File my only option or are there other types I'm not aware of?
s
You can annotate it as
@Internal
and declare another property (could be protected) that would compute the actual input (if it’s somehow relevant for the task) and would be annotated as
@Input
. E.g. something like this:
Copy code
@get:Internal("covered by myPath")
val myProperty: DirectoryProperty = ...

@get:Input
protected val myPath: Provider<String> = myProperty.map { it.asFile.path }
☝️ 1
v
Maybe as relative path though, especially if the task should become cacheable