Gradle: task with a custom dependency configuratio

2019-02-25 12:58发布

问题:

My project has a bunch of modules and while each module applies the java plugin and has normal compile, test, jar, and such steps, the outer project doesn't. However, the outer project does have a task that wraps up a bunch of files, reports, and such and does some processing. This task needs a particular zip file that nothing else needs.

I need that task to resolve and download a dependency, so if I run:

gradle doWeeklySummaryTask

It'll go fetch the necessary zip, just like compile fetches all the compile dependencies.

I can create a custom dependency, that's easy enough:

configurations {
   foo
}
dependencies {
   foo('blah:blah:blah')
}

The question is, how do I get my doWeeklySummaryTask to resolve that dependency?

回答1:

The dependency will be automatically resolved as soon as some piece of code iterates over configurations.foo.



标签: gradle