2

I have the following ant build file that attempts to concatenate a bunch of JavaScript files, so that I can write modular code, but only deliver one js file. The script is automatically ran by Eclipse every time I save a file in my project, which greatly simplifies my workflow.

My problem

When the build script is executed by Eclipse, everything is fine. If I try to run ant directly from the command line, I get an error saying:

/home/formigone/html5voodoo/build.xml:38: file attribute is null!

Here's my script:

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

(I have intentionally left out other parts of the script that aren't in question here)

The error message refers to this line inside the link target:

<concat destfile="${JS_OUT_LINKED}">

What does file attribute is null! mean in this case? If I , I can see that the path to the file I want is correct. So why does it work from Eclipse, but not com CLI?

Thanks!

1 Answer 1

4

Turns out that the problem was that the <concat> block was missing a <filelist> to wrap the individual files with. Now the working script looks like this:

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

I'm still not sure how Eclipse got the script to run, but I guess I don't care much since it works both ways.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.