java - How to include local dependencies in my ant build -
at present have following build.xml:
<project name="bccn" default="help" basedir="."> <!-- define properties used build --> <property name="app.name" value="bccn" /> <property name="app.version" value="0.1-dev" /> <property name="tcserver.home" value="/home/abhishek/tomcat" /> <property name="work.home" value="${basedir}/work" /> <property name="dist.home" value="${basedir}/dist" /> <property name="src.home" value="${basedir}/src" /> <property name="web.home" value="${basedir}/web" /> <property name="lib.dir" value="${basedir}/lib" /> <target name="help"> <echo>you can use following targets:</echo> <echo> </echo> <echo> : (default) prints message </echo> <echo> : cleans, compiles, , packages application</echo> <echo> clean : deletes work directories</echo> <echo> compile : compiles servlets class files</echo> <echo> dist : packages artifacts deployable war</echo> <echo> </echo> <echo>for example, clean, compile, , package @ once, run:</echo> <echo>prompt> ant </echo> </target> <!-- define classpath --> <path id="compile.classpath"> <fileset dir="${tcserver.home}/bin"> <include name="*.jar" /> </fileset> <pathelement location="${tcserver.home}/lib" /> <fileset dir="${tcserver.home}/lib"> <include name="*.jar" /> </fileset> </path> <target name="all" depends="clean,compile,dist" description="clean work dirs, compile , create war" /> <target name="clean" description="delete old work , dist directories"> <delete dir="${work.home}" /> <delete dir="${dist.home}" /> </target> <target name="prepare" depends="clean" description="create working dirs , copy static files work dir"> <mkdir dir="${dist.home}" /> <mkdir dir="${work.home}/web-inf/classes" /> <!-- copy static html , jsp files work dir --> <copy todir="${work.home}"> <fileset dir="${web.home}" /> </copy> </target> <target name="compile" depends="prepare" description="compile java sources , copy web-inf/classes dir"> <javac srcdir="${src.home}" destdir="${work.home}/web-inf/classes"> <classpath refid="compile.classpath" /> </javac> <copy todir="${work.home}/web-inf/classes"> <fileset dir="${src.home}" excludes="**/*.java" /> </copy> </target> <target name="dist" depends="compile" description="create war file binary distribution"> <jar jarfile="${dist.home}/${app.name}-${app.version}.war" basedir="${work.home}" /> </target>
now included log4j local dependency , want include when create .war file. however, ant not able find dependency. there way working? sorry basic question, noob @ it.
update (and got already):
i didn't want add "war" thing modified build.xml follows: ``
<target name="help"> <echo>you can use following targets:</echo> <echo> </echo> <echo> : (default) prints message </echo> <echo> : cleans, compiles, , packages application</echo> <echo> clean : deletes work directories</echo> <echo> compile : compiles servlets class files</echo> <echo> dist : packages artifacts deployable war</echo> <echo> </echo> <echo>for example, clean, compile, , package @ once, run:</echo> <echo>prompt> ant </echo> </target> <!-- define classpath --> <path id="compile.classpath"> <fileset dir="${tcserver.home}/bin"> <include name="*.jar" /> </fileset> <pathelement location="${tcserver.home}/lib" /> <fileset dir="${tcserver.home}/lib"> <include name="*.jar" /> </fileset> <fileset dir="${lib.dir}"> <include name="*.jar" /> </fileset> </path> <target name="all" depends="clean,compile,dist" description="clean work dirs, compile , create war" /> <target name="clean" description="delete old work , dist directories"> <delete dir="${work.home}" /> <delete dir="${dist.home}" /> </target> <target name="prepare" depends="clean" description="create working dirs , copy static files work dir"> <mkdir dir="${dist.home}" /> <mkdir dir="${work.home}/web-inf/classes" /> <!-- copy static html , jsp files work dir --> <copy todir="${work.home}"> <fileset dir="${web.home}" /> </copy> </target> <target name="compile" depends="prepare" description="compile java sources , copy web-inf/classes dir"> <javac srcdir="${src.home}" destdir="${work.home}/web-inf/classes"> <classpath refid="compile.classpath" /> </javac> <copy todir="${work.home}/web-inf/classes"> <fileset dir="${src.home}" excludes="**/*.java" /> <fileset dir="${lib.dir}" includes="*.jar" /> </copy> </target> <target name="dist" depends="compile" description="create war file binary distribution"> <jar jarfile="${dist.home}/${app.name}-${app.version}.war" basedir="${work.home}" /> </target>
now ant can find dependencies , compile it. when deploy tomcat server, fails file dependencies. can please provide ideas how can package dependencies visible tomcat well?
you should use war task instead:
<war destfile="${warname}" webxml="war/web-inf/web.xml"> <fileset dir="${work.home}"/> <lib dir="${lib.dir}/" includes="log4j.jar"/> <classes dir = "${classes}" /> </war>
you can configure find dependency jars included in war file , specify path web.xml folder. shouldn't coping .class files destination in war folder, let war task you.
Comments
Post a Comment