Generate MetaData with ANT

Posted by Neil Foley on Stack Overflow See other posts from Stack Overflow or by Neil Foley
Published on 2010-04-28T13:56:14Z Indexed on 2010/04/28 14:13 UTC
Read the original article Hit count: 264

Filed under:
|

I have a folder structure that contains multiple javascript files, each of these files need a standard piece of text at the top = //@include "includes.js"

Each folder needs to contain a file named includes.js that has an include entry for each file in its directory and and entry for the include file in its parent directory.

I'm trying to achive this using ant and its not going too well. So far I have the following, which does the job of inserting the header but not without actually moving or copying the file. I have heard people mentioning the <replace> task to do this but am a bit stumped.

<?xml version="1.0" encoding="UTF-8"?>

<project name="JavaContentAssist" default="start" basedir=".">

    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
      <classpath>
        <pathelement location="C:/dr_workspaces/Maven Repository/.m2/repository/ant-contrib/ant-contrib/20020829/ant-contrib-20020829.jar"/>
      </classpath>
    </taskdef>

    <target name="start">

        <foreach target="strip" param="file">

            <fileset dir="${basedir}">
                <include name="**/*.js"/>
                <exclude name="**/includes.js"/>
            </fileset>

        </foreach>

    </target> 

    <target name="strip">

        <move file="${file}" tofile="${a_location}" overwrite="true">

            <filterchain>
                <striplinecomments>
                    <comment value="//@" />
                </striplinecomments>
                <concatfilter prepend="${basedir}/header.txt">
                </concatfilter>
            </filterchain>
        </move>


    </target>

</project> 

As for the generation of the include files in the dir I'm not sure where to start at all. I'd appreciate if somebody could point me in the right direction.

© Stack Overflow or respective owner

Related posts about ant

Related posts about JavaScript