Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
连接JavaScript的Ant构建:构建失败_Javascript_Ant_Compiler Errors_Nullpointerexception - Fatal编程技术网

连接JavaScript的Ant构建:构建失败

连接JavaScript的Ant构建:构建失败,javascript,ant,compiler-errors,nullpointerexception,Javascript,Ant,Compiler Errors,Nullpointerexception,我有下面的ant构建文件,它试图连接一组JavaScript文件,这样我就可以编写模块化代码,但只提供一个js文件。每次我在项目中保存文件时,Eclipse都会自动运行脚本,这大大简化了我的工作流程 我的问题 当Eclipse执行构建脚本时,一切正常。如果我试图直接从命令行运行ant,我会收到一个错误消息: /home/formigone/html5voodoo/build.xml:38: file attribute is null! 这是我的剧本: <?xml version="1.

我有下面的ant构建文件,它试图连接一组JavaScript文件,这样我就可以编写模块化代码,但只提供一个js文件。每次我在项目中保存文件时,Eclipse都会自动运行脚本,这大大简化了我的工作流程

我的问题

当Eclipse执行构建脚本时,一切正常。如果我试图直接从命令行运行ant,我会收到一个错误消息:

/home/formigone/html5voodoo/build.xml:38: file attribute is null!
这是我的剧本:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Build example" default="all" basedir=".">
    // ...
    <property name="SRC_JS_DIR" value="${basedir}/js/hvdoo" />
    <property name="DIST_JS_DIR" value="${basedir}/js/out" />
    <property name="DIST_JS_TMP" value="${basedir}/js/out/tmp" />

    // ...

    <property name="JS_OUT_DEF" value="${DIST_JS_TMP}/__def.js" />
    <property name="JS_OUT_CODE" value="${DIST_JS_TMP}/__code.js" />
    <property name="JS_OUT_LINKED" value="${DIST_JS_TMP}/__out.js" />

    <target name="makeDef">
        <concat destfile="${JS_OUT_DEF}">
            <fileset dir="${SRC_JS_DIR}" 
                includes="**/__def.js" />
        </concat>
    </target>

    <target name="makeCode">
        <concat destfile="${JS_OUT_CODE}">
            <fileset dir="${SRC_JS_DIR}" 
                includes="**/*.js" 
                excludes="**/__*.js" />
        </concat>
    </target>

    <target name="link">
        <concat destfile="${JS_OUT_LINKED}">
            <file name="${JS_OUT_DEF}" />
            <file name="${JS_OUT_CODE}" />
        </concat>
    </target>

    // ...

<target name="quick" depends="makeDef, makeCode, linkToOut"></target>
我故意省略了脚本中其他没有问题的部分

错误消息引用链接目标内的此行:

什么文件属性是空的!在这种情况下是什么意思? 如果是,我可以看到我想要的文件的路径是正确的。那么,为什么它可以从Eclipse工作,而不能从com CLI工作呢


谢谢

结果表明,问题在于块缺少用于包装单个文件的文件。现在,工作脚本如下所示:

<target name="link">
    <concat destfile="${JS_OUT_LINKED}">
        <filelist dir="${DIST_JS_TMP}">
            <file name="${JS_OUT_DEF}" />
            <file name="${JS_OUT_CODE}" />
        </filelist>
    </concat>
</target>

我仍然不确定Eclipse是如何运行脚本的,但我想我不太在乎,因为它是双向运行的。

结果表明,问题在于块缺少一个用于包装单个文件的文件。现在,工作脚本如下所示:

<target name="link">
    <concat destfile="${JS_OUT_LINKED}">
        <filelist dir="${DIST_JS_TMP}">
            <file name="${JS_OUT_DEF}" />
            <file name="${JS_OUT_CODE}" />
        </filelist>
    </concat>
</target>
我仍然不确定Eclipse是如何运行脚本的,但我想我不太在乎,因为它是双向运行的