ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Tayek <rta...@attbi.com>
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 
http://tayek.com/~ray/localBuild/ 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.

thanks


<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="localBuildProject">
         <property name="app.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">
                 <echo>ant.home=${ant.home}</echo>
         </target>
         <target name="clean" depends="init" description="Clean all build 
products.">
                 <delete dir="classes"/>
         </target>
         <target name="compile" depends="init">
                 <mkdir dir="classes"/>
                 <javac srcdir="${src.path}" destdir="classes" debug="true" 
deprecation="true">
                         <include name="com/tayek/foo/bar/**/*.java"/>
                         <exclude name="com/tayek/foo/bar/**/*Test.java"/>
                 </javac>
         </target>
         <target name="compileTests" depends="compile">
                 <mkdir dir="classes"/>
                 <javac srcdir="${src.path}" destdir="classes" debug="true" 
deprecation="true">
                         <include name="com/tayek/foo/bar/**/*Test.java"/>
                         <!-- **/*Test.java - does not work! -->
                         <!--<exclude name="com/tayek/foo/bar/**/*.java"/> 
how do i exclude the normal java files? -->
                         <classpath>
                                 <pathelement location="d:/java/junit.jar"/>
                         </classpath>
                 </javac>
         </target>
         <target name="test" depends="compileTests" description="run the 
tests.">
                 <junit fork="yes" printsummary="on" haltonfailure="true">
                         <classpath>
                                 <pathelement path="classes"/>
                                 <pathelement 
location="${ant.home}/lib/junit.jar"/>
                         </classpath>
                         <formatter type="brief" usefile="false"/>
                         <batchtest fork="yes" todir="classes">
                                 <fileset dir="${src.path}">
                                         <include name="**/*Test.java"/>
                                         <exclude name="**/AllTests.java"/>
                                 </fileset>
                         </batchtest>
                 </junit>
         </target>
         <target name="all" depends="test" description="Build everything 
and run the tests.">
     </target>
</project>


---
ray tayek http://tayek.com/ actively seeking mentoring or telecommuting work
vice chair orange county java users group http://www.ocjug.org/
hate spam? http://samspade.org/ssw/


Mime
View raw message