I am using XMLC and Tomcat but maybe you can get what you need from this
build file. The XMLC target is a little large because I have my stuff
broken up into many packages.

Joe McGlynn wrote:
> 
> Does anyone have Ant examples or tasks to help build Enhydra-based
> applications?  An XMLC task would be pretty useful...
> 
> Thanks,
> Joe McGlynn

-- 
Denny Chambers
Linux Java Engineer
Connex, Inc
Voice: 770-455-7653
Fax: 770-455-7325
<project default="compile" basedir=".">

        <!-- Set up application info -->
    <property file="build.properties"/>
        <property name="app.Name" value="Lolo"/>
        <property name="app.name" value="lolo"/>
        <property name="app.version" value="0.1"/>
        <property name="app.year" value="2001"/>
        <property name="company.name" value="Connex"/>

        <!-- content files -->
        <property name="content.dir" value=".." />

        <!-- source files -->
        <property name="src.dir" value="./" />
        <property name="src.package.dir" value="com/connex/lolo" />

        <!-- xmlc info -->
        <property name="xmlc_resource.dir" value="./com/connex/lolo/pres/resources" />
        <property name="xmlc_package.dir" value="com/connex/lolo/pres/screens" />
        <property name="xmlc_options.file" 
value="com/connex/lolo/pres/resources/options.xmlc" />
        <property name="xmlc.classpath" value="${xmlc.jar}" />

        <!-- build info -->
        <property name="build.dir" value="../WEB-INF" />
        <property name="qualified.build.dir" value="${user.dir}/output" />
        <property name="build.xmlc_source.dir" value="${build.dir}/xmlc_source/"/>
        <property name="build.classes.dir" value="${build.dir}/classes" />
        <property name="build.lib.dir" value="${build.dir}/lib" />
        <property name="build.javadocs.dir" value="${content.dir}/javadocs" />
        
        
        <!-- test build info -->
        <property name="test.build.dir" value="../built_tests" />
        <property name="test.build.classes.dir" value="${test.build.dir}/classes" />
        <property name="test.build.lib.dir" value="${build.dir}/lib" />
        <property name="test.src.dir" value="../src_tests/" />
        <property name="test.src.package.dir" value="com/connex/lolo" />

        <!-- Property Files -->
        <property name="master.property.dir" 
value="${build.classes.dir}/com/connex/lolo/common/util" />
        <property name="master.property" 
value="./com/connex/lolo/common/util/resource.properties" />

        <!-- jar info -->
        <property name="jar.dir" value="${build.dir}/jars" />
        <property name="jar.name" value="lolo.jar" />

        <!-- javadocs -->
        <property name="javadoc.packages" value="com.connex.lolo.*"/>

        <!-- classpath for building lolo -->
    <path id="build.classpath">
                <pathelement location="${build.classes.dir}" /> 
        <pathelement path="${barracuda.jar}"/>
                <pathelement path="${xmlc.jar}" />
                <pathelement path="${ant_xmlc.jar}" />
                <pathelement path="${servlet.jar}" />
    </path>

        <!-- classpath for building lolo junit test cases -->
    <path id="test.build.classpath">
                <pathelement location="${test.build.classes.dir}" />    
                <pathelement path="${junit.jar}" />
                <path refid="build.classpath" />
    </path>

        <!-- XMLC Taskdef -->
    <taskdef name="xmlc" classname="org.enhydra.ant.taskdefs.Xmlc">
                <classpath refid="build.classpath" />
        </taskdef>
        
        <!-- Junit Taskdef -->
    <taskdef name="junit" 
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />

        <!-- ============================================================= -->
        <!--    The clean target cleans out the xmlc source directory,     -->
        <!--    the class build directory and the javadocs directory.      -->
        <!-- ============================================================= -->
    <target name="clean">
        <delete dir="${build.xmlc_source.dir}" /> 
        <delete dir="${build.classes.dir}/${src.package.dir}" /> 
        <delete dir="${build.javadocs.dir}" /> 
    </target>

        <!-- ============================================================= -->
        <!--    The clean.test target cleans out the built_tests                   -->
        <!--    directory.                                                             
                                    -->
        <!-- ============================================================= -->
    <target name="clean.test">
        <delete dir="${test.build.classes.dir}/${src.package.dir}" /> 
    </target>

        <!-- ============================================================= -->
        <!--    The prepare target creates the directories needed for      -->
        <!--    building the lolo application                                          
            -->
        <!-- ============================================================= -->
    <target name="prepare">
        <mkdir dir="${build.dir}" /> 
        <mkdir dir="${build.xmlc_source.dir}" /> 
        <mkdir dir="${build.classes.dir}" /> 
        <mkdir dir="${master.property.dir}" /> 
        <copy file="${master.property}" todir="${master.property.dir}" />
    </target>

        <!-- ============================================================= -->
        <!--    The prepare.test target creates the directories needed for -->
        <!--    building the junit test files                                          
            -->
        <!-- ============================================================= -->
    <target name="prepare.test">
        <mkdir dir="${test.build.dir}" /> 
                <mkdir dir="${test.build.classes.dir}" />
    </target>

  <!-- =================================================================== -->
  <!-- Check to see what optional dependencies are available               -->
  <!-- =================================================================== -->
  <target name="check_for_optional_packages">
    <available property="junit.present" classname="junit.framework.TestListener" 
