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 ...
随机推荐
- sql 模糊搜素拼接
if($irb_order!=''){ $condition .= " AND d.irb_order like '%".$irb_order."%'"; } ...
- hashlib 文件校验,MD5动态加盐返回加密后字符
hashlib 文件校验 # for循环校验 import hashlib def check_md5(file): ret = hashlib.md5() with open(file, mode= ...
- 由上一个血案引发的关于property和attribute关系的思考
boss说,学习要刨根问底. 好的,开刨. 一.property和attribute在英语里有什么区别 看似没有区别.但其实大神说: property是 物体本身自带属性,不能改变的(一旦改了就是另外 ...
- DOM基础操作(二)
插入操作 1.appendChild(child); 这个是父级调用的方法,它会将child元素插入到父级里面,而且是放到逻辑后面的位置上. div.appendChild(comment); ...
- 匿名内部类中关于new Runnable()的使用
匿名内部类也就是没有名字的内部类,正因为没有名字,所以匿名内部类只能使用一次,它通常用来简化代码编写. 但使用匿名内部类还有个前提条件:必须继承一个父类或实现一个接口 1.继承一个父类的匿名内部类实现 ...
- 深入解析C++ STL中的常用容器
转载:http://blog.csdn.net/u013443618/article/details/49964299 这里我们不涉及容器的基本操作之类,只是要讨论一下各个容器其各自的特点.STL中的 ...
- 移动端tap事件的封装
/*封装tap*/ cc.tap = function(dom,callback){ /* * 要求 没有触发 touchmove 事件 * 并且响应速度要比click快 */ if(dom & ...
- Android沉浸式状态栏
private void initWindows() { Window window = getWindow(); int color = getResources().getColor(androi ...
- ubuntu搭建LAMP全教程及简单使用
一:安装: 参考:http://jingyan.baidu.com/article/a681b0de36ad683b18434691.html 本经验向你展示如何在ubuntu14.04 环境下搭建a ...
- 微信开发——微信公众平台实现消息接收以及消息的处理(Java版)
本文主要讲述了如何在微信公众平台实现消息接收以及消息的处理,使用java语言开发,现在把实现思路和代码整理出来分先给兄弟们,希望给他们带来帮助. 温馨提示: 这篇文章是依赖前几篇的文章的. 第一篇:微 ...