Ant项目打包脚本

<!-- path of the web source files -->
<property name="webapp.path" value="." />

<!-- build output name -->
<property name="output_war" value="myapp.war" />

<!-- paths to the Tomcat JSP compiler -->
<property name="catalina.home" value="C:\Programmer\Tomcat 5.5" />

<target name="make_war" depends="compile">
<description>Harvest the compiled files and html files into a WAR file ready for deployment</description>
<war destfile="${output_war}" webxml="${webapp.path}/WEB-INF/web.xml">
<classes dir="${webapp.path}/WEB-INF/classes"/>
<zipfileset dir="${webapp.path}/graphics/images/" prefix="images"/>
</war>
</target>


<target name="compile" depends="jsp_compile">
<description>
Compile the generated servlets and change web.xml into mapping the servlets to the corresponding .jsp urls.
</description>

<mkdir dir="${webapp.path}/WEB-INF/classes"/>
<mkdir dir="${webapp.path}/WEB-INF/lib"/>

<javac destdir="${webapp.path}/WEB-INF/classes" srcdir="${webapp.path}/WEB-INF/src" >
<classpath>
<pathelement location="${webapp.path}/WEB-INF/classes" />
<fileset dir="${webapp.path}/WEB-INF/lib"> <include name="*.jar" /></fileset>

<pathelement location="${catalina.home}/common/classes" />
<fileset dir="${catalina.home}/common/lib"> <include name="*.jar" /></fileset>

<pathelement location="${catalina.home}/shared/classes" />
<fileset dir="${catalina.home}/shared/lib"> <include name="*.jar" /></fileset>

<fileset dir="${catalina.home}/bin"> <include name="*.jar" /></fileset>
</classpath>
<include name="**" />
<exclude name="tags/**" />
</javac>
</target>


<target name="jsp_compile" depends="clean_jspcompile">
<description>Take all .jsp pages and convert them into servlets using the Tomcat jsp compiler</description>
<taskdef classname="org.apache.jasper.JspC" name="jasper2">
<classpath id="jspc.classpath">
<fileset dir="${catalina.home}/bin"><include name="*.jar"/> </fileset>
<fileset dir="${catalina.home}/server/lib"> <include name="*.jar"/> </fileset>
<fileset dir="${catalina.home}/common/lib"> <include name="*.jar"/> </fileset>
</classpath>
</taskdef>

<jasper2 uriroot="${webapp.path}"
webXmlFragment
="${webapp.path}/WEB-INF/generated_web.xml"
addWebXmlMappings
="true"
outputDir
="${webapp.path}/WEB-INF/src/" />

<!-- path to the compiler generated web.xml -->
<!-- automatically merge the "generated_web.xml" into "web.xml" -->
<!-- path to the output of the compilation -->
</target>

<target name="clean_jspcompile">
<description>clear the generated source files</description>
<delete dir="${webapp.path}/WEB-INF/src"/>
</target>
posted @ 2012-02-13 14:43  microsoft_kk  阅读(1393)  评论(0编辑  收藏  举报