有没有办法将Gradle构建的公共部分分解/分解出来? [英] Is there a way to split/factor out common parts of Gradle build

查看:115
本文介绍了有没有办法将Gradle构建的公共部分分解/分解出来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有几个独立的构建(每个独立构建是一个多项目构建)。主构建脚本变得相当庞大,因为我们有一些子项目重用的常见任务,以及独立构建之间有很多重复。我们正在寻找的是:


  1. 将主构建文件
    拆分为更小的文件的一种方式

  2. 在其他独立构建中重用
    构建的某些部分的方法

什么是最佳方式在Gradle中实现它?

解决方案

Gradle 0.9允许您从另一个构建脚本中导入构建脚本。查看:使用外部构建脚本配置项目。基本上它是适用于:'other.gradle'



用户指南没有提及的一件事是'from'参数可以是一个URL,所以你可以通过HTTP将你的共享脚本提供给某个地方(例如你的Subversion版本库),然后从多个版本中导入它们。

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:

  1. A way to split main build file into smaller files
  2. A way to reuse some parts of the build in other independent builds

What is the best way to achieve that in 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'.

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屋!

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