有没有办法拆分/分解出 Gradle 构建的公共部分 [英] Is there a way to split/factor out common parts of Gradle build
问题描述
我们有几个独立的构建(每个独立构建都是一个多项目构建).主构建脚本变得非常大,因为我们有一组由子项目重用的常见任务,并且独立构建之间有很多重复.我们正在寻找的是:
We have several independent builds (each independent build is a multi-project build). The main build scripts become quite big as we have a set of common tasks reused by subprojects as well as there is a lot of repeation between indepedent builds. What we are looking for is:
- 一种拆分主构建文件的方法成更小的文件
- 重用某些部分的方法在其他独立版本中构建
在 Gradle 中实现这一目标的最佳方法是什么?
What is the best way to achieve that in Gradle?
推荐答案
Gradle 0.9 允许您从另一个构建脚本导入构建脚本.看看:使用外部构建脚本配置项目一>.基本上它是 apply from: 'other.gradle'
.
Gradle 0.9 allows you to import a build script from another build script. Have a look at: Configuring the project using an external build script. Basically it's apply from: 'other.gradle'
.
用户指南没有提到的一件事是,'from' 参数可以是一个 URL,因此您可以通过 HTTP 使您的共享脚本在某处(例如您的 subversion 存储库)可用,并从多个构建中导入它们.
One thing the user guide doesn't mention is that the 'from' parameter can be a URL, so you can make your shared scripts available via HTTP somewhere (eg your subversion repository), and import them from multiple builds.
这篇关于有没有办法拆分/分解出 Gradle 构建的公共部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!