Reputation: 778
I am having problem generating the war file correctly with ANT's build.xml for Struts2.
My problem was for the struts.xml, I can't seem to be able to put it to the right place even though I tried to use the tag.
What is the correct way of putting it into the war file? Here is my code (removed the tag as it wasn't working):
<?xml version="1.0" encoding="UTF-8"?>
<project name="Struts2Proj" default="war">
<property name= "build.dir" value="build"/>
<property name= "src.dir" value="src"/>
<property name= "lib.home" value="WebContent/WEB-INF/lib"/>
<target name="clean" description="Clean output directories">
<delete>
<fileset dir="classes">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="build" description="Compile source tree java files">
<mkdir dir="${build.dir}"/>
<javac src ="${src.dir}" destdir="${build.dir}" >
<classpath>
<path>
<fileset dir="${lib.home}" />
</path>
</classpath>
</javac>
</target>
<target name="war">
<war destfile="Struts2Project.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent">
<include name="**/*.*"/>
</fileset>
<lib dir="${lib.home}" />
<classes dir="build/classes"/>
</war>
</target>
</project>
Upvotes: 0
Views: 1495
Reputation: 24396
The problem seems to be in your build
target. You are not copying configuration files (like struts.xml
) to your build path. See this ANT tutorial: http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html#config-files.
Example:
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>
Upvotes: 2