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 rename() method of the copy task to define the naming rules. We can use a closure where the filename is the argument of the closure. The name we return from the closure is the new name of copied file. Or we can define a regular expression and set the replacement value for the corresponding regular expression. We can use groups in the regular expression and use them in the replacement value like $<group>.
0.task copyFiles(type: Copy) {1.from 'src/files'2.into "$buildDir/files"3.rename '(.*)-(.*).html', '$2/$1.html'4.rename ~/(.*).template.(.*)/, '$1.$2'5.rename { filename ->6.filename.replace 'java', 'groovy'7.}8.}Let's create some source files, so the renaming rules can be applied to them.
src/files/index-en.html:
<html><body><h1>Hello Gradle</h1></body></html>src/files/index-nl_NL.html:
<html><body><h1>Hallo Gradle</h1></body></html>src/files/sample.template.txt:
Sample file.src/files/Sample.java:
public class Sample {private String gradle = "Gradle";}We run $ gradle copyFiles and we get the following files in build/files:
nl_NL|+-- index.htmlen|+-- index.htmlSample.groovysample.txtGradle Goodness: Renaming Files while Copying的更多相关文章
- Gradle Goodness: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
- 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: 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. ...
- 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 ...
- 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: Add Incremental Build Support to Custom Tasks with Annotations
In a previous post we learned how we can use the inputs and outputs properties to set properties or ...
- Gradle Goodness: Automatic Clean Tasks
Gradle adds the task rule clean<Taskname> to our projects when we apply the base plugin. This ...
- 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 ...
随机推荐
- HMTL label标签
label标签和特定表单控件关联之后,如果用户在 label 元素内点击文本,就会触发关联的表单控件.就是说,当用户选择该label标签时,浏览器就会自动将焦点转到和label标签相关的表单控件上. ...
- 洛谷 P3390 【模板】矩阵快速幂
这题的确是个模板 但也要提到有关矩乘的内容: 首先什么是矩阵? 给一个线性变换 F(x) (她可能就是个函数,定义域为向量集) 她可以把一个N维向量变成M维 那么显然x的每一维都可能影响着F(x) ...
- 洛谷P4716 【模板】最小树形图(朱刘算法)
题意 题目链接 Sol 朱刘算法?感觉又是一种神仙贪心算法 大概就是每次贪心的用每个点边权最小的入边更新答案,如果不行的话就缩起来找其他的边 不详细说了,丢链接走人.. #include<bit ...
- 使用SVG绘制流程图
本篇主要记录流程图的实现过程中的难点和核心技术点,先上效果图: 节点可以任意拖拽,曲线跟随变化 正在连接的线 1.节点实现 流程图是基于SVG绘制的,节点主要利用 g 和 foreignObject的 ...
- Sql 列转行字符串
select OrderID,ProdDetailID from A 表A : OrderID,ProdDetailID 1 6 1 7 1 ...
- CAD增强属性块的还原(转)
来自:http://blog.3snews.net/space.php?uid=13924959&do=blog&id=70174 作者:毛毛虫 Demo下载:CAD增强属性块的还原 ...
- 在SQL service或Oracle中将数字转换成有千位符号
1.在SQL service中的写法: --Function主体 CREATE FUNCTION [dbo].[FnMoneyStyle](@Number )) RETURNS VARCHAR() A ...
- toLocaleTimeString()方法在IE和谷歌浏览器上 根据本地时间格式,把 Date 对象的时间部分(不含日期)转换为“时间字符串”存在区别
这两天修改一个bug,发现一个问题: toLocaleTimeString()方法在IE和谷歌浏览器上 根据本地时间格式,把 Date 对象的时间部分(不含日期)转换为“时间字符串”存在区别.方法原 ...
- 避免jar依赖冲突的一种办法
java中的依赖冲突问题一直比较头疼,特别是做公用包给其他系统用的时候,现在都不敢引入太多的依赖,基本上每次都要帮别人解决依赖冲突的问题,非常麻烦. 特别是碰到一些老系统还不是用maven管理的,人家 ...
- Visual studio 2015已经停止工作无限重启
今天遇到一个问题,某个文件在撤销的时候vs报错,然后提示到路径 “C:\Users\username\AppData\Roaming\Microsoft\VisualStudio\14.0\***.x ...