classpathref="test.build.classpath" />
  </target>

        <!-- ============================================================= -->
        <!--    The xmlc target buils the java class files from the lolo   -->
        <!--    html files                                                             
                                    -->
        <!-- ============================================================= -->
        <target name="xmlc" depends="prepare">  
                
                <xmlc srcdir="${xmlc_resource.dir}" 
                        sourceout="${build.classes.dir}" 
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}" 
                        keep="false" compile="true"
                        includes="*.html" verbose="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />    
                </xmlc>
                
                <xmlc srcdir="${xmlc_resource.dir}/system" 
                        sourceout="${build.classes.dir}" 
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}/system" 
                        keep="false" compile="true"
                        includes="*.html" verbose="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />
                </xmlc>
                
                <xmlc srcdir="${xmlc_resource.dir}/backup" 
                        sourceout="${build.classes.dir}" 
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}/backup" 
                        keep="false" compile="true"
                        includes="*.html" verbose="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />
                </xmlc>
                
                <xmlc srcdir="${xmlc_resource.dir}/maintenance" 
                        sourceout="${build.classes.dir}" 
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}/maintenance" 
                        keep="false" compile="true"
                        includes="*.html" verbose="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />
                </xmlc>
                
                <xmlc srcdir="${xmlc_resource.dir}/monitoring" 
                        sourceout="${build.classes.dir}"  
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}/monitoring" 
                        keep="false" compile="true"
                        includes="*.html" verbose="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />
                </xmlc>
                
                <xmlc srcdir="${xmlc_resource.dir}/network" 
                        sourceout="${build.classes.dir}"  
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}/network" 
                        keep="false" compile="true"
                        includes="*.html" verbose="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />
                </xmlc>
                
                <xmlc srcdir="${xmlc_resource.dir}/storage" 
                        sourceout="${build.classes.dir}" 
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}/storage" 
                        includes="*.html" verbose="true"
                        keep="false" compile="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />
                </xmlc>
                
                <xmlc srcdir="${xmlc_resource.dir}/security" 
                        sourceout="${build.classes.dir}" 
                        destdir="${build.classes.dir}" 
                        packagedir="${xmlc_package.dir}/security" 
                        includes="*.html" verbose="true" 
                        keep="false" compile="true" 
                        classpath="${xmlc.classpath}" >
                        <arg value="${xmlc_options.file}" />
                </xmlc>
        </target>

        <!-- ============================================================= -->
        <!--    The compile target builds the lolo application. This is    -->
        <!--    the default target for build file                                      
            -->
        <!-- ============================================================= -->
    <target name="compile" depends="check_for_optional_packages,xmlc,prepare">
        <javac srcdir="${build.xmlc_source.dir}"
            destdir="${build.classes.dir}"
            classpathref="build.classpath"
        />

        <javac srcdir="${src.dir}" 
                        destdir="${build.classes.dir}" 
                        includes="**/*.java" 
                        excludes="**/old/**" 
                        classpathref="build.classpath"
                />
    </target>  

        <!-- ============================================================= -->
        <!--    The dist target builds a distrabution for the lolo app     -->
        <!-- ============================================================= -->
    <target name="dist" depends="compile">
        <mkdir dir="${jar.dir}" />
        <jar jarfile="${jar.dir}/${jar.name}" basedir="${build.classes.dir}" />
    </target>

        <!-- ============================================================= -->
        <!--    The javadocs target builds javadocs from the lolo source   -->
        <!--    directory                                                              
                                    -->
        <!-- ============================================================= -->
    <target name="javadocs" >
        <mkdir dir="${build.javadocs.dir}"/>
        <javadoc packagenames="${javadoc.packages}"
            sourcepath="${src.dir}"
                        classpathref="build.classpath"
            destdir="${build.javadocs.dir}"
            author="true"
            version="true"
            use="true"
            windowtitle="${app.name} API"
            doctitle="${app.name}"
            bottom="Copyright &#169; ${app.year} ${company.name}"
        />
    </target>

        <!-- ============================================================= -->
        <!--    The compile.tests target compiles the lolo junit test files -->
        <!-- ============================================================= -->
    <target name="compile.tests" depends="compile,prepare.test" if="junit.present">
        <javac srcdir="${test.src.dir}" 
                        destdir="${test.build.classes.dir}" 
                        includes="**/*.java" 
                        excludes="**/old/**" 
                        classpathref="test.build.classpath" />
    </target> 


  <!-- ================================================================ -->
  <!-- Run testcase                                                     -->
  <!-- ================================================================ -->
  <target name="run.tests" depends="compile.tests" if="junit.present">
<property name="cp" refid="test.build.classpath" />
<echo message="Claspath for JUnit: ${cp}" />
    <junit printsummary="no" haltonfailure="yes">
      <classpath refid="test.build.classpath" />

      <formatter type="plain" usefile="false" />

      <batchtest>
        <fileset dir="${test.src.dir}">
          <include name="**/*Test*" />
        </fileset>
      </batchtest>
    </junit>

  </target>

  <!-- ================================================================ -->
  <!-- Run a single testcase                                            -->
  <!-- ================================================================ -->
  <target name="run.single.test" if="testcase" depends="compile.tests">
    <junit printsummary="no" haltonfailure="yes">
        <classpath refid="test.build.classpath" />
                <formatter type="plain" usefile="false" />
        <test name="${testcase}" />
    </junit>
  </target>


</project>

Reply via email to