Gradle Goodness: Changing Name of Default Build File
Gradle uses the name build.gradle
as the default name for a build file. If we write our build code in a file build.gradle
then we don't have to specify the build filename when we run tasks. We can create build files with a different name other than build.gradle
. For example we can define our build logic in a file sample.gradle
. To run the tasks from this build file we can use the command line option -b
or --build-file
followed by the file name. But we can also change the project settings and set a new default build file name for our project. With the changed project settings we do not have to use the command line options -b
or --build-file
.
Suppose we have the following build file with the name sample.gradle
:
0.
// File: sample.gradle
1.
task sample(description:
'Sample task'
) << {
2.
println
'Sample task'
3.
}
4.
5.
defaultTasks
'sample'
To run the sample
task from the command line we can use the command line options -b
or --build-file
:
$ gradle -b sample.gradle
:sample
Sample task
BUILD SUCCESSFUL
Total time: 3.168 secs
$ gradle --build-file sample.gradle
:sample
Sample task
BUILD SUCCESSFUL
Total time: 2.148 secs
$
To change the default build file name for our project we create a file settings.gradle
in our project. Inside the settings.gradle
file we can change the property buildFileName
for rootProject
:
0.
// File: settings.gradle
1.
// Change default build file name for this project.
2.
rootProject.buildFileName =
'sample.gradle'
Now we execute the tasks from sample.gradle
without the options -b
or --build-file
:
$ gradle
:sample
Sample task
BUILD SUCCESSFUL
Total time: 3.312 secs
$
Code written with Gradle 2.1.
Gradle Goodness: Changing Name of Default Build File的更多相关文章
- Gradle Goodness: Rename Ant Task Names When Importing Ant Build File
Migrating from Ant to Gradle is very easy with the importBuild method from AntBuilder. We only have ...
- Gradle Goodness: Continue Build Even with Failed Tasks
If we run a Gradle build and one of the tasks fails, the whole build stops immediately. So we have f ...
- Eclipse项目导入Android Stuio 配置出现 Timeout waiting to lock buildscript class cache for build file 'H:\studioproject\Generic_SN\build.gradle'
Eclipse项目导入Android Stuio 配置出现 Error:Timeout waiting to lock buildscript class cache for build file ...
- Gradle Goodness: Run a Build Script With a Different Name
Normally Gradle looks for a build script file with the name build.gradle in the current directory to ...
- Gradle Goodness: Add Incremental Build Support to Tasks
Gradle has a very powerful incremental build feature. This means Gradle will not execute a task unle ...
- Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
- 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: Using and Working with Gradle Version
To get the current Gradle version we can use the gradleVersion property of the Gradle object. This r ...
随机推荐
- 二、IOC容器基本原理
IOC容器就是具有依赖注入功能的容器,IOC容器负责实例化.定位.配置应用程序中的对象及建立这些对象间的依赖.应用程序无需在代码中new相关的对象,应用程序由IOC容器进行组装. spring IOC ...
- flask 继承模版的基本使用1
- promose
function runAsync1(){ var p = new Promise(function(resolve, reject){ //做一些异步操作 setTimeout(function() ...
- JS 面向对象之继承---多种组合继承
1. 组合继承:又叫伪经典继承,是指将原型链和借用构造函数技术组合在一块的一种继承方式. 下面来看一个例子: function SuperType(name) { this.name = name; ...
- strace for Android
使用strace for Android跟踪系统调用过程方便后续的so文件分析 http://benno.id.au/blog/2007/11/18/android-runtime-stracehtt ...
- Oracle基础之分析表
analyze table tablename compute statistics; analyze index indexname compute statistics; (analyze 不会重 ...
- SVNKit学习——Setting Up A Subversion Repository 创建仓库(三)
所谓Setting Up A Subversion Repository,就是在Subversion所在的服务器上创建一个仓库,说白了就是在磁盘上建一个特殊的目录,这里我以windows举例. 1.使 ...
- 爬虫入门之Scrapy框架实战(新浪百科豆瓣)(十二)
一 新浪新闻爬取 1 爬取新浪新闻(全站爬取) 项目搭建与开启 scrapy startproject sina cd sina scrapy genspider mysina http://roll ...
- .net 面向对象程序设计深入](2)UML
1.用例图简介 定义:用例图主要用来描述“用户.需求.系统功能单元”之间的关系.它展示了一个外部用户能够观察到的系统功能模型图. 类型:动态图 应用:需求分析阶段 2.用例图元素 2.1 参与者(Ac ...
- July 26th 2017 Week 30th Wednesday
A man can't ride your back unless it is bent. 你的腰不弯,别人就不能骑在你的背上. Have you ever ride a horse, or ride ...