Jamie Fearon
Jamie Fearon

Reputation: 2634

Using ant build.xml to concatenate js files

I'm trying to concatenate the js files in my project and put the resultant file in a build folder using ant.

The folder structure of my project is:

-Project
  -build.xml
  -build
  -src
    -init.js
    -Game.js

The build.xml file I'm trying to run is:

<project name="Build example" default="all" basedir=".">
    <!-- Setup -->
    <property name="SRC_JS_DIR" value="src" description="JavaScript source folder" />
    <property name="DIST_JS_DIR" value="build" description="Output folder for JavaScript files" />

    <property name="JS" value="${DIST_JS_DIR}/app.js" />

    <target name="js" description="Concatenate JavaScript source files">
        <echo message="Building ${JS}" />
        <concat destfile="${JS}">
            <fileset dir="${SRC_JS_DIR}" includes="init.js" />
            <fileset dir="${SRC_JS_DIR}" includes="Game.js" />
        </concat>
        <echo message="${JS} built." />
    </target>
</project>

When I run ant I get the following error:

BUILD FAILED Target "all" does not exist in the project "Build example".

Please could some one give a help on how to fix this.

Upvotes: 0

Views: 1581

Answers (1)

martinez314
martinez314

Reputation: 12332

Either change the target name to all or change default="all" to default="js".

The default attribute of the <project> tag indicates which target will be run if none were specified.

Upvotes: 1

Related Questions