不信网恋 发表于 2018-1-7 12:46:26

Jenkins + Ant + Git + Tomcat自动化部署

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>  
<project name=&quot;palace&quot; default=&quot;compile&quot; basedir=&quot;.&quot;>
  
<property name=&quot;tomcat.lib&quot; value=&quot;/usr/local/apache-tomcat-8.0.24/lib&quot; />
  
<property name=&quot;dest.dir&quot; value=&quot;WEB-INF/classes&quot; />
  
<property name=&quot;src.dir&quot; value=&quot;src&quot; />
  
<!-- 定义属性,打成war包的名称。 -->
  
<property name=&quot;warFileName&quot; value=&quot;palace.war&quot;></property>
  
<target name=&quot;init&quot;>
  
<mkdir dir=&quot;${dest.dir}&quot; />
  
</target>
  
<target name=&quot;compile&quot; depends=&quot;init&quot;>
  
<javac srcdir=&quot;${src.dir}&quot; destdir=&quot;${dest.dir}&quot;>
  
<classpath>
  
<fileset dir=&quot;${tomcat.lib}&quot;>
  
<include name=&quot;*.jar&quot; />
  
</fileset>
  
<fileset dir=&quot;WebContent/WEB-INF/lib&quot;>
  
<include name=&quot;*.jar&quot; />
  
</fileset>
  
</classpath>
  
</javac>
  
</target>
  

  
<!-- 定义默认任务,将class文件集合成jar包。 -->
  
<target name=&quot;war&quot; depends=&quot;compile&quot;>
  
<!-- 删除原有war包。 -->
  
<delete dir=&quot;${basedir}/${warFileName}&quot; />
  
<!-- 建立新war包。 -->
  
<war destfile=&quot;${basedir}/${warFileName}&quot; webxml=&quot;${basedir}/WebContent/WEB-INF/web.xml&quot;>
  
<!-- 将非jar和非class文件拷贝到war包的对应路径下。 -->
  
<fileset dir=&quot;${basedir}/WebContent&quot;>
  
<include name=&quot;**/**.*&quot; />
  
<exclude name=&quot;**/*.jar&quot;/>
  
<exclude name=&quot;**/*.class&quot;/>
  
</fileset>
  
<!-- 将jar和class文件拷贝到war包的对应路径下。 -->
  
<lib dir=&quot;${basedir}/WebContent/WEB-INF/lib&quot; />
  
<classes dir=&quot;${dest.dir}&quot; />
  
</war>
  
</target>
  

  
<target name=&quot;clean&quot;>
  
<delete dir=&quot;${dest.dir}&quot; />
  
</target>
  
</project>
页: [1]
查看完整版本: Jenkins + Ant + Git + Tomcat自动化部署