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 ...
随机推荐
- Postman-Tests模块测试方法记录
用Postman的时候大多数测试结果是可以用Tests模块的测试方法来代替人工检查的,测试方法本质上是JavaScript代码,我们可以通过运行测试用例(测试脚本是在发送请求之后并且从服务器接收到响应 ...
- Vue打包桌面程序
开源的地址:https://github.com/electron/electron-quick-start 一.运行 1. 安装依赖 cnpm install electron --save cnp ...
- CAS服务器集群和客户端集群环境下的单点登录和单点注销解决方案
CAS的集群环境,包括CAS的客户应用是集群环境,以及CAS服务本身是集群环境这两种情况.在集群环境下使用CAS,要解决两个问题,一是单点退出(注销)时,CAS如何将退出请求正确转发到用户sessio ...
- 第一个JavaScript代码
既然我们的CSS就必须要要放再专门的style标签内 那么javascript也需要放在子级的标签内,那就是script标签内 在页面中,我们可以在body标签中放入<script type= ...
- Google官方教程之Selling In-app Products
1.原文链接[需FQ]:http://developer.android.com/training/in-app-billing/index.html 2.平时对于英文文档都是大概读一下,现在翻译文章 ...
- 对volatile不具有原子性的理解
在阅读多线程书籍的时候,对volatile的原子性产生了疑问,问题类似于这篇文章所阐述的那样.经过一番思考给出自己的理解. 我们知道对于可见性,Java提供了volatile关键字来保证可见性.有序性 ...
- 页面请求速度慢,TTFB时间长的问题分析
线上环境发现用户请求某个页面时,出现请求速度慢页面卡顿白屏的现象,通过chrome开发工具调试查看Timing,花费在waiting(TTFB)上的时间过长,几秒十几秒不等 TTFB全称Time To ...
- JavaScript设计模式导学
如何成为一名合格的工程师? 作为一名合格的工程师,不仅需要懂代码,还要懂设计,一名合格工程师的必备条件: 前端开发有一定的设计能力,一般三年开发经验的同学,面试必须考设计能力 成为项目技术负责人,设计 ...
- UVA 10617 Again Palindrome 区间DP
题目链接: https://cn.vjudge.net/problem/UVA-10617 题目大意: 问有几种删除字符的方法可以使得该字符串为回文. 解题思路: 删除字符得到回文串的方法数 等于 字 ...
- springMVC <mvc:interceptors>拦截器的使用
首先在springMVC.xml配置如下代码 <!-- 拦截器 --> <mvc:interceptors> <bean class="com.base.Acc ...