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 ...
随机推荐
- JDBC入门(2)--- ResultSet之滚动结果集
一.ResultSet之滚动结果集 ResultSet表示结果集,它是一个二维的表格.ResultSet内部维护一个行光标(游标),ResultSet提供了一系列的方法来移动游标: void befo ...
- OpenStack IceHouse 部署 - 2 - 网络与软件环境初始化
OpenStack应用:节点软硬件环境配置 节点硬件与IP分配 实验室网关 10.14.39.1 各个节点 节点名称 硬件(Linux硬盘分区,RAM,CPU) ip地址(接口) 作用与运行的服 ...
- python学习之老男孩python全栈第九期_day018知识点总结——正则表达式、re模块
一. 正则表达式 正则表达式本身和python没有什么关系,就是匹配字符串内容的一种规则. 官方定义:正则表达式是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合,组成 ...
- C# 读写txt文件方法
添加引用: using System.IO; 1.File类写入文本文件: private void btnTextWrite_Click(object sender, EventArgs e) { ...
- 004bean作用域
1.Singleton(单例) 2.Prototype(原型)---->每次注入.通过Spring应用上下文获取,都会重新创建 @Scope(ConfigurableBeanFactory ...
- Mac 下VIM配置
Mac下VIM配置 首先,我们去这里下载MacVim,也可用这个网址:(http://code.google.com/p/macvim/),进入后的界面如下: ____________________ ...
- error:将字符串转换为 uniqueidentifier 时失败
sql server查询中出现 将字符串转换为 uniqueidentifier 时失败异常 原因为id设置为uniqueidentifier 字段,在where查询时需要做转换cast(id as ...
- BIEE总结
一,数据仓库,BI涉及到的相关概念 1.DW: 即数据仓库(Data Warehouse),是一个面向主题的(Subject Oriented).集成的(Integrated).相对稳定的(N ...
- c#(winform)环境下使用动态链接库dll的详解
1,什么是dll文件? DLL(Dynamic Link Library)文件为动态链接库文件,又称“应用程序拓展”,是软件文件类型.在Windows中,许多应用程序并不是一个完整的可执行文件,它们被 ...
- eclipse直接使用tomcat安装程序的webapp目录调试
感谢此文:http://blog.csdn.net/soszou/article/details/23673133 本文很多技术及操作来源于此文 需求:因为微信方面的开发调试.为了测试方便,直接构建了 ...