目标:使用ant为任意组合(例如)5个文件夹(所有文件夹,或任意3个文件夹或任意4个文件夹.)创建单个tar存档。我不喜欢使用temp和copy命令。
如果ant任务支持追加,这应该很简单。
一次搜索让我发现:
在的tar任务中设置mode="update“应该可以完成所请求的任务。
如何知道'antlib‘是否已安装,或如何安装它。如何设置mode=“更新”-哪个文件是chgd?
在ant的tar任务中启用"tar追加“的最佳方式是什么?
GNU、-r或-u选项会失败,除非tar文件已经存在--对于在ant中如何处理w/那个有什么想法吗?
--谢谢
PS
下面的示例是对shell进行分叉的工作,然后检查tarfile是否存在,如果存在,则运行tar w/append选项:
<target name="package-blah" description="generate tar file" depends="clean,init">
<exec executable="sh" >
<arg value="-xc"/>
<arg value="
[[ -f ${tarfile} ]] && C=r || C=c;
tar ${C}vf ${tarfile} --exclude '*/.svn' ${src}/main/blah
"/>
</exec>
</target>我宁愿不使用上述方法,但它是有效的。
发布于 2011-08-30 15:01:50
与其更新现有的归档文件,不如首先使用多个源文件夹创建存档?
<tar destfile="${target}/mytar.tar">
<tarfileset dir="srcdir1">
<include name="**/*" />
<exclude name="**/*.sh" />
</tarfileset>
<tarfileset dir="srcdir2">
<include name="**/*.sh" />
</tarfileset>
<tarfileset dir="srcdir3">
<include name="**/*" />
</tarfileset>
</tar>https://stackoverflow.com/questions/7245144
复制相似问题