This message was deleted.
# plugin-development
s
This message was deleted.
p
As a workaround you could use the project dir and the paths api to get the normalized path.
πŸ‘€ 1
m
Like pass
project.rootDir
as an
@Internal
property?
Copy code
// Path to the project directory, internal to make the cache relocatable
  @get:Internal
  var rootDir: String? = null
?
rootDir
is not what I want because the normalized path is computed relative the "roots" of the file collection, not
rootDir
, see also https://gradle-community.slack.com/archives/CA745PZHN/p1705335182134659
p
Oh, okay but how should it work? It’s possible to have multiple root dirs in a file collection.
m
That's my problem πŸ˜… , Gradle does it using internal APIs but I don't think it's doable without this
Ideally I'd like something that iterates the files and gives me (normalizedPath + File) together
Or getting
fileCollection.roots()
would work too and I could compute the normalized path myself
p
What happens if you use
FileCollection.asFileTree
?
m
A file tree only has a single root, right?
p
Yes
m
And in all cases I can't find an API to get the root of a
FileTree
it's all about iterating files
p
I think getAsPath returns the root πŸ€”
m
Was just trying that πŸ™‚ It returns a column separated list of files
Copy code
val files = project.files()
files.from(fileTree("dir1"), fileTree("dir2"))

println(files.asFileTree.asPath) // "dir1/a.txt:dir2/b.txt"