alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Axis 2 example source code file (xmlbeansAntBuildTemplate.xsl)

This example Axis 2 source code file (xmlbeansAntBuildTemplate.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.

Java - Axis 2 tags/keywords

apache, asf, availability, availability, axis2, license, license, see, stax, the, the, xmlbeans, xmlbeans, you

The Axis 2 xmlbeansAntBuildTemplate.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="xbeans.packaged.jar.name" value="XBeans-packaged.jar">

            <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="jar.xbeans">
                <!-- jar the  XMLbeans stuff to the lib folder-->
                <jar>
                    <xsl:attribute name="basedir">${resources}
                    <xsl:attribute name="destfile">${lib}/${xbeans.packaged.jar.name}
                    <xsl:attribute name="excludes">**/services.xml, **/*.xsd
                </jar>
            </target>

            <target name="pre.compile.test" depends="init, jar.xbeans">
                <xsl:comment>Test the classpath for the availability of necesary classes
                <available classname="org.apache.xmlbeans.XmlObject" property="xbeans.available" classpathref="axis2.class.path"/>
                <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"/>
                <condition property="jars.ok" >
                    <and>
                        <isset property="xbeans.available"/>
                        <isset property="stax.available"/>
                        <isset property="axis2.available"/>
                    </and>
                </condition>

                <xsl:comment>Print out the availabilities
                <echo>
                    <xsl:attribute name="message">XmlBeans Availability = ${xbeans.available}
                </echo>
                <echo>
                    <xsl:attribute name="message">Stax Availability= ${stax.available}
                </echo>
                <echo>
                    <xsl:attribute name="message">Axis2 Availability= ${axis2.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="location">${lib}/${xbeans.packaged.jar.name}
                    </classpath>
                    <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="location">${lib}/${xbeans.packaged.jar.name}
                    </classpath>
                    <classpath>
                        <xsl:attribute name="refid">axis2.class.path
                    </classpath>

                    <!-- todo -->

                </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
                        <exclude>**/schemaorg_apache_xmlbean/**
                    </fileset>
                </copy>
                <copy>
                    <xsl:attribute name="file">${lib}/${xbeans.packaged.jar.name}
                    <xsl:attribute name="toDir">${classes}/lib
                </copy>
                <jar>
                    <xsl:attribute name="destfile">${lib}/${name}.aar
                    <fileset>
                        <xsl:attribute name="excludes">**/Test.class
                        <xsl:attribute name="dir">${classes}
                    </fileset>
                </jar>
            </target>

            <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>
                    <fileset>
                        <xsl:attribute name="dir">${resources}
                        <exclude>**/*.wsdl
                        <exclude>**/*.xsd
                        <exclude>**/*.xml
                    </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="jar.client" 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>
                </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 xmlbeansAntBuildTemplate.xsl source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.