Gradle:使用其他文件中的任务 [英] Gradle: using tasks from other files

查看:91
本文介绍了Gradle:使用其他文件中的任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多项目gradle设置.可以想象,某些项目需要使用相同的自定义任务.我到处寻找一种使用位于另一个build.gradle文件中的任务的方法,以避免代码重现,但是找不到任何信息.有没有办法做到这一点?如果没有,是否有一个优雅的解决方法?

I have a multi-project gradle setup. As one would imagine, some projects need to use the same custom tasks. I looked around for a way to use tasks located in another build.gradle file, to avoid code reproduction, but couldn't find any info. Is there a way to do this? If not, is there an elegant workaround?

谢谢!

推荐答案

有几种方法可以做到这一点.最简单的方法是在根项目中使用 subprojects {...} 对其进行定义.您还可以将其写在一个单独的文件中,并使用 apply from yourfile.gradle 添加.

There are several ways to do this. The easiest way would be to define it in the root project with subprojects { ... }. You also can write it in a separate file and add it with apply from: yourfile.gradle.

如果您想要更具体的答案,则必须提供有关您的项目和任务的更多信息.

If you want a more specific answer, you have to give more information about your projects and the task.

这篇关于Gradle:使用其他文件中的任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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