To create an archive with Gradle is easy. We have several tasks like Zip, Tar, Jar, War and Ear to create a new archive. But there is no UnZip or UnTar to unpack an archive in Gradle. To unpack an archive we must use the Copy task and copy the contents of the archive to a specified destination directory. In Gradle we can use the zipTree() method to access the contents of an archive. So in our copy definition the source is the contents of the archive we access with the zipTree() method.

In the following build file we see a simple task to unzip a ZIP file with the name dist.zip in the directory src/dists. We unpack the contents to the directory build/unpacked/dist:

0.task unzip(type: Copy) {
1.def zipFile = file('src/dists/dist.zip')
2.def outputDir = file("${buildDir}/unpacked/dist")
3. 
4.from zipTree(zipFile)
5.into outputDir
6.}

The good thing is that tasks of type Copy automatically support Gradle's incremental build support. This means that if the task has been executed once and the dist.zip file and output in the directory build/unpacked/dist has not change the task is up-to-date and isn't executed.

We get the following output if we run the task twice:

$ gradle unzip
:unzip
 
BUILD SUCCESSFUL
 
Total time: 2.867 secs
unzip mrhaki$ gradle unzip
:unzip UP-TO-DATE
 
BUILD SUCCESSFUL
 
Total time: 2.606 secs
$

最新文章

  1. c#教程之通过数据绑定修改数据
  2. Java学习笔记(03)
  3. mysql 联合索引和唯一索引
  4. WinForm程序全局捕捉异常处理办法
  5. 51Node 1483----化学变换(暴力枚举)
  6. 循序渐进 Jprofiler
  7. 网站SEO优化之Robots.txt文件写法。
  8. 《Unix网络编程》卷一(简介TCP/IP、基础套接字编程)
  9. WWDC2014之iOS使用动态库 framework【转】
  10. IDL中histogram的应用
  11. Spring自定义一个拦截器类SomeInterceptor,实现HandlerInterceptor接口及其方法的实例
  12. 温故知新---重读C#InDepth(二)
  13. Linux Mint下编译Bochs
  14. 获取Request请求的路径信息
  15. 【原创】一起学C++ 之->(箭头符号) ---------C++ primer plus(第6版)
  16. S2SH+Hibernate search出现的问题
  17. 通过一个正则表达式,让SQL Server数据库的带参sql也支持位置参数语法!
  18. python 小练习之删除文件夹下的所有文件,包括子文件夹中的文件
  19. 【NLP】BLEU值满分是100分吗?
  20. Python多版本共存(生产环境)

热门文章

  1. ECharts显示百分比(小数转百分比)
  2. CSS3动画功能
  3. 删除SVN版本信息 .svn文件夹
  4. C++类继承--基类析构函数加上Virtual
  5. kafka controller重构
  6. linux 安装源码后的操作 ldconfig
  7. Java常用开发组件介绍
  8. c# 依赖注入之---反射(转)
  9. Data Flow ->> Excel Connection遇到错误:[Excel Source [16]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.....
  10. 旋转动画用控件RotateView