Friday, January 8, 2010

Ant goodies 1

Suppose you have a library project checked into subversion

|_ log4j-1.2.15.jar

and you wanted to copy such library jars to your target dir when you kick an ant build

here is what I created!


            <findAndCopy fromdir="${master.library.dir}" todir="${lib.dir}" filenames="${project.classpath.compile}" />

where project.classpath.compile=log4j-1.2.15.jar,junit-4.7.jar

<macrodef name="findAndCopy">

<attribute name="fromdir" />

<attribute name="todir" />

<attribute name="filenames" />


<for list="@{filenames}" param="file">


<echo>iterate == '@{file}'</echo>

<copy todir="@{todir}" flatten="true">

<fileset dir="@{fromdir}" includes="**/*.jar">

<filename name="**/@{file}" />










oh, I do use ant-contrib, that is evil!

No comments:

Post a Comment