调用另一个Ant脚本Ant脚本奇怪的现象,为什么呢? [英] Strange behavior of ant script that call another ant script, why?

查看:192
本文介绍了调用另一个Ant脚本Ant脚本奇怪的现象,为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的蚂蚁(我是从Maven的来到),我发现很多问题,做以下操作。

I am very new to Ant (I came from Maven) and I am finding many problem to do the following operation.

我有一个名为主体工程的 CrystalIceGUI 使用另一个名为依赖项目的 ShellExtBridge

I have a main project named CrystalIceGUI that use another dependency project named ShellExtBridge.

的依赖项目的 ShellExtBridge 有一个自己的的build.xml 的编译项目,并将其打包成推到一个名为direcotry一个jar文件,文件的发布

The dependency project ShellExtBridge have an own build.xml file that compile the project and pack it into a jar file putted into a direcotry named Release

主要项目的 CrystalIceGUI 有它的的build.xml 包含一个名为目标Ant文件的的init 试图执行建的.xml 的文件中的 ShellExtBridge depency项目建设这个项目,后来又利用其罐子另一个目标。

The main project CrystalIceGUI have its build.xml ant file that contain a target named init that try to execute the build.xml file of the ShellExtBridge depency project to build this project and, later, use its jar in another target.

问题是,如果我执行的build.xml文件Ant脚本 ShellExtBridge 它运作良好,jar文件正确地创建到它的发布目录(所以我觉得这Ant脚本是确定的),但如果我把它从的build.xml 主体工程它给我一长串的错误。

The problem is that if I execute the build.xml ant script of ShellExtBridge it work well and the jar file is correctly created into its Release directory (so I think that this ant script is ok) but if I call it from the build.xml of the main project it give me a long series of errors.

这是在的build.xml ShellExtBridge 的依赖项目:

<?xml version="1.0"?>
<project default="default">

    <!-- ============================================ -->
    <!-- Load build properties                        -->
    <!-- ============================================ -->

    <property name="project.buildfile" value="build.num" />
    <property file="${project.buildfile}" />
    <property file="info.properties" />


    <!-- ============================================ -->
    <!-- The default target                           -->
    <!-- ============================================ -->

    <target name="default" depends="jar" />

    <!-- Elimina le cartelle contenenti le classi compilate ed i jar -->
    <target name="clean">
        <echo message="Into ShellExtBridge build.xml clean target"/>
        <delete dir="../Release" />
        <!-- Elimina directory del jar finale -->
        <delete dir="bin" />
        <!-- Elimina directory delle classi compilate -->
    </target>


    <!-- Contiene i task di COMPILAZIONE: 
         1) Crea la directory "bin/" nel progetto
         2) Compila tutte le classi dentro la cartella "src" del progetto e mette i risultanti .class
            dentro "bin"
    -->
    <target name="compile" depends="clean">
        <echo message="Into ShellExtBridge build.xml compile target"/>
        <mkdir dir="bin" />
        <javac srcdir="src" destdir="bin" />
    </target>

    <target name="jar" description="Packs classes of shellextbridge" depends="compile">
        <echo message="Into ShellExtBridge build.xml jar target"/>
        <jar destfile="../Release/shellExtBridge.jar" index="false">
            <fileset dir="bin" />
            <manifest>
                <attribute name="Created-By" value="${info.software.author}" />
                <attribute name="Main-Class" value="com.techub.crystalice.rmi.Main" />
            </manifest>
        </jar>

    </target>

</project>

这是在的init 的目标的的build.xml 主体工程文件的 CrystalIceGUI

And this is the init target of the build.xml file of the main project CrystalIceGUI:

<target name="init">


        <ant antfile="${basedir}../../../ShellExtBridge/Project/build.xml" />
</target>

如果我去执行的init 这个ant脚本的目标我获得这些错误:

If I go to execute the init target of this ant script I obtain these errors:

Buildfile: /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/build.xml
init:
clean:
     [echo] Into ShellExtBridge build.xml clean target
   [delete] Deleting directory /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/bin
