Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering
Gradle's copy task is very powerful and includes filtering capabilities. This means we can change the contents of the files that are copied before they reach their new destination. We use the filter() method to define a filter. The good news is we can reuse the Ant filtering classes from the org.apache.tools.ant.filters package. We define the filtering class and can pass parameters for the filter. Or we can pass a closure which is passed each line as an argument. Within the closure we must return the filtered line.
00.import org.apache.tools.ant.filters.*01. 02.task('filterCopy', type: Copy) {03.from 'src/templates'04.into buildDir05.include '**/*.txt'06.filter { line -> line.contains('Gradle') ? line : '' }07.filter(ReplaceTokens, tokens: [author: 'mrhaki', gradleVersion: gradle.gradleVersion])08.filter(ConcatFilter, prepend: file('src/include/header.txt'))09.}Now let's create a sample text file that will get filtered in src/templates/HelloGradle.txt:
This is just a simple text file. This line will not make it.We show filtering capabilities of Gradle copy.This file is written by @author@ with Gradle version @gradleVersion@.And we create the file src/include/header.txt:
Include this header file.-------------------------After we run $ gradle filterCopy we get the following contents for the file build/HelloGradle.txt:
Include this header file.-------------------------We show filtering capabilities of Gradle copy in combination with the Ant filtering types.This file is written by mrhaki with Gradle version 0.9-rc-1.Gradle Goodness: Copy Files with Filtering的更多相关文章
- Gradle Goodness: Parse Files with SimpleTemplateEngine in Copy Task
With the copy task of Gradle we can copy files that are parsed by Groovy's SimpleTemplateEngine. Thi ...
- Gradle Goodness: Renaming Files while Copying
With the Gradle copy task we can define renaming rules for the files that are copied. We use the ren ...
- Gradle Goodness: Task Output Annotations Create Directory Automatically
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...
- Xcode6 ADD Copy Files Build Phase 是灰色的
在学习的怎样写frameWork的时候,查看一个教程How to Create a Framework for iOS [一个中文翻译 创建自己的framework] 其中一个步骤就是添加一个Cop ...
- How to copy files between sites using JavaScript REST in Office365 / SharePoint 2013
http://techmikael.blogspot.in/2013/07/how-to-copy-files-between-sites-using.html I'm currently playi ...
- How do I copy files that need root access with scp
server - How do I copy files that need root access with scp? - Ask Ubuntuhttps://askubuntu.com/quest ...
- 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: Adding Tasks to a Predefined Group
In Gradle we can group related tasks using the group property of a task. We provide the name of our ...
- Could not resolve all files for configuration;Andriod在build.gradle添加compile files()报错
在build.gradle中添加个 compile files('libs/alipaySdk-20170922.jar') 就一直报这个错误 Error:Could not resolve all ...
随机推荐
- csharp:A Custom CheckedListBox with Datasource
/// <summary> /// (eraghi) /// Custom CheckedListBox with binding facilities (Value property) ...
- POJ P2777 Count Color——线段树状态压缩
Description Chosen Problem Solving and Program design as an optional course, you are required to sol ...
- CSS3之word-wrap英文单词溢出强制换行
语法 word-wrap: normal|break-word; 所有主流浏览器都支持 word-wrap 属性. <div style="border:1px #f00 solid; ...
- 使用input做简单的上传图片
css 代码: .container{ width: 200px; height: 200px; border: 1px solid #666; } HTML 代码: <input type=& ...
- Python爬虫教程-11-proxy代理IP,隐藏地址(猫眼电影)
Python爬虫教程-11-proxy代理IP,隐藏地址(猫眼电影) ProxyHandler处理(代理服务器),使用代理IP,是爬虫的常用手段,通常使用UserAgent 伪装浏览器爬取仍然可能被网 ...
- 【转】pscp实现远程文件(夹)传输
原文地址:http://blog.163.com/yang_jianli/blog/static/16199000620128251383197/ pscp与linux下的scp命令相似,功能相同,在 ...
- JavaScript 模块化入门
理解模块 模块打包构建 webpack牛刀小试
- 使用自定义视图的AlertDialog
使用自定义视图的AlertDialog主要分为以下几个步骤: 1)利用XML文件构建自己的的视图 2)将视图添加到AlertDialog中 * 在进行第二步之前,有时需要对对话框窗口进行额外的设置 下 ...
- C#中Array、ArrayList和List三者的区别
1.Array 在C#中最早出现的.在内存中是连续存储的,所以它的索引速度非常快,而且赋值与修改元素也很简单. 它的空间大小是固定的,空间不够时也不能再次申请,所以需要事前确定合适的空间大小. 2. ...
- php中的mysql_fetch_row,mysql_fetch_array,mysql_fetch_object
1.mysql_fetch_row mysql_fetch_row,这个函数是从结果集中取一行作为枚举数据,从和指定的结果标识关联的结果集中取得一行数据并作为数组返回.每个结果的列储存在一个数组的单元 ...