Ant不创建tar文件 [英] Ant not creating tar files

查看:22
本文介绍了Ant不创建tar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小蚂蚁脚本,它应该创建 3 个 tar 文件.

I have a little ant script which should create 3 tar files.

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="."  >

    <property name="dcc-shell.dir" value="${basedir}"/>
    <property name="dcc-mdp.dir" value="${dcc-shell.dir}/eq-mo-drop-copy-converter-mdp"/>
    <property name="mdp-code.dir" value="${dcc-mdp.dir}/src/main/*"/>
    <property name="dcc-srv.dir" value="${dcc-shell.dir}/eq-mo-drop-copy-converter-server"/>
    <property name="srv-code.dir" value="${dcc-srv.dir}/src/main/*"/>
    <property name="dcc-trans.dir" value="${dcc-shell.dir}/eq-mo-drop-copy-converter-transformer"/>
    <property name="trans-code.dir" value="${dcc-trans.dir}/src/main/*"/>

    <target name="create MDP Tar">
        <tar destfile="${dcc-shell.dir}/mdp.tar"
            basedir="${dcc-mdp.dir}/**"
            excludes="${dcc-mdp.dir}/target/*"
        />
    </target>

    <target name="create Trans Tar">
        <tar destfile="${dcc-shell.dir}/trans.tar"
            basedir="${dcc-trans.dir}/**"
            excludes="${dcc-trans.dir}/target/*"
        />
    </target>

    <target name="create SRV Tar">
        <tar destfile="${dcc-shell.dir}/srv.tar"
            basedir="${dcc-srv.dir}/**"
            excludes="${dcc-srv.dir}/target/*"
        />
    </target>
</project>

脚本运行良好:

    Buildfile: C:\eq-Drop-Copy\eq-mo-drop-copy-converter-shell\build.xml
BUILD SUCCESSFUL
Total time: 94 milliseconds

但是在项目中没有创建 tar 文件.对自己来说有点神秘

However no tar files are created within the project. Somewhat of a mystery to myself

编辑我一直收到以下错误!

    <target name="create MDP.Tar">
    <tar destfile="C:/eq-Drop-Copy/eq-mo-drop-copy-converter-shell/mdp.tar"
        basedir="C:/eq-Drop-Copy/eq-mo-drop-copy-converter-shell/eq-mo-drop-copy-converter-mdp/*"
        excludes="C:/eq-Drop-Copy/eq-mo-drop-copy-converter-shell/eq-mo-drop-copy-converter-mdp/target/*"
    />
</target>

我已将 xml 更改为绝对路径:

I have changed the xml to the absoulet paths:

    <target name="create MDP.Tar">
    <tar destfile="C:/eq-Drop-Copy/eq-mo-drop-copy-converter-shell/mdp.tar"
        basedir="C:/eq-Drop-Copy/eq-mo-drop-copy-converter-shell/eq-mo-drop-copy-converter-mdp/*"
        excludes="C:/eq-Drop-Copy/eq-mo-drop-copy-converter-shell/eq-mo-drop-copy-converter-mdp/target/*"
    />
</target>

但是仍然存在相同的错误,其中包含构建文件的基础如何不存在.MDP 目标中的 basedir 指向一个绝对路径并将其中的所有文件 tar .为什么会报错?

However still the same error how can the basedir not exist the build file is contained within it. The basedir within the MDP target is pointing to an absoulet path and tar all the files within that. why would this be giving an error?

推荐答案

我更正了几个问题:

  • basedir 属性中不应包含*".它会自动完成整棵树.
  • 目标不能包含空格
  • 您可能没有指定目标.因此,我简单地添加了一个default 目标create_all_tars",并使用 来调用所需的目标.

  • basedir attribute shouldn't have "*" in it. It'll automatically do the whole tree.
  • Targets can't contain spaces
  • You probably didn't specify targets. Therefore, I simply added a default target "create_all_tars", and used <antcall> to call the needed targets.

<project basedir="." default="create_all_tars" >
    <property name="dcc-shell.dir"
        value="${basedir}"/>
    <property name="dcc-mdp.dir"
        value="${dcc-shell.dir}/eq-mo-drop-copy-converter-mdp"/>
    <property name="mdp-code.dir"
        value="${dcc-mdp.dir}/src/main/*"/>
    <property name="dcc-srv.dir"
        value="${dcc-shell.dir}/eq-mo-drop-copy-converter-server"/>
    <property name="srv-code.dir"
        value="${dcc-srv.dir}/src/main/*"/>
     <property name="dcc-trans.dir"
         value="${dcc-shell.dir}/eq-mo-drop-copy-converter-transformer"/>
     <property name="trans-code.dir"
         value="${dcc-trans.dir}/src/main/*"/>

    <target name="create_all_tars">
        <antcall target="create_MDP_Tar"/>
        <antcall target="create_Trans_Tar"/>
        <antcall target="create_SRV_tar"/>
    </target>

    <target name="create_MDP_Tar">
        <tar destfile="${dcc-shell.dir}/mdp.tar"
            basedir="${dcc-mdp.dir}"
            excludes="${dcc-mdp.dir}/target/**"/>
    </target>

    <target name="create_Trans_Tar">
        <tar destfile="${dcc-shell.dir}/trans.tar"
            basedir="${dcc-trans.dir}"
            excludes="${dcc-trans.dir}/target/**"/>
    </target>

    <target name="create_SRV_Tar">
        <tar destfile="${dcc-shell.dir}/srv.tar"
            basedir="${dcc-srv.dir}"
            excludes="${dcc-srv.dir}/target/**"/>
    </target>

这有帮助吗?

这篇关于Ant不创建tar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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