compile:
     [echo] Into ShellExtBridge build.xml compile target
    [mkdir] Created dir: /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/bin
    [javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/ShellExtBridge/Project/build.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 117 source files to /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/bin
    [javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/src/com/techub/crystalice/utils/QuickLocale.java:8: package org.apache.log4j does not exist
    [javac] import org.apache.log4j.Logger;
    [javac]                        ^
    [javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/src/com/techub/crystalice/fuse/AtmosFuseWrapper.java:8: package org.apache.log4j does not exist
    [javac] import org.apache.log4j.Logger;
    [javac]                        ^
    [javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/src/com/techub/crystalice/fuse/AtmosFuseWrapper.java:11: package com.techub.crystalice.jaxb.settings does not exist
    [javac] import com.techub.crystalice.jaxb.settings.DriveType;
    [javac] 
...............................................................................
...............................................................................
ETCETCETC MANY OTHERS SIMILAR ERRORS
...............................................................................
...............................................................................
BUILD FAILED
/home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/build.xml:70: The following error occurred while executing this line:
/home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/ShellExtBridge/Project/build.xml:37: Compile failed; see the compiler error output for details.

正如你可以看到似乎在的build.xml 蚂蚁依赖脚本的 ShellExtBridge 项目被称为是因为在回应消息此蚂蚁脚本示

As you can see seems that the build.xml ant script of the dependency ShellExtBridge project is called because the echo messages of this ant script are shown.

但有一点很奇怪,因为当的build.xml脚本在 ShellExtBridge 被称为执行这些操作:

But there is something strange because when the build.xml script of the ShellExtBridge is called execute these operations:

[回应]进入ShellExtBridge的build.xml clean目标
    [删除]删除目录/ home /安德烈/文件/ XCloud / Implementazione /跨平台/ CrystalIceGUI /项目/斌
编译:
     [回应]进入ShellExtBridge的build.xml编译目标
     [命令mkdir]创建目录:/家居/安德烈/文件/ XCloud / Implementazione /跨平台/ CrystalIceGUI /项目/斌
    [javac的] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/ShellExtBridge/Project/build.xml:37:警告:includeantruntime没有设置,默认为build.sysclasspath =最后;设置为false重复建立

[echo] Into ShellExtBridge build.xml clean target [delete] Deleting directory /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/bin compile: [echo] Into ShellExtBridge build.xml compile target [mkdir] Created dir: /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/bin [javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/ShellExtBridge/Project/build.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

它删除这个目录/home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/bin而不是正确的目录是相关的bin目录中的 ShellExtBridge 项目中的人。

It delete this directory /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceGUI/Project/bin instead the correct directory that is the one related to the bin directory inside the ShellExtBridge project.

好像,当它调用 ShellExtBridge 项目的Ant文件,失去了参考和做的主要项目,并没有合适的项目的文件夹的操作。

Seems like that, when it call the ant file of the ShellExtBridge project, lost its references and do the operations on the folder of the main project and not of the right project.

你有一些想法要解决呢?

Do you have some ideas about to solve it?

推荐答案

我觉得这是很简单的修复。该 &LT;&蚂蚁GT; 任务将使用当前目录作为工作目录,除非你指定 DIR 属性(另外,如果要运行目标文件名为build.xml,你可以省略antfile属性)

I think it is quite simple to fix. The <ant> task will use the current directory as working directory unless you specify the dir attribute (and additionally if the target file to run is named build.xml you can omit the antfile property).

所以,这里的初始化目标,我建议:

So, here the init target that I suggest:

<target name="init">
    <ant dir="${basedir}../../../ShellExtBridge/Project" />
</target>

下面是关于财产目录的官方文档:

Here is the official doc about the dir property:

DIR:该目录作为新的Ant项目的basedir使用(除非useNativeBasedir设置为true)。默认为当前项目的BASEDIR,除非inheritall已经被设置为false,在这种情况下,它并没有一个默认值。这将覆盖被叫项目BASEDIR设置。
  也作为目录以解决antfile和输出属性的值(如果有)。

dir: the directory to use as a basedir for the new Ant project (unless useNativeBasedir is set to true). Defaults to the current project's basedir, unless inheritall has been set to false, in which case it doesn't have a default value. This will override the basedir setting of the called project. Also serves as the directory to resolve the antfile and output attribute's values (if any).

这篇关于调用另一个Ant脚本Ant脚本奇怪的现象,为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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