Skip Headers

# Creating TopLink Workbench Ant Tasks

Previous

Next

Example: Example Ant Build File with TopLink Workbench Ant Tasks shows a typical Ant `build.`xml file that declares and uses the TopLink Workbench Ant task and type definitions.

Example Ant Build File with TopLink Workbench Ant Tasks

    <project name="MyBuild" default="validate.session" basedir="." xmlns:toplink="toplinklib">
        <!-- ===================================================== -->
        <!--  Properties                                           -->
        <!-- ===================================================== -->
        <target name="init">
            <property file="build.properties"/>

            <property name = "toplink.mwp.dir" value = "${basedir}/mw"/>
            <property name = "toplink.sessions.dir" value = "${basedir}/config"/>
            <property name = " myProject.classes" value = "${basedir}/classes "/>

            <path id = "database.classpath">
                <pathelement path = "${toplink.home}/jlib /dms.jar"/>
                <pathelement path = "${toplink.home}/jlib /OracleThinJDBC.jar"/>
            </path>
            <path id = "toplink.classpath">
                <pathelement path = "${toplink.home}/jlib /toplink.jar"/>
                <pathelement path = "${toplink.home}/jlib /ejb.jar"/>
                <pathelement path = "${toplink.home}/jlib /xmlparserv2.jar"/>
                <pathelement path = "${toplink.home}/jlib /antlr.jar"/>
            </path>
            <path id = "mw.classpath">
                <pathelement path = "${toplink.home}/jlib /tlmwcore.jar"/>
                <pathelement path = "${toplink.home}/jlib /toplinkmw.jar"/>
            </path>
            <path id = "mwplatforms.classpath">
                <pathelement path = "${toplink.home}/config"/>
            </path>

            <typedef file = "toplink-ant-lib.xml"

                     classpathref = "mw.classpath"
                     uri = "toplinklib" />
        </target>
        <!-- ===================================================== -->
        <!--  Define task parameter                                -->
        <!-- ===================================================== -->
        <target name="parameter.definition" depends="init">
            <toplink:ignoreerrorset id = "ignoreErrors">
            <toplink:ignoreerror code = "0233" />
            </toplink:ignoreerrorset>

            <toplink:loginspec id = "loginSpec"
            url = "jdbc:cloudscape:stagedb;create=true"
            driverclass = "COM.cloudscape.core.JDBCDriver"
            user = "scott"
            password="tiger" />
        </target>
         <!-- ==================================================== -->
        <!--  Validate the MW Project                              -->
        <!-- ===================================================== -->
        <target name="validate.project" depends="parameter.definition">

            <toplink:mappings.validate
                projectfile = "${toplink.mwp.dir}/myProject.mwp"
                reportfile = "${toplink.mwp.dir}/problem-report.html"
                reportformat = "html"
                property = "mw-valid"
                classpathref = "mwplatforms.classpath" >

                <toplink:classpath refid = "mw.classpath" />
                <toplink:classpath refid = "toplink.classpath" />

                <toplink:ignoreerrorset refid = "ignoreErrors"/>

            </toplink:mappings.validate>
        </target>
        <!-- ===================================================== -->
        <!--  TopLink deployment descriptor XML generation         -->
        <!-- ===================================================== -->
        <target name="export.deployment" depends="validate.project"  if="mw-valid">

            <toplink:mappings.export
                projectfile = "${toplink.mwp.dir}/myProject.mwp"
                deploymentfile = "${toplink.sessions.dir}/sessions.xml"
                property = "export-completed"
                failonerror = "true"
                classpathref = "toplink.classpath">

                <toplink:classpath refid = "mw.classpath" />
                <toplink:classpath refid = "mwplatforms.classpath" />

                <toplink:ignoreerrorset refid = "ignoreErrors"/>
                <toplink:loginspec refid = "loginSpec" />
            </toplink:mappings.export>
        </target>
        <!-- ===================================================== -->
        <!--  TopLink Session Validate                             -->
        <!-- ===================================================== -->
        <target name="validate.session"  depends="export.deployment" if="export-completed">

            <toplink:session.validate
                sessionsfile = "${toplink.sessions.dir}/sessions.xml"
                sessionname = "ThreeTierEmployee"
                property = "session-valid"
                classpathref = "toplink.classpath"
                classpath = "${ myProject.classes}" >

                <toplink:classpath refid = "mw.classpath" />
                <toplink:classpath refid = " database.classpath" />

                <toplink:loginspec refid = "loginSpec" />
            </toplink:session.validate>
        </target>
    <project>