ant脚本下载svn并自动化编译

参考链接 http://blog.csdn.net/rose19891213/article/details/6085899

http://blog.csdn.net/zh2qiang/article/details/6795823

忙了两个多小时终于把最困难的地方给过去了,直接贴代码

<?xml version="1.0" encoding="gb2312"?> 
 
<!-- binding svnkit --> 
<project basedir="." name="cowork" default="svncheckout"> 
  <property name="destPath" value="${basedir}" /> 
 
  <property name="svn.username" value="11" />
  <property name="svn.password" value="11" />
  <property name="svnurl" value="https://9.123.195.191/svn/APEducation/trunk" />
 
  <path id="path.svnant"> 
    <fileset dir="${basedir}"> 
      <include name="**/*.jar"/> 
    </fileset> 
  </path> 
  <echo>导出目录${destPath}</echo>
  <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant"/> 
  <target name="svncheckout" > 
    <svnSetting id="svnparams" username="${svn.username}" password="${svn.password}" javahl="false" svnkit="true"/> 
    <svn refid="svnparams"> 
      <checkout url="${svnurl}" destPath="${destPath}" /> 
    </svn> 
  </target> 
</project>

<?xml version="1.0" ?>
<project name="hp" default="war">
 <property name="dir" value="C:\project\workspace\APEducation" />
 <property name="WebContent" value="C:\project\workspace\APEducation\WebRoot" />
 <property name="dist" value="C:\temp" />
 <property name="warDest" value="wardest" />
 <property name="classDest" value="class" />
 <property name="source-encoding" value="UTF-8" />
 <property name="warName" value="APEDU.war"/>

   



 <!--编译java源文件所需的jar文件 -->
 <path id="build-classpath">
  <fileset dir="${dir}\WebRoot\WEB-INF\lib">
   <include name="*.jar" />
  </fileset>
 </path>
 
 <!--清理-->
 <target name="clean">
  <delete dir="${dist}" />
 </target>
 
 <!-- 初始化,建立相关的文件夹-->
 <target name="init">
  <mkdir dir="${dist}"/>
  <mkdir dir="${dist}/${warDest}" />
  <mkdir dir="${dist}/${classDest}" />
 </target>
 
 <!-- 编译java源文件并拷贝到相应的文件夹-->
 <target name="compile" depends="init">
  <javac srcdir="${dir}/src" destdir="${dist}/${classDest}"  target="1.6"
   classpathref="build-classpath" encoding="${source-encoding}"
   debug="true" debuglevel="source,lines,vars"  includeantruntime="on">
  </javac>
 </target>
 
 <!--拷贝WebRoot文件到相应的文件夹-->
 <target name="copy">
  <copy todir="${dist}/${warDest}">
   <fileset dir="${dir}/WebRoot">
    <exclude name="**/*.jar"/>
   </fileset>
  </copy>
  <copy todir="${dist}/${classDest}">
   <fileset dir="${dir}/src">
    <exclude name="**/*.java"/>
   </fileset>
  </copy>
  
  <!--拷贝部署用的配置文件-->
  <!--delete file="${dist}/${warDest}/WEB-INF/config/log4j.properties"/>
  <move file="${dist}/${warDest}/WEB-INF/config/log4j.build.properties"
   tofile="${dist}/${warDest}/WEB-INF/config/log4j.properties" />
  <delete file="${dist}/${warDest}/WEB-INF/web.xml"/>
  <move file="${dist}/${warDest}/WEB-INF/web.build.xml"
   tofile="${dist}/${warDest}/WEB-INF/web.xml" />
  <delete file="${dist}/${warDest}/META-INF/context.xml"/>
   <move file="${dist}/${warDest}/META-INF/context.build.xml"
    tofile="${dist}/${warDest}/META-INF/context.xml" /-->
 </target>
 
 <!--打包-->
 <target name="war" depends="compile, copy">
  <war destfile="${dist}/${warName}" webxml="${dir}/WebRoot/WEB-INF/web.xml">
   <fileset dir="${dist}/${warDest}" />
   <!--
   <lib dir="${dir}/WebRoot/WEB-INF/lib"/>
   -->
   <classes dir="${dist}/${classDest}"></classes>
  </war>
  <delete dir="${dist}/${warDest}"></delete>
  <delete dir="${dist}/${classDest}"></delete>
 </target>
 
</project>

 有空再整理一下,先睡觉了

猜你喜欢

转载自lxneliu.iteye.com/blog/1634666