Gradle Goodness: Skip Building Project Dependencies
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的更多相关文章
- Windows下Android Studio长时间停留在Building "Project Name" Gradle project info画面的解决方法
问题描述: 创建好一个Android项目后,Android Studio长时间停留在Building [Project Name] Gradle project info画面不动. 原因: 此时And ...
- AndroidStudio创建项目时一直处于building“project name”gradle project info的解决办法
AndroidStudio创建项目,最后一步finish后,一直长时间处于building“project name”gradle project info,界面就一直停留在如图所示: 谷歌自家的产品 ...
- Android Studio 创建/打开项目时一直处于Building“project name”Gradle project info 的解决
最近发现新版的AS,IDEA毛病不断,而且gradle的更新又给墙了,无奈啊! 进入类似如下的目录,发现如果没有对应的gradle解压文件,则在gradle官网下载完整压缩包,放入类似55xxxx串号 ...
- Android Studio一直显示Building“project name”Gradle project info问题详解
关注我,每天都有优质技术文章推送,工作,学习累了的时候放松一下自己. 本篇文章同步微信公众号 欢迎大家关注我的微信公众号:「醉翁猫咪」 Android Studio一直显示 Building&quo ...
- 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 ...
- Gradle Goodness: Task Output Annotations Create Directory Automatically
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...
- 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. ...
- Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
- 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 ...
随机推荐
- Swift 中使用Nimble 库进行单元测试
Nimble 从字面上看是 敏捷,灵活 的意思.Nimble 是一个库,一个 断言库.这个库一般用于单元测试.Xcode 6 为我们集成了 XCTest 单元测试库.在正式介绍 Nimble 之前,我 ...
- Entity Framework 学习第二天 续
今天来写一点不一样的删除,修改,查询 下面只写了几个方法 /// <summary> /// 根据删除条件进行删除 /// </summary> /// <param n ...
- datawindow直接导入导出xml
long dwcontrol.ImportFile ( XML!, filename ) dw_.Modify("DataWindow.Export.XML.UseTemplate = 't ...
- C Primer Plus学习笔记(二)
1. C的左值用是指用于标志一个特定的数据对象的名字或表达式.“数据对象”是泛指数据存储的术语. 赋值运算符的左边应该是以个可以修改的左值. 右值是指可赋给可修gia的左值的量.右值可以是常量.变量或 ...
- OpenGL学习笔记之配置OpenGL
OpenGL是计算机图形学领域的一门入门语言,OpenGL开发库的一些文件在官网上可以下载到.里面包含三个文件,如下: 1.把在OpenGL开发库中LIB(库文件)glut.lib和glut32.li ...
- xml基础学习笔记05
Xpath快速解析 如题一样,本篇主要说说Xpath快速查找XML文档 * Xpatn.Xquery,是专门用来查询xml的语言 * 查询xml非常快 Xpatn.Xquery,是专门用来 ...
- Web前端一种动态样式语言-- Less
变量 变量允许我们单独定义一系列通用的样式,然后在需要的时候去调用.所以在做全局样式调整的时候我们可能只需要修改几行代码就可以了. // LESS @color: #4D926F; #header { ...
- Upgrading to Java 8——第三章 Optional and Similar Classes
Java程序员对付空指针异常已经好多年了.在Java8中将有新的方式去处理他们.通过包装一个潜在的可能为null的类称为Optianal. 在Java8中添加了the Optional, Option ...
- 《我是IT一只小小鸟》读后感
<我是IT一只小小鸟>读后感 首先,非常感谢我的老师给我推荐了这么一本书,虽然刚开始因为这门课学分太低,所以我对老师布置了字数这么多的作业存在有很大的不满,但在看了这本书后我的不满立马得到 ...
- PowerDesigner中创建Oracle表全过程记录
本文记录如何在PowerDesigner中创建一个Oracle结构的表. 在进行本文阅读之前,需要在PowerDesigner进行 DBMS修改,DataBase创建,用户创建,表空间创建. 1. ...