How to use the dependency as a file object?

Is there an elegant way to use a particular dependency as a file object (casting dependency on a file object). It is often necessary to pass the file as an argument to the / ant task, etc. I helped me with.   configurations.myDependency.files.iterator().next() But it doesn’t look very intuitive.

+5
source share
1 answer

I think you mean a configuration that is independent. Assuming you have something like:

configurations{
  myConf
}

dependencies{
  myConf 'mydep:mydep:1.0'
}

Then, if you are sure that in all your dependencies there myConfwill be only one file for, then you can do configurations.myConf.singleFile(return type File).

, , , configurations.myConf.files ( - Set<File>).

, - :

configurations.myConf.files { dep -> dep.name == 'mydep' }

dep Dependency, - Set<File>.

. javadoc.

+7

All Articles