How to parse out List<Object> that includes files and remote urls


(Appu Goundan) #1

I have a plugin with an extension property that I want to be able to take files or urls. There seems to be a pretty universal handler for List<Object> in project.files(myListOfObjects).getFiles(), except that it doesn’t handle urls.

for example I have a build.gradle with the configuration

myExtension {
  allfiles = ['some-local-file.txt', 'https://whatever.com/test.tx']
}

It errors with this message (which is the default error it looks like in AbstractFileResolver.java so I’m not sure if it has to do with URLs or the system just considers everything a URL.

A problem occurred configuring project ':client'
> Cannot convert URL 'https://whatever.com/test.txt' to a file.

I’m wondering if there is something in the gradle api that does this, or alternatively is there some way for me to filter out the files from the urls and access those so I can handle them on my own.

project.files(myListOfObjects).filter("for urls")
project.files(myListOfObjects).filter("for files and directories")