Re: Stupid Ant Question

From: Lachlan Deck (lachlan.dec..mail.com)
Date: Mon Feb 11 2008 - 15:45:01 EST

  • Next message: David Avendasora: "WOLips binding keypath validator"

    On 12/02/2008, at 7:02 AM, Pierce T. Wetter III wrote:

    > Ok, so in order to do a deployment, I have to build 2 .jar
    > libraries, 7 frameworks, and 7 WebObjects applications.
    >
    > The way this is done currently is we have these scary totally
    > undocumented ant files, one called build.xml and one called
    > generic.xml. Somehow, they managed to build everything, in general
    > because the first build.xml knows what has to be built in what
    > order, and then it uses generic.xml to force projects to build.
    >
    > That is, until I decided to add a framework to hold all our 3rd
    > party jars, instead of just dumping crap into /Library/Java/
    > Extensions.
    >
    > So now I need to either understand how all that works, or recreate it.
    >
    > It seems to me though that this can't be an uncommon problem. :-)
    >
    > So I'm leaning towards recreating it. I mean, AFAIK, I should only
    > have to do the following:
    >
    > 1. Export a build.xml for each project from Eclipse.
    > 2. Write a master build.xml that calls the others.
    >
    > Is that correct or is there a cooler, easier way? Like can you
    > select a group of projects in eclipse and have it write out an
    > build.xml file for you?

    Here's my approach, if it's of any use...

    Example bulk operations
    $ cd parentDirOfFrameworks
    $ ant # defaults to build all frameworks in the fileset
    $ ant build # ditto
    $ ant clean # cleans all frameworks in fileset
    $ ant reinstall # reinstalls deployed framework (by firsly removing
    current deployed framework)
    $ etc

    i.e., all it's doing is calling the appropriate target on the build
    file for each project.
    -----------------------------
    <?xml version="1.0"?>
    <project name="ishframeworks" basedir="." default="build">
            
            <!-- = = = = = = = = = = = = = = = = =
                    macrodef: anttarget
             = = = = = = = = = = = = = = = = = -->
            <macrodef name="anttarget">
                    <attribute name="name" default="build" />
                    <sequential>
                            <subant target=..name}" antfile="build.xml">
                                    <filelist dir="${basedir}">
                                            <file name="FrameworkProjectDir_1" />
                                            <...>
                                    </filelist>
                            </subant>
                    </sequential>
            </macrodef>

            <target name="clean">
                    <anttarget name="clean"/>
            </target>
            
            <target name="compile">
                    <anttarget name="compile"/>
            </target>
            
            <target name="build">
                    <anttarget name="build"/>
            </target>
            
            <target name="install">
                    <anttarget name="install"/>
            </target>
            
            <target name="reinstall">
                    <anttarget name="reinstall"/>
            </target>
    </project>
    -----------------------------

    Each of my framework project's build files looks exactly like this
    (changing the name of course):
    <project name="SomeFramework" basedir=".">
            <dirname file="../../ant/build.woframework.xml" property="helper.dir"/>
            <import file="../../ant/build.woframework.xml"/>
    </project>

    build.woframework.xml, and build.woapp.xml too, are also lightweight
    - simple setting some properties used elsewhere. e.g.,
    <project>
            <property name="woproject.type" value="woframework" />
            <property name="woproject.ext" value="framework" />
            <import file="${helper.dir}${file.separator}build.common.xml" />
    </project>

    build.common.xml contains all the common targets I want to expose to
    the user...
    <project default="build">
            
            <property name="ant.helper" value="${helper.dir}${file.separator}
    build.help.xml" />
                    
            <!-- =================================
                     target: build
                     ================================= -->
            <target name="build">
                    <ant antfile="${ant.helper}" target="build">
                            <property name="target" value="build.${woproject.type}" />
                    </ant>
            </target>

            <!-- =================================
                     target: compile
                     ================================= -->
            <target name="compile">
                    <ant antfile="${ant.helper}" target="compile" />
            </target>

            <... etc ...>

    </project>

    build.help.xml, finally, is a slightly customised version of what
    WOLips produced for a new project some six months ago or so.

    with regards,

    --
    

    Lachlan Deck



    This archive was generated by hypermail 2.0.0 : Mon Feb 11 2008 - 15:46:21 EST