Gradle:具有自定义依赖配置的任务? [英] Gradle: task with a custom dependency configuration?

查看:405
本文介绍了Gradle:具有自定义依赖配置的任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目有一堆模块,每个模块应用java插件,并且具有正常的编译,测试,jar和这些步骤,但外部项目没有。然而,外部项目确实有一个任务,包装了一堆文件,报告等,并做了一些处理。这个任务需要一个特殊的zip文件,它不需要任何东西。



我需要这个任务来解析和下载一个依赖项,所以如果我运行:

  gradle doWeeklySummaryTask 

就像编译获取所有的编译依赖关系一样。我可以创建一个自定义的依赖关系,这很简单:

 配置{
foo
}
依赖项{
foo('blah:blah:blah')

$ / code>

现在的问题是,如何让我的doWeeklySummaryTask解决这个依赖关系?

解决方案

一旦某段代码重复遍历 configurations.foo


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?

解决方案

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

这篇关于Gradle:具有自定义依赖配置的任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