Sunday, March 1, 2009

Ant tips

  1. JWSDP integration
    <path id="jaxrpc.libs">
    <fileset dir="${lib.dir}/jwsdp-1.5/jaxrpc">
    <include name="*.jar" />
    </fileset>
    </path>

    <path id="saaj.libs">
    <fileset dir="${lib.dir}/jwsdp-1.5/saaj">
    <include name="*.jar" />
    </fileset>
    </path>

    <path id="jwsdp-shared.libs">
    <fileset dir="${lib.dir}/jwsdp-1.5/jwsdp-shared">
    <include name="*.jar" />
    </fileset>
    </path>

    <path id="tools.jar">
    <pathelement location="${env.JAVA_HOME}/lib/tools.jar" />
    </path>

    <taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile">
    <classpath>
    <path refid="jaxrpc.libs" />
    </classpath>
    </taskdef>

    <target name="generate-wsclient" depends="create-target-dirs">
    <wscompile keep="true" fork="true" client="true" features="noencodedtypes" base="${classes.dir}" sourceBase="${gensrc.dir}" mapping="${classes.dir}/ProvisionService-mapping.xml" nonClassDir="${config.dir}" xPrintStackTrace="true" verbose="true" config="${config.dir}/ProvisionService-client-config.xml">
    <classpath>
    <path refid="jaxrpc.libs" />
    <path refid="jwsdp-shared.libs" />
    <path refid="tools.jar" />
    </classpath>
    </wscompile>
    </target>

    <target name="generate-ws-test" depends="create-target-dirs">
    <wscompile keep="true" fork="true" server="true" features="noencodedtypes" base="${test-classes.dir}" sourceBase="${test-gensrc.dir}" mapping="${test-classes.dir}/ProvisionService-mapping.xml" nonClassDir="${config.dir}" xPrintStackTrace="true" verbose="true" config="${config.dir}/ProvisionService-config.xml">
    <classpath>
    <path refid="jaxrpc.libs" />
    <path refid="saaj.libs" />
    <path refid="jwsdp-shared.libs" />
    <path refid="tools.jar" />
    </classpath>
    </wscompile>
    </target>

  2. JUnit integration
    <path id="junit.libs">
    <fileset dir="${lib.dir}/junit-3.8.1">
    <include name="**/*.jar" />
    </fileset>
    </path>

    <junit printsummary="yes" haltonfailure="no" fork="true">
    <classpath>
    <path refid="junit.libs" />

    <pathelement path="${classes.dir}" />
    <pathelement path="${test-classes.dir}" />
    <pathelement path="${test-resources.dir}" />
    </classpath>

    <formatter type="plain" />

    <batchtest todir="${test-results.dir}">
    <fileset dir="${test-classes.dir}">
    <include name="**/ws/client/test/unit/**" />
    </fileset>
    </batchtest>
    </junit>

  3. JMeter integration
    <path id="jmeter-ant.libs">
    <fileset dir="${lib.dir}/jakarta-jmeter-2.2/extras">
    <include name="ant-jmeter.jar" />
    </fileset>
    </path>

    <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask">
    <classpath>
    <path refid="jmeter-ant.libs" />
    </classpath>
    </taskdef>

    <jmeter jmeterhome="${lib.dir}/jakarta-jmeter-2.2" testplan="${test-results.dir}/WebService.jmx" resultlog="${test-results.dir}/WebService.jtl" />
    <xslt in="${test-results.dir}/WebService.jtl" out="${test-results.dir}/WebService.html" style="${lib.dir}/jakarta-jmeter-2.2/extras/jmeter-results-report_21.xsl" />

  4. AntContrib integration
    <taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
    <pathelement location="${libs.dir}/ant/ant-contrib-1.0b3.jar"/>
    </classpath>
    </taskdef>

    <target name="dist-sql">
    <!-- iterate over each .sql file found within database folder
    and call concatSQLFile target for them: -->
    <foreach target="concatSQLFile" param="targetFile">
    <path>
    <fileset dir="database">
    <include name="*.sql"/>
    </fileset>
    </path>
    </foreach>
    </target>

    <!-- is called by target dist-sql
    param: targetFile - the sql file to append -->
    <target name="concatSQLFile">
    <basename property="targetFileShort" file="${targetFile}"/>
    <echo message="${targetFileShort}"/>

    <concat destfile="${dist.dir}/${sql.name}" append="true">
    <header>-- ${targetFileShort}${line.separator}</header>
    <fileset file="${targetFile}"/>
    <footer>-- ${line.separator}</footer>
    </concat>
    </target>

  5. SSH integration
    <sshexec host="${host}" username="${user}" password="${password}" command="rm -rf ${path}/${subfolder}; mkdir -p ${path}/${subfolder}"/>

    <scp todir="${user}:${password}@${host}:${path}/${subfolder}">
    <fileset dir="${dist.dir}">
    <include name="${release.archive}"/>
    <include name="${docs.archive}"/>
    </fileset>
    </scp>

No comments: