ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Tayek <>
Subject local build file with ant
Date Sat, 22 Mar 2003 08:10:32 GMT
hi, i''ve been trying to come up with a build file that lives in the 
package that it builds (imho, this seems like the appropriate place for it 
to hang out - but this is contrary to most of the examples i have seen).

so i came up with the following build script (see below). this seems to 
sorta do what i want (and it works in netbeans except for getting the 
environment variables).

it seems like you would want to have one of these in most packages that 
were deliverable (say as a jar) or required some extra (non-unit) testing.

has anyone else fooled around with this idea?

i am wondering how to build on something like this when the build script is 
at a higher level and wants to build all of the stuff below it. perhaps 
there is some ant mechanism that goes around and builds everything below 
it?. i would not object to having a build file in *every* package as that 
will keep the information on how to build close to what it is building/

i am concerned that the includes and excludes for the javac will work ok as 
there may be a *lot* of stuff in the tree. i zipped up a simple example at that works on windoze and linux just in 
case anyone is interested in fooling around with it.

does anyone have any ideas about this sort of thing?

any pointers would be appreciated.


<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="localBuildProject">
         <property name="" value="localBuildApp"/>
         <property name="src.path" value="../../../.."/> <!-- ugly, but it 
only occurs once -->
         <property environment="env"/>
         <property name="ant.home" value="${env.ANT_HOME}"/>
         <!-- this does not work in netbeans -->
         <target name="init">
         <target name="clean" depends="init" description="Clean all build 
                 <delete dir="classes"/>
         <target name="compile" depends="init">
                 <mkdir dir="classes"/>
                 <javac srcdir="${src.path}" destdir="classes" debug="true" 
                         <include name="com/tayek/foo/bar/**/*.java"/>
                         <exclude name="com/tayek/foo/bar/**/*"/>
         <target name="compileTests" depends="compile">
                 <mkdir dir="classes"/>
                 <javac srcdir="${src.path}" destdir="classes" debug="true" 
                         <include name="com/tayek/foo/bar/**/*"/>
                         <!-- **/* - does not work! -->
                         <!--<exclude name="com/tayek/foo/bar/**/*.java"/> 
how do i exclude the normal java files? -->
                                 <pathelement location="d:/java/junit.jar"/>
         <target name="test" depends="compileTests" description="run the 
                 <junit fork="yes" printsummary="on" haltonfailure="true">
                                 <pathelement path="classes"/>
                         <formatter type="brief" usefile="false"/>
                         <batchtest fork="yes" todir="classes">
                                 <fileset dir="${src.path}">
                                         <include name="**/*"/>
                                         <exclude name="**/"/>
         <target name="all" depends="test" description="Build everything 
and run the tests.">

ray tayek actively seeking mentoring or telecommuting work
vice chair orange county java users group
hate spam?

View raw message