Gradle zip插件,如何在zip中创建空文件夹? [英] Gradle zip plugin, How to create empty folder within zip?

查看:171
本文介绍了Gradle zip插件,如何在zip中创建空文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有执行包装的Follow Gradle任务。在其中生成一个zip文件。但是,我尝试在zip文件中创建一个空文件夹调用日志,作为最终分发的一部分。

I have the follow Gradle task which does packaging. In which it produces a zip file. However I am trying create a empty folder call log within the zip file as part of final distribution.

task package(type: Zip){
   into('/log') {
  }
}

上面的代码不起作用,我已经尝试了

The above code does not work and I have tried

def destDir = new File(buildDir, 'log/log')
    destDir.mkdir()

,然后将

into('/') {
 from "$buildDir/log"
}

问题也就是说,如果我运行gradle clean程序包,它将清除导致未创建日志文件夹的build文件夹。有谁能解决在我们尝试创建的zip发行版中创建一个空文件夹的问题?

Problem with that is if I run gradle clean package it clear out the build folder which cause the log folder not created. Does anyone have a solution to the problem of creating an empty folder within the zip distribution we are trying to create?

推荐答案

我这样做:

package.doFirst {
    new File(buildDir, 'log/log').mkdirs()
}

这篇关于Gradle zip插件,如何在zip中创建空文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