|
|
Axis 2 example source code file (jibxAntBuildTemplate.xsl)
This example Axis 2 source code file (jibxAntBuildTemplate.xsl) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
The Axis 2 jibxAntBuildTemplate.xsl source code
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/ant">
<xsl:variable name="package" select="@package"/>
<xsl:variable name="src" select="@src"/>
<xsl:variable name="resource" select="@resource"/>
<project basedir=".">
<xsl:choose>
<xsl:when test="@isserverside">
<xsl:attribute name="default">jar.server
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="default">jar.client
</xsl:otherwise>
</xsl:choose>
<xsl:comment>Auto generated ant build file
<property environment="env"/>
<property name="axis2.home">
<xsl:attribute name="value">${env.AXIS2_HOME}
</property>
<property name="project.base.dir">
<xsl:attribute name="value">.
</property>
<property name="maven.class.path">
<xsl:attribute name="value">
</property>
<property name="name">
<xsl:attribute name="value">
</property>
<property name="src">
<xsl:attribute name="value">${project.base.dir}/
</property>
<property name="test">
<xsl:attribute name="value">${project.base.dir}/test
</property>
<property name="build">
<xsl:attribute name="value">${project.base.dir}/build
</property>
<property name="classes">
<xsl:attribute name="value">${build}/classes
</property>
<property name="lib">
<xsl:attribute name="value">${build}/lib
</property>
<property name="resources">
<xsl:attribute name="value">${project.base.dir}/
</property>
<property name="jars.ok" value="">
<path id="axis2.class.path">
<pathelement>
<xsl:attribute name="path">${java.class.path}
</pathelement>
<pathelement>
<xsl:attribute name="path">${maven.class.path}
</pathelement>
<fileset>
<xsl:attribute name="dir">${axis2.home}
<include>
<xsl:attribute name="name">lib/*.jar
</include>
</fileset>
</path>
<target name="init">
<mkdir>
<xsl:attribute name="dir">${build}
</mkdir>
<mkdir>
<xsl:attribute name="dir">${classes}
</mkdir>
<mkdir>
<xsl:attribute name="dir">${lib}
</mkdir>
<xsl:if test="not(@testOmit)">
<mkdir>
<xsl:attribute name="dir">${test}
</mkdir>
</xsl:if>
</target>
<target name="pre.compile.test" depends="init">
<xsl:comment>Test the classpath for the availability of necesary classes
<available classname="javax.xml.stream.XMLStreamReader" property="stax.available" classpathref="axis2.class.path"/>
<available classname="org.apache.axis2.engine.AxisEngine" property="axis2.available" classpathref="axis2.class.path"/>
<available classname="org.jibx.runtime.BindingDirectory" property="jibx.available" classpathref="axis2.class.path"/>
<condition property="jars.ok">
<and>
<isset property="stax.available"/>
<isset property="axis2.available"/>
<isset property="jibx.available"/>
</and>
</condition>
<xsl:comment>Print out the availabilities
<echo>
<xsl:attribute name="message">Stax Availability= ${stax.available}
</echo>
<echo>
<xsl:attribute name="message">Axis2 Availability= ${axis2.available}
</echo>
<echo>
<xsl:attribute name="message">JiBX Availability= ${jibx.available}
</echo>
</target>
<target name="compile.src" depends="pre.compile.test">
<xsl:attribute name="if">jars.ok
<javac fork="true" memoryInitialSize="256m" memoryMaximumSize="256m" debug="on">
<xsl:attribute name="destdir">${classes}
<xsl:attribute name="srcdir">${src}
<classpath>
<xsl:attribute name="refid">axis2.class.path
</classpath>
</javac>
</target>
<target name="compile.test" depends="compile.src">
<xsl:attribute name="if">jars.ok
<javac fork="true" memoryInitialSize="256m" memoryMaximumSize="256m" debug="on">
<xsl:attribute name="destdir">${classes}
<src>
<xsl:attribute name="path">${test}
</src>
<classpath>
<xsl:attribute name="refid">axis2.class.path
</classpath>
</javac>
</target>
<target name="echo.classpath.problem" depends="pre.compile.test">
<xsl:attribute name="unless">jars.ok
<echo message="The class path is not set right!
Please make sure the following classes are in the classpath
1. XmlBeans
2. Stax
3. Axis2
"></echo>
</target>
<target name="jar.all" depends="jar.server, jar.client">
</target>
<target name="jar.server" depends="compile.src,echo.classpath.problem">
<xsl:attribute name="if">jars.ok
<copy>
<xsl:attribute name="toDir">${classes}/META-INF
<xsl:attribute name="failonerror">false
<fileset>
<xsl:attribute name="dir">${resources}
<include>*.xml
<include>*.wsdl
<include>*.xsd
</fileset>
</copy>
<jar>
<xsl:attribute name="destfile">${lib}/${name}.aar
<fileset>
<xsl:attribute name="excludes">**/Test.class
<xsl:attribute name="dir">${classes}
</fileset>
</jar>
</target>
<!-- select between the -->
<target name="jar.client" if="jars.ok">
<!--set the correct depends target-->
<xsl:choose>
<xsl:when test="@testOmit">
<xsl:attribute name="depends">compile.src
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="depends">compile.test
</xsl:otherwise>
</xsl:choose>
<jar>
<xsl:attribute name="destfile">${lib}/${name}-test-client.jar
<fileset>
<xsl:attribute name="dir">${classes}
<exclude>**/META-INF/*.*
<exclude>**/lib/*.*
<exclude>**/*MessageReceiver.class
<exclude>**/*Skeleton.class
</fileset>
</jar>
</target>
<target name="make.repo" depends="jar.server" if="jars.ok">
<mkdir>
<xsl:attribute name="dir">${build}/repo/
</mkdir>
<mkdir>
<xsl:attribute name="dir">${build}/repo/services
</mkdir>
<copy>
<xsl:attribute name="file">${build}/lib/${name}.aar
<xsl:attribute name="toDir">${build}/repo/services/
</copy>
</target>
<target name="start.server" depends="make.repo" if="jars.ok">
<java classname="org.apache.axis2.transport.http.SimpleHTTPServer" fork="true">
<arg>
<xsl:attribute name="value">${build}/repo
</arg>
<classpath>
<xsl:attribute name="refid">axis2.class.path
</classpath>
</java>
</target>
<target name="run.test" depends="compile.test" if="jars.ok">
<path id="test.class.path">
<pathelement>
<xsl:attribute name="location">${lib}/${name}-test-client.jar
</pathelement>
<path>
<xsl:attribute name="refid">axis2.class.path
</path>
<pathelement>
<xsl:attribute name="location">${classes}
</pathelement>
</path>
<mkdir>
<xsl:attribute name="dir">${build}/test-reports/
</mkdir>
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<xsl:attribute name="refid">test.class.path
</classpath>
<formatter type="plain"/>
<batchtest fork="yes">
<xsl:attribute name="toDir">${build}/test-reports/
<fileset>
<xsl:attribute name="dir">${test}
<include>
<xsl:attribute name="name">**/*Test*.java
</include>
</fileset>
</batchtest>
</junit>
</target>
<target name="clean">
<delete>
<xsl:attribute name="dir">${build}
</delete>
</target>
</project>
</xsl:template>
</xsl:stylesheet>
Other Axis 2 examples (source code examples)
Here is a short list of links related to this Axis 2 jibxAntBuildTemplate.xsl source code file:
|