Monday 17 March 2014

bulid xml like as normal folder . war

Following build.xml is used to create the war file like normal folder


<!-- Build file for epubtoword -->

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

  <!-- ============= -->
  <!-- === CLEAN === -->
  <!-- ============= -->
  <target name="clean"  description="removes all generated files">
    <delete dir="build" />
  </target>
  
  <!-- =============== -->
  <!-- === INIT === -->
  <!-- =============== -->
  <target name="init">
 <property name="dirs.base" value="${basedir}"/>
 <property name="src" value="${dirs.base}/src"/>
 <property environment="env"/> 
 <property name="jboss.home" value="${env.JBOSS_HOME}"/>
 <property name="warDir" value="${jboss.home}/server/default/deploy/epubtoword.war"/>
 
 <!-- Create Web-inf and classes directories -->
 <mkdir dir="${warDir}/WEB-INF"/>
 <mkdir dir="${warDir}/WEB-INF/classes"/>
 <mkdir dir="${warDir}/WEB-INF/lib"/>
 <mkdir dir="${warDir}/src"/>
 <mkdir dir="${warDir}/css" />
 <mkdir dir="${warDir}/images"/>
 <mkdir dir="${warDir}/js"/>
 <mkdir dir="${warDir}/fonts"/>
</target>

  <!-- ================= -->
  <!-- === CLASSPATH === -->
  <!-- ================= -->
  <path id="classpath">
    <fileset dir="WebContent/WEB-INF/lib" includes="**/*.jar" />
  </path>
  
  <!-- =============== -->
  <!-- === COMPILE === -->
  <!-- =============== -->
  <target name="compile" depends="init">
   <echo message="start compiling" />
 <javac srcdir="${src}" destdir="${warDir}/WEB-INF/classes" debug="true" includes="**/*.java">
 <classpath refid="classpath" />
 </javac>
  </target>
  <!-- =============== -->
  <!-- === BUILD ===== -->
  <!-- =============== -->
  <target name="build" depends="init,compile">
    <echo message="start building:" />
    <copy todir="${warDir}/src">
     <fileset dir="src/" includes="**/*.java"/>
    </copy>
    <copy todir="${warDir}/">
     <fileset dir="${dirs.base}/" includes="*.jsp"/>
    </copy>
    <copy todir="${warDir}/">
     <fileset dir="${dirs.base}/" includes="*.html"/>
    </copy>
    <copy todir="${warDir}/">
     <fileset dir="${dirs.base}/" includes="*.htm"/>
    </copy>    
    <copy todir="${warDir}/">
     <fileset dir="${dirs.base}/" includes="**/*.properties"/>
    </copy>
    <copy todir="${warDir}/WEB-INF">
     <fileset dir="${dirs.base}/" includes="web.xml"/>
    </copy>
    
    <copy todir="${warDir}/WEB-INF/lib">
     <fileset dir="${dirs.base}/WEB-INF/lib" includes="*.jar" />
    </copy>
    <copy todir="${warDir}/images">
     <fileset dir="${dirs.base}/images" includes="*.*"/>
    </copy>
    
    <copy todir="${warDir}/js">
     <fileset dir="${dirs.base}/js" includes="*.js"/>
    </copy>
  <copy todir="${warDir}/css">
     <fileset dir="${dirs.base}/css" includes="*.css"/>
    </copy>
 
 <copy todir="${warDir}/fonts">
     <fileset dir="${dirs.base}/fonts" includes="*.*"/>
    </copy>
 
  </target>
  </project>

bulid.xml Creation

build xml creation  from eclipse  project  as war file


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="deploy" name="epubtoword">
 <property name="warfile" value="epubtowordx" />
 <target name="unpack">
  <unwar src="${warfile}.war" dest="${warfile}" />
 </target>
 <property name="debuglevel" value="source,lines,vars" />
 <property name="target" value="1.5" />
 <property name="source" value="1.5" />
 <path id="Web App Libraries.libraryclasspath">
  <pathelement location="WebContent/WEB-INF/lib/commons-fileupload-1.2.1.jar" />
  <pathelement location="WebContent/WEB-INF/lib/commons-fileupload-1.2.2.jar" />
  <pathelement location="WebContent/WEB-INF/lib/commons-io-2.3.jar" />
  <pathelement location="WebContent/WEB-INF/lib/commons-logging-1.1.1.jar" />
  <pathelement location="WebContent/WEB-INF/lib/javax.servlet-3.0.jar" />
  <pathelement location="WebContent/WEB-INF/lib/javax.servlet.jar" />
  <pathelement location="WebContent/WEB-INF/lib/mail.jar" />
  <pathelement location="WebContent/WEB-INF/lib/mysql-connector-java-3.1.10-bin.jar" />
  <pathelement location="WebContent/WEB-INF/lib/org.apache.commons.io.jar" />
  <pathelement location="WebContent/WEB-INF/lib/quartz-1.5.2.jar" />
  <pathelement location="WebContent/WEB-INF/lib/urlrewritefilter-4.0.3.jar" />
  <pathelement location="WebContent/WEB-INF/lib/xercesImpl-2.6.2-jaxb-1.0.6.jar" />
 </path>
 <path id="EAR Libraries.libraryclasspath" />
 <path id="epubtoword.classpath">
  <pathelement location="build/classes" />
  <path refid="Web App Libraries.libraryclasspath" />
  <path refid="EAR Libraries.libraryclasspath" />
 </path>
 <target name="init">
  <mkdir dir="build/classes" />
  <copy includeemptydirs="false" todir="build/classes">
   <fileset dir="src">
    <exclude name="**/*.launch" />
    <exclude name="**/*.java" />
   </fileset>
  </copy>
 </target>
 <target name="clean">
  <delete dir="build/classes" />
 </target>
 <target name="build">
  <javac debug="true" debuglevel="${debuglevel}" destdir="build/classes" source="${source}" target="${target}">
   <src path="src" />
   <classpath refid="epubtoword.classpath" />
  </javac>
 </target>

 <target name="create">
  <war destfile="/usr/jboss-4.2.3.GA/server/default/deploy/${warfile}.war" webxml="WebContent/WEB-INF/web.xml" update="true">
   <classes dir="build/classes" />
   <fileset dir="WebContent">
    <exclude name="WEB-INF/web.xml" />
   </fileset>
  </war>
 </target>
 

 <target name="deploy">
  <antcall target="clean" />
  <antcall target="init" />
  <antcall target="build" />
  <antcall target="create" />

 </target>
</project>