为了能够支配到日常环境,写的dorado ant 部署脚本
为了能够部署到日常环境,写的dorado ant 部署脚本
<?xml version="1.0" encoding="UTF-8"?>
<project name="SCM" default="compile" basedir=".">
<property name="webapp.name" value="SCM"/>
<property name="catalina.home" value="E:\fengbin\java\apache-tomcat-5.5.26"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="lib.dir" value="${basedir}/web/WEB-INF/lib"/>
<property name="class.dir" value="${basedir}/web/WEB-INF/classes"/>
<property name="webapps.dir" value="${catalina.home}/webapps"/>
<property name="cfg.dir" value="${basedir}/cfg"/>
<property name="webfile.dir" value="${basedir}/web"/>
<property name="ui.dir" value="ui"/>
<!-- **********************************set classpath********************************** -->
<path id="compile.classpath">
<fileset dir="${catalina.home}/common/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- **********************************init********************************** -->
<target name="init">
<mkdir dir="${src.dir}"/>
<mkdir dir="${lib.dir}"/>
<mkdir dir="${ui.dir}"/>
</target>
<!-- **********************************clean class********************************** -->
<target name="clean" description="Delete old build and dist directories">
<delete dir="${class.dir}" includes="**/*.class"/>
</target>
<!-- **********************************compile java********************************** -->
<target name="compile" description="Compile Java sources" depends="clean">
<mkdir dir="${class.dir}"/>
<javac srcdir="${src.dir}"
destdir="${class.dir}" includeantruntime="on" encoding="UTF-8">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${class.dir}">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>
<!-- **********************************deploy webapp********************************** -->
<target name="deploy" description="Install application to servlet container" depends="compile">
<delete dir="${webapps.dir}/${webapp.name}"/>
<war destfile="${webapps.dir}/${webapp.name}.war" webxml="${basedir}/web/WEB-INF/web.xml">
<fileset dir="ui"/>
<fileset dir="${webfile.dir}" excludes="WEB-INF"/>
<lib dir="${lib.dir}"/>
<classes dir="${class.dir}"/>
</war>
</target>
<!-- **********************************start web server********************************** -->
<target name="startserver" description="Start web server" >
<exec dir="${catalina.home}/bin" executable="cmd.exe">
<env key="CATALINA_HOME" path="${catalina.home}"/>
<arg value="/c startup.bat"/>
</exec>
</target>
<!-- **********************************stop web server********************************** -->
<target name="stopserver" description="Stop web server" >
<exec dir="${catalina.home}/bin" executable="cmd.exe">
<env key="CATALINA_HOME" path="${catalina.home}"/>
<arg value="/c shutdown.bat"/>
</exec>
</target>
<!-- **********************************start work********************************** -->
<target name="start" description="Clean build and dist directories, then compile">
<ant target="deploy"/>
<ant target="startserver"/>
</target>
<!-- **********************************reload web server********************************** -->
<target name="reload" description="reload web server">
<ant target="stopserver"></ant>
<sleep seconds="2"></sleep>
<ant target="start"></ant>
</target>
</project>
错误记录:
The processing instruction target matching "[xX][mM][lL]" is not allowed
神奇的错误
原因 因为 ant脚本 build.xml 中第一行为空造成的.
<?xml version="1.0" encoding="UTF-8"?>
<project name="SCM" default="compile" basedir=".">
<property name="webapp.name" value="SCM"/>
<property name="catalina.home" value="E:\fengbin\java\apache-tomcat-5.5.26"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="lib.dir" value="${basedir}/web/WEB-INF/lib"/>
<property name="class.dir" value="${basedir}/web/WEB-INF/classes"/>
<property name="webapps.dir" value="${catalina.home}/webapps"/>
<property name="cfg.dir" value="${basedir}/cfg"/>
<property name="webfile.dir" value="${basedir}/web"/>
<property name="ui.dir" value="ui"/>
<!-- **********************************set classpath********************************** -->
<path id="compile.classpath">
<fileset dir="${catalina.home}/common/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- **********************************init********************************** -->
<target name="init">
<mkdir dir="${src.dir}"/>
<mkdir dir="${lib.dir}"/>
<mkdir dir="${ui.dir}"/>
</target>
<!-- **********************************clean class********************************** -->
<target name="clean" description="Delete old build and dist directories">
<delete dir="${class.dir}" includes="**/*.class"/>
</target>
<!-- **********************************compile java********************************** -->
<target name="compile" description="Compile Java sources" depends="clean">
<mkdir dir="${class.dir}"/>
<javac srcdir="${src.dir}"
destdir="${class.dir}" includeantruntime="on" encoding="UTF-8">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${class.dir}">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>
<!-- **********************************deploy webapp********************************** -->
<target name="deploy" description="Install application to servlet container" depends="compile">
<delete dir="${webapps.dir}/${webapp.name}"/>
<war destfile="${webapps.dir}/${webapp.name}.war" webxml="${basedir}/web/WEB-INF/web.xml">
<fileset dir="ui"/>
<fileset dir="${webfile.dir}" excludes="WEB-INF"/>
<lib dir="${lib.dir}"/>
<classes dir="${class.dir}"/>
</war>
</target>
<!-- **********************************start web server********************************** -->
<target name="startserver" description="Start web server" >
<exec dir="${catalina.home}/bin" executable="cmd.exe">
<env key="CATALINA_HOME" path="${catalina.home}"/>
<arg value="/c startup.bat"/>
</exec>
</target>
<!-- **********************************stop web server********************************** -->
<target name="stopserver" description="Stop web server" >
<exec dir="${catalina.home}/bin" executable="cmd.exe">
<env key="CATALINA_HOME" path="${catalina.home}"/>
<arg value="/c shutdown.bat"/>
</exec>
</target>
<!-- **********************************start work********************************** -->
<target name="start" description="Clean build and dist directories, then compile">
<ant target="deploy"/>
<ant target="startserver"/>
</target>
<!-- **********************************reload web server********************************** -->
<target name="reload" description="reload web server">
<ant target="stopserver"></ant>
<sleep seconds="2"></sleep>
<ant target="start"></ant>
</target>
</project>
错误记录:
The processing instruction target matching "[xX][mM][lL]" is not allowed
神奇的错误
原因 因为 ant脚本 build.xml 中第一行为空造成的.