If we use Gradle in a multi-module project we can define project dependencies between modules. Gradle uses the information from the project dependencies to determine which tasks need to be run. For example if module B depends on module A and we want to build module B, Gradle will also build module A for us, because module B depends on it. But if we know for sure that module A is up to date and has not changed, we can also instruct Gradle to skip building module A, when we build module B.

Let's start with the following module structure, where each module depends on the module above it. So module services depends on common and module web depends on services:

.
├── common
├── services
└── web

When we want to build the service module we go to the services directory and execute the build task and we get the following output:

$ gradle build
:common:compileJava
:common:processResources
:common:classes
:common:jar
:services:compileJava
:services:processResources
:services:classes
:services:jar
:services:assemble
:services:compileTestJava
:services:processTestResources
:services:testClasses
:services:test
:services:check
:services:build
 
BUILD SUCCESSFUL
 
Total time: 8.013 secs

We see in the output that first the common module is build, because the services module depends on it. But if we work on this project and we know for sure the common module is up to date and has not changed since the last build (for example we didn't checkout new sources from version control or changed sources in the common module ourselves), then we can skip building the common module. We use the command line option -a or --no-rebuild to tell Gradle to skip project dependencies.

When we run the build task from the services directory using the command line option -a we get the following output:

$ gradle -a build
:services:compileJava
:services:processResources
:services:classes
:services:jar
:services:assemble
:services:compileTestJava
:services:processTestResources
:services:testClasses
:services:test
:services:check
:services:build
 
BUILD SUCCESSFUL
 
Total time: 5.626 secs

This time only the services module is build, which also speeds up the build proces. Still this should only be used if we know ourselves the project dependencies are up to date.

Written with Gradle 2.2.1.

Gradle Goodness: Skip Building Project Dependencies的更多相关文章

  1. Windows下Android Studio长时间停留在Building "Project Name" Gradle project info画面的解决方法

    问题描述: 创建好一个Android项目后,Android Studio长时间停留在Building [Project Name] Gradle project info画面不动. 原因: 此时And ...

  2. AndroidStudio创建项目时一直处于building“project name”gradle project info的解决办法

    AndroidStudio创建项目,最后一步finish后,一直长时间处于building“project name”gradle project info,界面就一直停留在如图所示: 谷歌自家的产品 ...

  3. Android Studio 创建/打开项目时一直处于Building“project name”Gradle project info 的解决

    最近发现新版的AS,IDEA毛病不断,而且gradle的更新又给墙了,无奈啊! 进入类似如下的目录,发现如果没有对应的gradle解压文件,则在gradle官网下载完整压缩包,放入类似55xxxx串号 ...

  4. Android Studio一直显示Building“project name”Gradle project info问题详解

    关注我,每天都有优质技术文章推送,工作,学习累了的时候放松一下自己. 本篇文章同步微信公众号  欢迎大家关注我的微信公众号:「醉翁猫咪」 Android Studio一直显示 Building&quo ...

  5. Gradle Goodness: Display Available Tasks

    To see which tasks are available for our build we can run Gradle with the command-line option -t or ...

  6. Gradle Goodness: Task Output Annotations Create Directory Automatically

    Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...

  7. Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects

    Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects Gradle is very flexible. ...

  8. Gradle Goodness: Copy Files with Filtering

    Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...

  9. Gradle Goodness: Check Task Dependencies With a Dry Run

    We can run a Gradle build without any of the task actions being executed. This is a so-called dry ru ...

随机推荐

  1. Objective-C 一些概念

    Automatic Reference Counting (ARC)

  2. windows CE 6.0编译报BLDDEMO: There were errors building MY283错误解决办法

    今天开始正式进入windows ce程序开发. 第一次编译windows ce6.0的系统,25分钟编译后报:BLDDEMO: There were errors building MY283 错误. ...

  3. sharepoint 浏览页面导航不正确

    问题是这样的: sharepoint网站上建立一个二级站点,然后在网站中创建几个页面.当浏览二级网站的页面的时候,顶部导航的位置总是在首页的地方,而不是我的二级站点的导航位置. 解决方法: 转到网站集 ...

  4. 30.DDR2问题2_local_init_done为什么没拉高?

    按照初始化时序,在200us时,mem_clk时钟稳定,开始初始化设置,设置完后,会产生一个初始化完成标志,local_init_done会拉高,没有拉高,可能有以下几个原因: 1.确认DDR2 IP ...

  5. mysql 创建一个用户,指定一个数据库

    mysql 创建一个用户 hail,密码 hail,指定一个数据库 haildb 给 hail mysql -u root -p password use mysql; insert into use ...

  6. 关于sqlserver身份登录失败的解决方法

    前几天写程序需要用到数据库,下载了一个用用,出现了不少的小问题(都怪我的32bit不争气的笔记本),有问题不要怕,至少证明我们在思考解决方案.废话不说了,直接上正题. Sqlserver有两种登陆方式 ...

  7. linux matplotlib入门

    python linux matplotlib 安装:   sudo apt-get install python-numpy 必须 先安装numpy matplotlib 安装:   sudo ap ...

  8. 随机的30道四则运算题(简单的c)

    #include <stdio.h>#include <stdlib.h>#include <time.h> int main(void){ int i = 0; ...

  9. 17、android设备如何防止屏幕休眠(转载)

    当你需要你的设备需要长期运行时,由于移动设备为了延长电池续航时间,在运行15s-30mins后(用户可自由设置),如果用户在此时间段内没有操作,系统将进入休眠状态并 将屏幕锁上,所以在需要长期运行时, ...

  10. word检视意见导出(VBA)

    Private Sub CommandButton1_Click() 'Dim Cmt As Comment Dim excelApp As Object Dim xlsWbk, objWdApp A ...