This message was deleted.
# plugin-development
s
This message was deleted.
c
Inject a
FileFactory
if you're in a task
Copy code
@get:Inject
    abstract val fileFactory: FileFactory

@TaskAction
fun task() {
    fileFactory.file(project.file("filename.txt"))
Alternatively if you can use a
RegularFileProperty
, then
Copy code
project.objects.fileProperty()
should work.
c
I don't think
FileFactory
is a thing...at least not in the javadoc.
c
Oups, it's internal. Ya probably best not to rely on it.
c
The file is actually from a resolved configuration, and I'm setting a RegularFileProperty value to it. This works 🤮
Copy code
Provider<File> ep = project.getProviders().provider(epConf::getSingleFile);
t.getTemplateFile().set(project.getLayout().file(ep));
t
Use RegularFileProperty#fileValue or fileProvider instead of project.getLayout().file() ?
c
Thanks Thomas, I missed the existence of the
file*
methods.