I have created sample/default test Web project in eclipse.
Then I am using Ant to build and deploy. I export default build.xml. but this ant doesn't have task to create war file. So, I have to write task for 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 a 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 this in apache webapps">
<copy file="${app}.war" todir="${tomcatWebApps}" />
</target>
When I copy and paste the generated war in webapps. After starting Tomcat server, I found that this war is corrupt. War file is just 1KB file that contains web.xml and manifest.mf.
I would like to know:
- What WAR file contains and its directory structure? What are optional and required files/folders?
- Task syntax to create and war through Ant build.xml
I read SO answer answer1 and answer2 , but couldn't help in my project.