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

Apache CXF example source code file (build.xml)

This example Apache CXF source code file (build.xml) 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 - Apache CXF tags/keywords

apache, asf, asf, cxf_home, cxf_home, generating, is, license, license, of, see, see, version, you

The Apache CXF build.xml source code

<?xml version="1.0"?>
<!--
  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.
-->

<project name="HelloWorldSOAPHttpDemo" default="build" basedir=".">

    <property environment="env"/>
    <condition property="jboss.home" value="${env.JBOSS_HOME}">
        <isset property="env.JBOSS_HOME"/>
    </condition>

    <fail message="this sample need to use jboss, please setup JBOSS_HOME in your environment" unless="jboss.home"/>

    <property environment="env"/>
    <condition property="cxf.home" value="${env.CXF_HOME}">
        <isset property="env.CXF_HOME"/>
    </condition>

    <fail message="this sample need to use CXF_HOME enviroment, please setup CXF_HOME in your environment" unless="cxf.home"/>

    <property name="wsdl.dir" value="${basedir}/etc/wsdl"/>
    <property name="wsdl.location" value="${wsdl.dir}/hello_world.wsdl"/>
    <property name="war.name" value="helloworld.war"/>
    <property name="j2ee.resources.dir" location="${basedir}/../common/resources"/>

    <property environment="env"/>
    <condition property="module.jar.dir" value="${env.CXF_HOME}/modules" else="${env.CXF_HOME}/lib">
        <available file="${env.CXF_HOME}/modules" type="dir"/>
    </condition>
    <condition property="integration.jar.dir" value="${env.CXF_HOME}/modules/integration" else="${env.CXF_HOME}/lib">
        <available file="${env.CXF_HOME}/modules/integration" type="dir"/>
    </condition>
    
    <import file="../../../common_build.xml"/>
 
    <path id="thirdParth.classpath">
        <pathelement location="${basedir}/../common/common.jar"/>
    </path>

    <path id="other.classpath">
        <pathelement location="${cxf.home}/lib/geronimo-servlet_2.5_spec-1.1-M1.jar"/>
        <pathelement location="${basedir}/../common/common.jar"/>
        <pathelement location="${jboss.home}/client/jboss-j2ee.jar"/>
        <fileset dir="${integration.jar.dir}" >  
             <include name="cxf-integration-jca-*.jar"/>
        </fileset>
    </path>
    
    <target name="prepare">
        <replace file="${cxf.home}/etc/ra.xml" token="CXF_HOME" value="${cxf.home}"/>
    </target>

    <target name="init">
        <mkdir dir="${build.classes.dir}"/>
        <mkdir dir="${build.src.dir}"/> 
        <mkdir dir="${build.classes.dir}/lib"/>
    </target>


    <target name="update.jboss.endorsed">
        <copy todir="${jboss.home}/lib/endorsed">
            <fileset dir="${cxf.home}/lib">
                <include name="*activation*" />
                <include name="*annotation*" />
                <include name="*ws-metadata*" />
                <include name="jaxb*" />
                <include name="stax*" />
                <include name="geronimo-stax-api*" />
                <include name="saaj*" />
                <include name="wsdl4j*" />
            </fileset>
        </copy>
    </target>

    <target name="deploy.cxf.rar" depends="generate.rar" description="deploy the cxf.rar">
        <copy todir="${jboss.home}/server/default/deploy">
            <fileset dir="${build.classes.dir}/lib" includes="cxf.rar"/>
            <fileset dir="${basedir}/etc" includes="cxfj2ee_1_5-ds.xml"/>
        </copy>
    </target>


    <target name="generate.rar" depends="prepare,update.jboss.endorsed,init">
        <copy file="${cxf.home}/etc/ra.xml" todir="${build.classes.dir}/cxf-rar/META-INF"/>
        <copy file="${cxf.home}/etc/licenses.txt" todir="${build.classes.dir}/cxf-rar" failonerror="no"/>

        <copy todir="${build.classes.dir}/cxf-rar" failonerror="no">
            <fileset dir="${cxf.home}/lib">
                <include name="*.jar"/>
                <exclude name="cxf*.jar"/>
                <exclude name="*manifest*.jar"/>
                <exclude name="*-jbi-*.jar"/>
            </fileset>
            <fileset dir="${module.jar.dir}">
                <include name="cxf*.jar"/>
                <exclude name="*manifest*.jar"/>
                <exclude name="*-jbi-*.jar"/>
            </fileset>
            <fileset dir="${integration.jar.dir}">
                <include name="*-jca-*.jar"/>
                <exclude name="*-jbi-*.jar"/>
            </fileset>
        </copy>
        <jar destfile="${build.classes.dir}/lib/cxf.rar"
         basedir="${build.classes.dir}/cxf-rar"/>
    </target>
  
    <target name="j2ee.compile" depends="maybe.generate.code">
        <javac destdir="${build.classes.dir}" debug="true">
            <src path="${build.src.dir}"/>
            <src path="${basedir}/src"/>
            <classpath>
                <path refid="cxf.classpath"/>
                <path refid="other.classpath"/>
            </classpath>
        </javac>

        <copy todir="${build.classes.dir}">
            <fileset dir="${basedir}/src" includes="**/*.xml" />
            <fileset dir="${build.src.dir}" includes="**/*.xml" />
            <fileset dir="${build.src.dir}" includes="**/*.wsdl" />
        </copy>
    </target>

   
    <target name="build" description="compile the code" depends="init,j2ee.compile,build-war"/>

    <target name="generate.code">
        <echo level="info" message="Generating code using wsdl2java..."/>
        <wsdl2java file="hello_world.wsdl"/>
    </target>

     <target name="clean">
        <delete failonerror="no">
            <fileset dir="./build" includes="**/*.class"/>
            <fileset dir="./build" includes="**/*.jar"/>
            <fileset dir="./build" includes="**/*.rar"/>
            <fileset dir="${build.classes.dir}/cxf-rar" includes="**/*"/>
        </delete>
    </target>

    <target name="build-war">
        <copy file="${wsdl.location}" todir="${basedir}/src" />

        <mkdir dir="./build/lib"/>
        <mkdir dir="./build/classes/wsdl"/>
        <copy file="${wsdl.location}" todir="${basedir}/build/classes/wsdl"/>
        <war destfile="build/lib/${war.name}" webxml="${basedir}/etc/web.xml">
            <webinf dir="etc">
                <include name="jboss-web.xml"/>
                <include name="weblogic.xml"/>
            </webinf>

            <lib dir="../common/">
                <include name="common.jar"/>
            </lib>

            <classes dir="${build.classes.dir}">
                <include name="**/*.class"/>
                <include name="**/*.wsdl"/>
            </classes>

            <zipfileset dir="${j2ee.resources.dir}/images" prefix="images">
                <include name="*.gif" />
            </zipfileset>

            <zipfileset dir="${j2ee.resources.dir}">
                <include name="*.css" />
            </zipfileset>

        </war>
    </target>

    <target name="deploy.war" description="deploy the helloworld.war" depends="build-war">
        <copy todir="${jboss.home}/server/default/deploy">
            <fileset dir="${basedir}/build/lib" includes="helloworld.war"/>
        </copy>
    </target>

    <target name="client" description="run demo client" depends="build">
        <property name="param" value=""/>
        <cxfrun classname="demo.client.Client" param1="${op}"/>
    </target>


</project>

Other Apache CXF examples (source code examples)

Here is a short list of links related to this Apache CXF build.xml source code file:

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.