Gradle Zip 任务做多个子树?
我们试图在 Gradle 中从多个文件系统源树构建一个稍微复杂的 Zip 文件,但无论我们给出多少个 into
规范,它都会将它们放在同一个规范中。这可以在 Gradle 中做到吗?
build/libs/foo.jar --> foo.jar
bar/* --> bar/*
我们得到的是这个:
build/libs/foo.jar --> bar/foo.jar
bar/* --> bar/*
使用这个:
task installZip(type: Zip, dependsOn: jar) {
from('build/libs/foo.jar').into('.')
from('bar').into('bar')
}
任何帮助将不胜感激。
编辑:Gradle 1.0-milestone-3
We're trying to build up a minorly complicated Zip file in Gradle from multiple filesystem source trees, but no matter how many into
specifications we give, it all puts them in the same one. Is this possible to do in Gradle?
build/libs/foo.jar --> foo.jar
bar/* --> bar/*
We're getting this instead:
build/libs/foo.jar --> bar/foo.jar
bar/* --> bar/*
Using this:
task installZip(type: Zip, dependsOn: jar) {
from('build/libs/foo.jar').into('.')
from('bar').into('bar')
}
Any help would be appreciated.
EDIT: Gradle 1.0-milestone-3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
首先... jar 应该位于 zip 的 root / 中(这似乎就是您想要的)。其次,通过指定 from
jar.outputs.files
,jar 任务上有一个隐式的dependsOn
,因此这显示了完成您想要的任务的另一种方法。除非使用这种方法,如果 jar 名称随着时间的推移而改变,那并不重要。如果您需要其他帮助,请告诉我。Try this:
First... the jar should be in the root / of the zip (which seems to be what you want). Second, by specifying the from
jar.outputs.files
, there is an implicitdependsOn
on the jar task, so this shows another way of accomplishing what you want. Except with this approach if the jar name changes over time it doesn't matter. Let me know if you need additional help.显然,对答案的评论不允许以方便的方式显示更多代码...或者它并不明显:)我有一个针对客户的项目...所以我无法共享完整的项目/构建文件。以下是我可以分享的内容(我将项目特定的 acron 更改为 XXX):
这将创建一个 zip,其中项目 jar 位于 zip 的根目录中。将脚本从目录复制到根目录,将配置文件复制到根目录,并在 zip 的根目录中创建一个名为 /lib 的目录,并将项目 /lib 中的所有 jar 复制到 zip/lib 中。
Apparently the comments to an answer will not allow for a convenient way to show more code... or it isn't obvious :) I have a project which is for a client... so I can't share the full project / build file. Here is what I can share (I changed the project specific acron to XXX):
This creates a zip with the project jar in the root of the zip. Copies the scripts from a directory to the root, copies the config file to the root and creates a directory in the root of the zip named /lib and copies all the jars from the project /lib to the zip/lib.
这个答案并没有直接回答问题,但我想这会对编写“Gradle 插件”的人有所帮助
This answer does not directly answer the question but I guess this would help someone who writes 'Gradle Plugins'