You could probably extend AbstractFileCollection and implement getFiles() to return Collection.emptySet() but I’m not sure I’d recommend this as AbstractFileCollection is in an “internal” package and can change (or be removed) in future gradle versions without warning in a way that is not backwards compatible
Is there a reason why you can’t inject the ObjectFactory or the Project?
I’m doing it in a helper function that does a few things, including using a higher order function parameter that is used to clear the classpath, then later set it.
Yes. I just think that such a singleton should probably be provided by Gradle, so people don’t have to make their own. I wasn’t sure if such a singleton was.
I’ve created empty FileCollection via project.files() or empty FileTree via project.files().asFileTree. All of my plugins, tasks and extension objects etc hold a reference to the Project so I’ve never had issues with this
That’s what I’ve done, too. It’s just that, in my current context, the helper method doesn’t otherwise need access to a Project or anything else that can get me a Project, so I wanted to avoid passing or injecting a Project (or FileCollection, etc.) if possible.