Tuesday, October 11, 2005

simple ant project


<project basedir="." default= "web-war" name="contextuon">
<target name="init">
<property name="name" value="contextuon">
<property name="src.dir" value="src">
<property name="dist.dir" value="dist">
<property name="deploy.dir" value="C:/jboss-4.0.1sp1/server/default/deploy">
<property name="web.dir" value="web">
<property name="project.lib" value="lib">
<property name="build.dir" value="build">
<property name="config.dir" value="config">
<property name="build.compiler" value="modern">

<!-- jdbc -->
<property name="jdbc.url" value="jdbc:postgresql://pathfinder/amo">
<property name="database.driver" value="org.postgresql.Driver">
<property name="database.username" value="avexnet">
<property name="database.password" value="avexnet">
<property name="database.schema" value="">
<property name="database.catalog" value="">


<!--war info-->
<property name="build.dir.web" value="${build.dir}/web">
<property name="build.web.inf" value="${build.dir.web}/WEB-INF">
<property name="build.web.classes" value="${build.web.inf}/classes">

<property name="warfile" value="${name}.war">
<property name="web.orig.dir" value="web">
<property name="web.lib" value="${web.orig.dir}/WEB-INF/lib">
<property name="web.classes" value="${web.orig.dir}/WEB-INF/classes">

<!--javadoclet properties-->
<property name="javadoc.dir" value="${web.orig.dir}/html/docs">



<!-- Configure the custom Ant tasks for the Manager application -->
<echo message="JAVA_HOME=${java.home}">
<mkdir dir="${dist.dir}">

 <path id="project.class.path">
<fileset dir="${java.home}/lib">
<include name="*.jar">
</fileset>
<fileset dir="${project.lib}">
<include name="*.jar">
</fileset>
<fileset dir="${web.lib}">
<include name="*.jar">
</fileset>
<fileset dir="${dist.dir}">
<include name="*.jar">
</fileset>
</path>

<tstamp>
<format pattern="d-MM-yy" property="TODAY">
</tstamp>


</target>

<target name="prepare" depends="init"
description="Create build directories.">
<mkdir dir="${dist.dir}">
<mkdir dir="${build.dir}">
<mkdir dir="${build.web.classes}">
<mkdir dir="${build.dir.web}/WEB-INF">
<mkdir dir="${build.dir.web}/WEB-INF/lib">
<mkdir dir="${build.dir.web}/html">
<mkdir dir="${build.dir.web}/images">
<mkdir dir="${build.dir.web}/js">
</target>


<target name="hibernate-gui" depends="init, prepare" description="Runs hibernate ide">
<java classname="net.sf.hibern8ide.Hibern8IDE"
fork="yes" spawn="no">
<classpath refid="project.class.path">
<classpath>
<pathelement location="dist/${name}.jar">
</classpath>
</java>
</target>


<target name="jar-all" depends="init, prepare, web-compile">
<copy todir="${build.dir}/web/WEB-INF/classes">
<fileset dir="web/WEB-INF/classes">
<include name="**/*.lcf">
<include name="**/*.xml">
<include name="**/*.properties">
</fileset>
</copy>
<copy todir="${build.dir}/web/WEB-INF/classes">
<fileset dir="src">
<include name="**/*.properties">
<include name="**/*.hbm.xml">
</fileset>
</copy>
<jar jarfile="${dist.dir}/${name}.jar">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.class">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.xml">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.lcf">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.properties">
<fileset dir="${build.dir}" includes="META-INF/**">
</jar>
</target>


<target name="javadoc" depends="init, prepare">
<javadoc destdir="${javadoc.dir}" classpath="project.class.path" additionalparam="-tag ejb:X">
<fileset dir="${src.dir}">
<include name="**/*.java">
</fileset>
</javadoc>
</target>


<target name="web-compile" depends="init, prepare" description="Compile webapp Java files and copy HTML and JSP pages">
<javac deprecation="on" destdir="${build.web.classes}" srcdir="${src.dir}">
<include name="**/*.java">
<classpath refid="project.class.path">
</javac>
</target>

 <target name="web-war" depends="init, prepare, web-compile"
description="Compile app Java files and copy HTML and JSP pages" >

<copy todir="${build.dir.web}">
<fileset dir="${web.dir}">
<include name="**/*.*">
<exclude name="${web.dir}/WEB-INF/web.xml">
</fileset>
</copy>
<copy todir="${build.dir.web}/WEB-INF/classes">
<fileset dir="${src.dir}">
<include name="**/*.*">
<exclude name="**/*.java">
</fileset>
</copy>

<war warfile="${dist.dir}/${name}.war" webxml="${web.orig.dir}/WEB-INF/web.xml">
<fileset dir="${build.dir.web}">
<include name="**/*.*">
<exclude name="**/web.xml">
</fileset>
</war>
</target>

   <target name="all" depends="init, prepare, web-war" description="Compile webapp Java files and copy HTML and JSP pages">

<target name="deploy" depends="init, prepare, web-war">
<copy todir="${deploy.dir}">
<fileset dir="${dist.dir}">
<include name="${name}.war">
</fileset>
</copy>
</target>

<target name="clean" depends="init">
<delete dir="${build.dir}">
<delete dir="${generated.src.dir}">
<delete dir="${dist.dir}">
</target>

</project>

No comments: