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. This means we can expand properties in the source file and add Groovy code that is going to be executed. We must use the expand() method in the copy task where we can pass properties to be used in the source file.
00.version = 'DEMO'01.group = 'com.mrhaki'02. 03.task copy(type: Copy) {04.from 'src/templates'05.into "$buildDir"06.include 'projectinfo.html.template'07.rename { file -> 'projectinfo.html' }08.expand(project: project, title: 'ProjectInfo', generated: new Date())09.}We define the following source file in src/templates/projectinfo.html.template:
00.<html>01.<head>02.<title>${title}</title>03.</head>04.<body>05.<h1>${project.name}</h1>06. 07.<ul>08.<% project.properties.findAll { k,v -> v instanceof String }.each { key, value -> %>09.<li>$key = $value</li>10.<% } %>11.</ul>12. 13.<hr />14.<p>Generated on ${generated.format('dd-MM-yyyy')}</p>15.</body>16.</html>When we run the copy task we get the following output:

Gradle Goodness: Parse Files with SimpleTemplateEngine in Copy Task的更多相关文章
- 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: Copy Files with Filtering
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filterin ...
- Gradle Goodness: Task Output Annotations Create Directory Automatically
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of ...
- 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: Automatic Clean Tasks
Gradle adds the task rule clean<Taskname> to our projects when we apply the base plugin. This ...
- Gradle Goodness: Unpacking an Archive
To create an archive with Gradle is easy. We have several tasks like Zip, Tar, Jar, War and Ear to c ...
- 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: Continue Build Even with Failed Tasks
If we run a Gradle build and one of the tasks fails, the whole build stops immediately. So we have f ...
- Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/lidroid/xutils/task/TaskHandler;
Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files defi ...
随机推荐
- 如何使用canvas进行2d绘图
canvas 的 2D context 可以绘制简单的 2D 图形.它的 2D context 坐标开始于 <canvas> 元素的左上角,原点坐标是(0,0).所有的坐标值都基于这个原点 ...
- Portal for ArcGIS 10.2.2更改域名和导入自定义证书
1.产品版本 Portal for ArcGIS10.2.2(同样适用于ArcGIS10.3) 2.修改说明 )修改Portal中的域名:(2)修改Portal中的证书. 3.修改步骤 3.1.在ho ...
- React 入门实例教程[阮一峰的网络日志] (分享)
作者: 阮一峰 https://github.com/ruanyf/react-demos 转自:http://www.ruanyifeng.com/blog/2015/03/react.html 对 ...
- Manachar算法详解
求解最长回文串之Manachar算法 问题类型: 输入一个字符串,求出其中最大的回文子串.子串的含义是:在原串中连续出现的字符串片段. 回文的含义是:正着看和倒着看相同,如abba和yyxyy. 这类 ...
- VMware下Linux配置局域网和外网访问(CentOS)
要使用Linux系统很重要的一个操作就是使Linux系统能够访问互联网,只有Linux系统能够访问互联网才能够去下载很多自己所需要的资源,如果不能访问互联网那么使用Linux系统往往会卡在这一步,假设 ...
- 用squid做http/https正向代理
0.环境准备 VM1(server):nat-192.168.12.128 bridge-192.168.124.128 VM2(client):bridge-192.168.124.129 在VMw ...
- MVC Controller的激活
各Controller的继承关系 Controller最重要的是对Execute方法的调用,当目标Controller对象被激活后,对请求的后续处理和最终响应均是通过执行这个Execute方法来完成. ...
- C#中IL, CTS, CLR, CLS, JIT含义
1. IL/MSIL (Microsoft Intermediate Language) 微软中间语言 (IL是MSIL的缩写,译为中间语言) 2. CTS (Common Type System ...
- 在 Windows Server Container 中运行 Azure Storage Emulator(二):使用自定义的 SQL Server Instance
上一节,我们解决了 Azure Storage Emulator 自定义监听地址的问题,这远远不够,因为在我们 DEV/QA 环境有各自的 SQL Server Instance,我们需要将 ASE ...
- 初始python(二)
1. 列表list 1.1 切片# 定义一个list.list = [1, 2, 3, 4, 5] 从左往右读取字符(默认步长为 1 ).如:list[-2:-1] # 返回一个list数据类型,[ ...