当前位置:编程学习 > XML/UML >>

ant build.xml demo

<?xml version="1.0" encoding="UTF-8"?>
<project name="lb" default="main" basedir=".">
 <property file="resouces.properties" />
 <property name="src.dir" value="${basedir}/src"/>
 <property name="build.dir" value="${basedir}/build"/>
 <property name="build.classes.dir" value="${build.dir}/classes"/>
 <property name="build.lib.dir" value="${build.dir}/lib"/>
 <property name="lib.dir" value="${basedir}/lib"/>
 <property name="dist.dir" value="${basedir}/dist"/>
 <property name="web.dir" value="${basedir}/web"/>
 <property name="deploy.dir" value="${tomcat.home}/webapps"></property>
 <property name="app" value="lb"/>
 
 <property name="javac.target" value="1.5" />
 <property name="javac.source" value="1.5" />
 <property name="debug" value="true" />
 <property name="deprecation" value="false" />
 <property name="optimize" value="true" />
 
 <patternset id="respository.files">
  <include name="org/springsource/spring-framework-3.0.5.RELEASE/dist/org.springframework.aop-3.0.5.RELEASE.jar"/>
  <include name="org/springsource/spring-framework-3.0.5.RELEASE/dist/org.springframework.beans-3.0.5.RELEASE.jar"/>
  <include name="org/springsource/spring-framework-3.0.5.RELEASE/dist/org.springframework.context-3.0.5.RELEASE.jar"/>
  <include name="org/springsource/spring-framework-3.0.5.RELEASE/dist/org.springframework.core-3.0.5.RELEASE.jar"/>
  <include name="org/springsource/spring-framework-3.0.5.RELEASE/dist/org.springframework.expression-3.0.5.RELEASE.jar"/>
  <include name="org/springsource/spring-framework-3.0.5.RELEASE/dist/org.springframework.web-3.0.5.RELEASE.jar"/>
  <include name="org/springsource/spring-framework-3.0.5.RELEASE/dist/org.springframework.web.servlet-3.0.5.RELEASE.jar"/>
  <include name="com/mchange/c3p0/0.9.1/c3p0-0.9.1.jar"/>
  <include name="com/mysql/jdbc/5.1.21/mysql-connector-java-5.1.21-bin.jar"/>
  <include name="taglibs/standard/1.1.2/standard-1.1.2.jar"/>
  <include name="javax/servlet/jstl/1.1.2/jstl-1.1.2.jar"/>
 </patternset>
 
 <path id="master-classpath">
  <fileset dir="${lib.dir}">
   <include name="*.jar"/>
  </fileset>
  <fileset dir="${tomcat.home}/lib">
   <include name="servlet*.jar"/>
  </fileset>
  <pathelement path="${build.classes.dir}"/>
 </path>
 
 <target name="main" depends="init, getRespositoryFiles, compile, war">
 </target>
 
 <target name="compile" depends="init">
  <echo>Building...</echo>
  <javac srcdir="${src.dir}"
      destdir="${build.classes.dir}"
      debug="${debug}"
      target="${java.comp.level}"
      source="${java.comp.level}"
      deprecation="on"
      optimize="${optimize}"
      failonerror="true"
      fork="true"
      executable="${javac.exe}"
      memoryinitialsize="128m"
      memorymaximumsize="256m">
   <classpath refid="master-classpath"></classpath>
  </javac>
 </target>
 
 <target name="init">
  <property environment="env"></property>
  <property name="java.comp.level" value="1.6" />
  <property name="javac.exe" value="${env.JAVA_HOME}/bin/javac.exe" />
 </target>
 
 <target name="getRespositoryFiles" >
  <copy todir="${lib.dir}" verbose="true">
   <fileset dir="${basedir}/../../REPOSITORY/">
    <patternset refid="respository.files"></patternset>
   </fileset>
   <mapper type="flatten"></mapper>
  </copy>
 </target>
 
 <target name="clean" description="Initialize build and dist folders">
  <delete dir="${build.dir}" />
  <delete dir="${dist.dir}" />
  <delete dir="${lib.dir}" />
  <mkdir dir="${build.dir}"/>
  <mkdir dir="${build.classes.dir}"/>
  <mkdir dir="${build.lib.dir}"/>
  <mkdir dir="${lib.dir}" />
 </target>
 
 <target name="war">
  <echo>Archiving...</echo>
  <mkdir dir="${dist.dir}"/>
  <copydir dest="${build.lib.dir}" src="${lib.dir}" />
  <war destfile="${dist.dir}/${app}.war" webxml="${web.dir}/WEB-INF/web.xml">
   <lib dir="${build.lib.dir}"></lib>
   <classes dir="${build.classes.dir}"></classes>
   <fileset dir="${web.dir}">
    <include name="**/*.*"/>
   </fileset>
  </war>
 </target>
 
 <target name="copyWar" depends="war">
  <echo>Deploy...</echo>
  <copy todir="${deploy.dir}">
   <fileset dir="./${dist.dir}">
    <include name="*.war"/>
   </fileset>
  </copy>
 </target>

</project>

补充:软件开发 , Delphi ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,