Caleb Cushing
03/17/2025, 12:23 PMProvider<File>
? since this isn't valid
project.layout.file("diagrams/class.puml")
Vampire
03/17/2025, 12:25 PMVampire
03/17/2025, 12:25 PMproject.layout.projectDirectory.file("diagrams/class.puml")
Caleb Cushing
03/17/2025, 12:26 PMVampire
03/17/2025, 12:26 PMwhy files should be different from fileI don't get what you mean by that
Caleb Cushing
03/17/2025, 12:27 PMfiles
takes Any...
Caleb Cushing
03/17/2025, 12:28 PMVampire
03/17/2025, 12:29 PMAny
for historical reasons (pre-Kotlin DSL and pre-Providers)
And iirc it documents that relative paths given to it are used relative to the project directory.Caleb Cushing
03/17/2025, 12:29 PMCaleb Cushing
03/17/2025, 12:30 PMCaleb Cushing
03/17/2025, 12:30 PMVampire
03/17/2025, 12:35 PMlayout.files
, I see.
Yeah, it is defined in terms of Project#files
and if a FileCollection
is ok as result to work with further on probably is also ok, just a bit less explicit. 🙂Vampire
03/17/2025, 12:37 PMproject.layout.file(providers.provider { File(...) })
But the ...
must not be a relative path or the build is inherently broken as it would depend on current working directory of the daemon which often is the project directory, but also often is not and it is not guaranteed what it is.Caleb Cushing
03/18/2025, 8:44 PMCaleb Cushing
03/18/2025, 8:45 PMVampire
03/19/2025, 9:44 AMasFile
for you: https://gitlab.com/Plunts/plantuml-gradle-plugin/-/blob/main/plugin/src/main/java/io/gitlab/plunts/gradle/plantuml/plugin/ClassDiagram.java#L51Caleb Cushing
03/19/2025, 12:19 PMVampire
03/19/2025, 12:27 PMProvider
overload of the method. Having the function like that would mean you need to support all the possible variants like File
, RegularFile
, Provider<RegularFile>
, Provider<File>
, and any other possibility existing now or being added in the future. If it would be a RegularFileProperty
, you could simply use everything the Gradle version you are using in the consumer project supports.
layout.projectDirectory
vs. file()
per-se is not so much different, more depending on what the thing you try to configure expects / supports. The layout
is mainly more explicit that you resolve a relative path relative to the project directory, but file()
does the same and also documents that. When it comes to layout.buildDirectory
or a Provider<RegularFile>
things are different, because the project directory cannot change, the output path of a task property or the build directory can change.Caleb Cushing
03/19/2025, 12:30 PMCaleb Cushing
03/19/2025, 12:30 PMCaleb Cushing
03/19/2025, 12:31 PMVampire
03/19/2025, 12:32 PM