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.gradle1.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:sampleSample taskBUILD SUCCESSFULTotal time: 3.168 secs$ gradle --build-file sample.gradle :sampleSample taskBUILD SUCCESSFULTotal 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.gradle1.// 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:sampleSample taskBUILD SUCCESSFULTotal 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 ...
随机推荐
- Java接口和抽象类理解(New)
一. 抽象类和接口的特点 包含抽象方法的类称为抽象类,但并不意味着抽象类中只能有抽象方法,它和普通类一样,同样可以拥有成员变量和普通的成员方法.注意,抽象类和普通类的主要有三点区别: 1)抽象方法必 ...
- JavaScript里面的居民们3-去除空格和重复
如代码,分别实现 diyTrim 及 removeRepetition 函数,并跑通代码中的测试用例. <!DOCTYPE html> <html> <head> ...
- var a =10 与 a = 10的区别
学习文章------汤姆大叔-变量对象 总结笔记 变量特点: ①变量声明可以存储在变量对象中.②变量不能直接用delete删除. var a =10 与 a = 10的区别: ①a = 10只是为全局 ...
- 原生js操作DOM基础-笔记
原文参考http://mp.weixin.qq.com/s?__biz=MzU3MDA0NTMzMA==&mid=2247485490&idx=1&sn=15197b4b53e ...
- 【转】Silverlight无法添加服务引用
引用地址:http://blog.sina.com.cn/s/blog_6e9c36f501017yzv.html 错误如下: 错误 7 自定义工具错误: 无法生成服务引用“ServiceRefere ...
- CSS的BFC和hasLayout及其应用场景
前端精选文摘:BFC 神奇背后的原理 一.BFC是什么? 先介绍 Box.Formatting Context的概念. Box: CSS布局的基本单位 Box 是 CSS 布局的对象和基本单位, 直观 ...
- 一、CSS实现横列布局的方法总结
一.使用float实现横列布局的方法 如下面所示:DIV1和DIV2都可以选择向左或者向右浮动50%来实现展示在同一行 div1 div2 实现下面图片中布局的css样式如下: 分析: 1.第一行第一 ...
- 记账本app(一)
计划开发一款小程序应用,主要来记录自己的财务账目. 通过使用SpringBoot开发后端应用,提供接口,对应前端使用微信小程序来实现. 功能模块(用户信息,账本.账目列表,新增一笔账,修改一笔账,删除 ...
- 【源码分析】cocos2dx的Action
第一次去学习Action,总会找到一篇入门的帖子(官网:http://cn.cocos2d-x.org/article/index?type=cocos2d-x&url=/doc/cocos- ...
- Docker_3 数据卷
数据卷 数据卷容器 参考连接 在Docker容器管理数据有两种方式 数据卷(Data Volumes) 数据卷容器(Data Volume Containers) 数据卷 这种方式在创建容器的时候将本 ...