使用build.xml的实例

 <?xml version="1.0"?>
<project name="gsbc1.3" basedir="." default="usage">
 <property file="build.properties"/>
 <property name="name" value="gsbc"/>
 <property name="version" value="1.3"/>
 <property name="dist.name" value="${name}${version}"/>
 <property name="dist.dir" value="dist"/>
 <property name="dist.tar.dir" value="${dist.dir}/${dist.name}"/>

 <property name="project.dir" value="project"/>
 <property name="src.dir" value="src/java"/>

 <property name="src.daemon.dir" value="daemon/${src.dir}"/>
 <property name="lib.dir" value="daemon/lib"/>
 
 <property name="dist.bin.dir" value="${dist.tar.dir}/daemon/bin"/>
 <property name="dist.lib.dir" value="${dist.tar.dir}/daemon/lib"/>
 <property name="dist.conf.dir" value="${dist.tar.dir}/daemon/conf"/>
 <property name="dist.version.dir" value="${dist.tar.dir}/version"/> 

 <property name="build.dir" value="build"/>
 <property name="build.lib.dir" value="${build.dir}/daemon/lib"/>
 <property name="build.daemon.class.dir" value="${build.dir}/daemon/classes"/>
 
 <property name="src.conf.dir" value="daemon/conf"/>
 <property name="src.bin.dir" value="daemon/bin"/>
 <property name="src.version.dir" value="daemon/version"/>

 <property name="jar.daemon" value="${name}-${version}.jar"/>

 <property name="gsbc.home.path" location="${basedir}"/>
 
 <path id="master-classpath">
  <fileset dir="${lib.dir}">
   <include name="*.jar"/>
  </fileset>
 </path>

 <target name="usage">
  <echo message=""/>
  <echo message="GSBC1.3 build file"/>
  <echo message="------------------------------------------------------"/>
  <echo message=""/>
  <echo message="Available targets are:"/>
  <echo message=""/>
  <echo message="clean    --> Clean output dirs"/>
  <echo message="all      --> clean, jarfile"/>
 </target>

 <target name="clean" description="Clean output dirs (build, dist)">
  <delete dir="${build.dir}"/>
  <delete dir="${dist.dir}"/>
 </target>
 
 <target name="daemon_jar"  description="Compile daemon, generate jar files">
  <mkdir dir="${build.dir}"/>
  <mkdir dir="${build.lib.dir}"/>
  <mkdir dir="${build.daemon.class.dir}"/>
  
  <javac destdir="${build.daemon.class.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
   <src path="${src.daemon.dir}"/>
   <classpath>
    <path refid="master-classpath"/>
    <pathelement location="${build.daemon.class.dir}"/>
   </classpath>
  </javac>

  <jar jarfile="${build.lib.dir}/${jar.daemon}" compress="true">
   <fileset dir="${build.daemon.class.dir}" includes="com/webex/**"/>
  </jar>
 </target>


 <target name="all" depends="clean,dist" description="clean,dist"/>

 <target name="create.dist.dir" description="create all dist dir">
  <mkdir dir="${dist.dir}"/>
  <mkdir dir="${dist.tar.dir}"/>
  <mkdir dir="${dist.tar.dir}/version"/>
  
  <copy todir="${dist.lib.dir}" preservelastmodified="true">
   <fileset dir="${build.lib.dir}">
    <include name="gsbc-1.3.jar" />
   </fileset>   
  </copy> 
  <copy todir="${dist.bin.dir}" preservelastmodified="true">
   <fileset dir="${src.bin.dir}">
    <include name="gsbc-report.sh" />
    <include name="gsbc-daemon.sh" />
   </fileset>   
  </copy>
  <copy todir="${dist.conf.dir}" preservelastmodified="true">
   <fileset dir="${src.conf.dir}">
    <include name="daemon-context.xml" />
    <include name="report-context.xml" />
   </fileset>   
  </copy>
  <copy todir="${dist.version.dir}" preservelastmodified="true">
   <fileset dir="${src.version.dir}">
    <include name="gsbc1.3.txt" />
   </fileset>   
  </copy>
 </target>
 
 <!--
   Create tar package of Connect GSBv1.3
 --> 
 <target name="dist" depends="daemon_jar">
  
  <antcall inheritAll="true" target="create.dist.dir" />  
  
  <!-- install shell and document and other binary content -->
  <tar longfile="gnu"
      destfile="${dist.dir}/${name}${version}.tar" basedir="${dist.dir}">
      <tarfileset dir="${dist.tar.dir}" mode="777" username="root" group="root">
       <include name="${dist.tar.dir}/daemon/bin/*"/>
      </tarfileset>
       
   <!-- all other files -->
   <tarfileset dir="${dist.tar.dir}" dirmode="755" username="root" group="root">
          <include name="${dist.tar.dir}/daemon/lib/*"/>
          <include name="${dist.tar.dir}/daemon/conf/*"/>
          <include name="${dist.tar.dir}/version/*"/>
   </tarfileset>
   
  </tar>
  

 </target>

</project>

你可能感兴趣的:(使用build.xml的实例)