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 ...
随机推荐
- java停止一个线程
Thread类中有start(), stop()方法,不过stop方法已经被废弃掉. 平时其实也有用过,共享一个变量,相当于标志,不断检查标志,判断是否退出线程 如果有阻塞,需要使用Thread的in ...
- AJAX 概念 优势 发展前景 工作原理 底层技术 状态 缺点 框架
1. 概念 Ajax asynchronous JavaScript and XML , 异步js和xml. 这种解释已经过时了, 现在ajax就是, 允许浏览器和服务器通信, 而无需刷新当前页面的技 ...
- sublime text3 jQuery Emmet 插件 安装方法,快捷键
preference->package control->install package> emmet / jQuery 先说jQuery jQuery 集成了很多JS的补全功能.例 ...
- error C3861: “getpid”: 找不到标识符
原文:http://blog.csdn.net/woniu199166/article/details/52471242 这种错误一般就是没有对应的函数或者对应的头文件 旧版的vs添加#include ...
- 在GitHub上删除项目后,在Android Studio上传项目依然提示project is already on github
描述: 在GitHub上面上传项目,但是感觉有些问题,就想删除了重新上传. 但是在Android Studio重新上传项目时,遇到了问题,一直提示“project is already on gith ...
- D3 JS study notes
如何使用d3来解析自定义格式的数据源? var psv = d3.dsvFormat("|"); // This parser can parse pipe-delimited t ...
- aspnetcore 认证相关类简要说明一
首先我想要简要说明是AuthenticationScheme类,每次看到Scheme这个单词我就感觉它是一个很高大上的单词,其实简单翻译过来就是认证方案的意思.既然一种方案,那我们就要知道这个方案的名 ...
- Mysql学习---使用Python执行存储过程
使用Python执行存储过程 使用Python执行存储过程[2部分]: 1.执行存储过程,获取存储过程的结果集 2.将返回值设置给了 @_存储过程名_序号 = #!/usr/bin/env pyt ...
- 设置OWA访问HTTP到HTTPS的重定向
需求:公司要求使用Http://mail.ever.com的方式来统一访问邮箱,所以需要进行相关的设置,将访问需求重定向到https://extest.ever.com/owa 首先在DNS里的eve ...
- 沉淀再出发:kafka初探
沉淀再出发:kafka初探 一.前言 从我们接触大数据开始,可能绕在耳边的词汇里面出现的次数越来越多的就包括kfaka了.kafka的设计初衷是希望作为一个统一的信息收集平台,能够实时的收集反馈信息, ...