eclipse - Build WAR file using Ant for WebApplication -
i have created sample/default test web project in eclipse.
then using ant build , deploy. export default build.xml. ant doesn't have task create war file. so, have write task creating war.
i used below code.
<property name="app" value="testantwar"/> <property name="tomcatwebapps" value="c:/apps/apache/jakarta/tomcat/tomcat-6/webapps" /> ...... <target name="buildwar" description="create war file"> <war basedir="${basedir}/build" destfile="${app}.war" webxml="${basedir}/webcontent/web-inf/web.xml"> <fileset dir="webcontent"/> <exclude name="web-inf/**" /> <lib dir="webcontent/web-inf/lib"/> <lib dir="lib"/> <classes dir="build/classes"/> <classes dir="config"/> <webinf dir="${basedir}/webcontent/web-inf/"> <include name="**/*.jar" /> </webinf> </war> </target> <target name="deploy" depends="buildwar" description="deploy in apache webapps"> <copy file="${app}.war" todir="${tomcatwebapps}" /> </target>
when copy , paste generated war in webapps. after starting tomcat server, found war corrupt. war file 1kb file contains web.xml , manifest.mf.
i know:
- what war file contains , directory structure? optional , required files/folders?
- task syntax create , war through ant build.xml
your war file doesn't right me.
- content , web.xml should @ root.
- web-inf @ root.
- .class files in web-inf/classes
- .jar files in web-inf/lib
Comments
Post a Comment