Ant 不创建 tar 文件

发布于 2024-11-16 14:38:09 字数 2509 浏览 0 评论 0原文

我有一个小 ant 脚本,它应该创建 3 个 tar 文件。

<?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 文件。对我自己来说有点神秘

编辑 我收到以下错误!

    <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 更改为absoulet 路径:

    <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>

但是仍然出现相同的错误,basedir 如何不存在,构建文件包含在其中。 MDP 目标中的 basedir 指向绝对路径并压缩其中的所有文件。为什么这会出错?

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>

The script runs fine:

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

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

EDIT
I have been getting the following error!

    <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>

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>

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我喜欢麦丽素 2024-11-23 14:38:09

很可能您在没有给出目标的情况下调用了它。您的打印输出没有显示任何已执行的 tar 目标。
尝试使用目标名称作为 ant 的参数来调用它。然后您还会发现在目标名称中使用空格可能不是一个好主意。

Most likely you called it without giving a target. Your printout does not show any tar targets executed.
Try calling it with target name as argument to ant. Then you will also find out that using spaces in target names may not be such a good idea.

别挽留 2024-11-23 14:38:09

我更正了几个问题:

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

    
        <属性名称=“dcc-shell.dir”
            值=“${basedir}”/>
        <属性名称=“dcc-mdp.dir”
            value="${dcc-shell.dir}/eq-mo-drop-copy-converter-mdp"/>
        <属性名称=“mdp-code.dir”
            value="${dcc-mdp.dir}/src/main/*"/>
        <属性名称=“dcc-srv.dir”
            value="${dcc-shell.dir}/eq-mo-drop-copy-converter-server"/>
        <属性名称=“srv-code.dir”
            value="${dcc-srv.dir}/src/main/*"/>
         <属性名称=“dcc-trans.dir”
             value="${dcc-shell.dir}/eq-mo-drop-copy-converter-transformer"/>
         <属性名称=“trans-code.dir”
             value="${dcc-trans.dir}/src/main/*"/>
    
        <目标名称=“create_all_tars”>
            
            
            
        
    
        <目标名称=“create_MDP_Tar”>
            
        
    
        <目标名称=“create_Trans_Tar”>
            
        
    
        <目标名称=“create_SRV_Tar”>
            
        
    

这有帮助吗?

I corrected several issues:

  • 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>
    

Does this help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文