博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ant + svn 自动部署项目
阅读量:4040 次
发布时间:2019-05-24

本文共 4336 字,大约阅读时间需要 14 分钟。

Java代码  
  1. build.properties  
  2.   
  3. # -----------------------------------------------------------------------------  
  4. # build.properties  
  5. # This file is referenced by the sample build.xml file.  
  6. # -----------------------------------------------------------------------------  
  7.   
  8. build.version=1.0.0  
  9.    
  10. #you need these jars  
  11. svnant.jar=/usr/local/ant/lib/svnant.jar  
  12. svnClientAdapter.jar=/usr/local/ant/lib/svnClientAdapter.jar  
  13. svnjavahl.jar=/usr/local/ant/lib/svnjavahl.jar  
  14. javaEE.lib=/opt/tomcat-7/lib  
  15.    
  16. #tomcat information  
  17. #tomcat home  
  18. tomcat.home=/opt/tomcat-7  
  19. #tomcat project deploy dir                
  20. tomcat.deploy=${tomcat.home}/webapps/${ant.project.name}  
  21.    
  22. debuglevel=source,lines  
  23. target=1.6  
  24. source=1.6  
  25.    
  26. work.space=/tmp/project  
  27.    
  28. build.dir=${work.space}/WebRoot/WEB-INF/classes  
  29. lib.dir=${work.space}/WebRoot/WEB-INF/lib  
  30.    
  31. java.source=${work.space}/src  
  32. java.config=${work.space}/config  
  33.    
  34. web.dir=${work.space}/WebRoot  
  35. resource.dir=${work.space}/resources  
  36.   
  37. zip.file=${tomcat.deploy}/${ant.project.name}.zip  
  38.    
  39. #project information in SVN   
  40. urlRepos=svn://192.168.1.114/project/lottery  
  41. svn.user=xxx  
  42. svn.passwd=xxxx  
  43.   
  44.   
  45. build.xml  
  46.   
  47. <?xml version="1.0" encoding="UTF-8"?>  
  48. <project basedir="." name="lottery" default="auto">  
  49.  <!--  all properties are in build.properties -->  
  50.  <property file="build.properties" />  
  51.  <!-- svn runtime libs -->  
  52.  <path id="svnant.lib">    
  53.          <pathelement location="${svnjavahl.jar}" />    
  54.          <pathelement location="${svnant.jar}" />    
  55.          <pathelement location="${svnClientAdapter.jar}" />    
  56.  </path>    
  57.  <!--java EE  库 -->    
  58.      <path id="javaEE">    
  59.          <fileset dir="${javaEE.lib}">    
  60.              <include name="**/*.jar" />    
  61.          </fileset>    
  62.      </path>    
  63.   
  64.  <!-- load the libs in classpath -->  
  65.  <path id="project.classpath">  
  66.  <pathelement location="${build.dir}"/>  
  67.  <fileset dir="${lib.dir}"/>  
  68.  </path>  
  69.    
  70.  <!-- clean up -->  
  71.   
  72.  <target name="clear">  
  73.  <delete dir="${work.space}"></delete>  
  74.  <delete dir="${tomcat.home}/work/Catalina/localhost/${ant.project.name}"></delete>  
  75.  <delete dir="${tomcat.deploy}/${ant.project.name}"></delete>  
  76.  <delete dir="${tomcat.deploy}/${ant.project.name}.war"></delete>  
  77.  </target>  
  78.  <!-- load the svn task -->  
  79.  <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classdata-path="svnant.jar" />  
  80.  <svnSetting id="svn.settings" javahl="false" svnkit="true" username="${svn.user}" password="${svn.passwd}" />  
  81.   
  82.  <!--svn checkout-->  
  83.  <target name="svn" depends="clear">  
  84.  <mkdir dir="${work.space}"/>  
  85.  <svn refid="svn.settings">  
  86.  <checkout url="${urlRepos}" destdata-path="${work.space}" />  
  87.  </svn>  
  88.  </target>  
  89.  <!--compile the project-->  
  90.    
  91.  <target name="compile" depends="svn" description="----------compile ${ant.project.name}-----------">  
  92.  <echo message="----------compile ${ant.project.name}:${ant.file}-----------"></echo>  
  93.  <mkdir dir="${build.dir}"/>  
  94.  <copy includeemptydirs="false" todir="${build.dir}">  
  95.  <fileset dir="${java.source}" excludes="**/*.launch, **/*.java"></fileset>  
  96.  <fileset dir="${java.config}" excludes="**/*.launch, **/*.java"></fileset>  
  97.  </copy>  
  98.    
  99.  <javac  includeantruntime="false" includejavaruntime="true" debug="true" debuglevel="${debuglevel}" destdir="${build.dir}" source="${source}" target="${target}" encoding="utf-8">    
  100.              <src data-path="${java.source}" />    
  101.              <exclude name="config/"/>    
  102.              <classpath>    
  103.                  <path refid="project.classpath">    
  104.                  </path>    
  105.                  <path refid="javaEE">    
  106.                  </path>    
  107.      
  108.              </classpath>    
  109.              <compilerarg value="-Xlint:unchecked"/>    
  110.          <compilerarg value="-Xlint:deprecation"/>    
  111.      </javac>  
  112.    
  113.  </target>  
  114.  <!--compress and pack -->  
  115.  <!--deploy to the tomcat project dir-->  
  116.     <target name="deploy" depends="compile">  
  117.      <mkdir dir="${tomcat.home}/webapps/${ant.project.name}"/>  
  118.      <zip destfile="${zip.file}">  
  119.           <zipfileset dir="${web.dir}"/>  
  120.      </zip>  
  121.      <unzip dest="${tomcat.home}/webapps/${ant.project.name}" overwrite="true" src="${zip.file}"/>  
  122.        
  123.  </target>  
  124.    
  125.  <!--shutdowntomcat-->  
  126.   
  127.  <target name="shutdowntomcat" description="========shutdowntomcat===========">  
  128.  <exec executable="${tomcat.home}/bin/shutdown.sh" failοnerrοr="false">  
  129.  </exec>  
  130.  <sleep seconds="10" />  
  131.  </target>  
  132.  <!--startuptomcat-->  
  133.   
  134.  <target name="startuptomcat" description="========startuptomcat===========">  
  135.  <sleep seconds="5" />  
  136.  <exec executable="${tomcat.home}/bin/startup.sh" failοnerrοr="true" >  
  137.  </exec>  
  138.  </target>  
  139.   
  140.  <!--Done,restart tomcat-->  
  141.   
  142.  <target name="auto" depends="shutdowntomcat,deploy,startuptomcat">  
  143.  <echo message="All DONE!!!!" />  
  144.  </target>  
  145. </project>  

 

  在安装了ant的环境下面运行 build.xml

 

上面的tomcat的目录需要自己制定,svn的信息也需要自己设定,配置信息都在build.properties文件中

转载地址:http://chen106106.iteye.com/blog/1912426

你可能感兴趣的文章
qt5 everywhere编译完成后,找不到qmake
查看>>
qt 创建异形窗体
查看>>
可重入函数与不可重入函数
查看>>
简单Linux C线程池
查看>>
内存池
查看>>
输入设备节点自动生成
查看>>
GNU hello代码分析
查看>>
Qt继电器控制板代码
查看>>
wpa_supplicant控制脚本
查看>>
gstreamer相关工具集合
查看>>
RS232 四入四出模块控制代码
查看>>
gstreamer插件之 videotestsrc
查看>>
linux 驱动开发 头文件
查看>>
/etc/resolv.conf
查看>>
container_of()传入结构体中的成员,返回该结构体的首地址
查看>>
linux sfdisk partition
查看>>
ipconfig,ifconfig,iwconfig
查看>>
opensuse12.2 PL2303 minicom
查看>>
网络视频服务器移植
查看>>
Encoding Schemes
查看>>