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 ...
随机推荐
- bsgs(Baby Steps Giant Steps)算法
BSGS算法(Baby Steps Giant Steps算法,大步小步算法,北上广深算法,拔山盖世算法) 适用问题 对于式子: $$x^y=z(mod_p)$$ 已知x,z,p,p为质数: 求解一个 ...
- Maven学习总结(三):修改从Maven中心仓库下载到本地的jar包的默认存储位置
一:修改从Maven中心仓库下载到本地的jar包的默认存储位置 从Maven中心仓库下载到本地的jar包的默认存放在”${user.home}/.m2/repository”中,${user.home ...
- drupal7 获取网站名称
$site_name=variable_get('site_name', 'Drupal');
- laravel之引入验证码类
1.将验证码类文件夹放入到指定的位置,放入位置可以自定义 2.在控制器中引入验证码文件 3.在验证码文件中可以根据自己的需要,对验证码的内容进行编辑(包括背景,画线,边框,内容) 4.在入口文件中开启 ...
- vue2 入门 教程 单页应用最佳实战[*****]
推荐 vue2 入门 教程 -------- 看过其他的,再看作者的,很赞 vue2 入门 教程 单页应用最佳实战 : 具体在 https://github.com/MeCKodo/vue-tuto ...
- ArcGIS 地类净面积计算工具
地类净面积计算工具可以自己定义图层.字段.地类代码计算任意图层的椭球面积.线状地物扣除.零星扣除和其他扣除,计算地类净面积计算:可以用于二调数据图斑地类.规划地块和基本农田等等需要计算净面积的都可以. ...
- Android GridView异步加载图片和加载大量图片时出现Out Of Memory问题
我们在使用GridView或者ListView时,通常会遇到两个棘手的问题: 1.每个Item获取的数据所用的时间太长会导致程序长时间黑屏,更甚会导致程序ANR,也就是Application No R ...
- activiti查询
一 1.根据当前任务id获得当前任务对象 Task task = processEngine.getTaskService().createTaskQuery().taskId(taskId).s ...
- Linux Swap扩容
最近在做rac,在环境检查的时候发现swap空间检查不通过,所以我们第一想到的是对swap进行扩容,那么swap扩容有哪些方法呢?这里主要介绍两种方法,一通过添加额外磁盘,扩展swap分区,二是通过本 ...
- CentOS7.x使用yum安装Mysql5.6
先检查是否存在已安装的MySQL # yum list installed | grep mysql 若存在删除: yum remove 软件名称 CentOS 7的yum源中没有正常安装mysql时 ...