ant


<project name="cmail.webmail" default="compile" xmlns:ivy="antlib:org.apache.ivy.ant">
    <!-- 变量设置 -->
    <property name="lib.dir" value="./web/WEB-INF/lib" />
    <property name="build.dir" value="build" />
    <property name="src.dir" value="src" />
    <property name="dest.dir" value="./web/WEB-INF/lib" />
    <property name="version" value="1.0" />
    <property environment="env"/>
    <property name="java.dir" value="${env.JAVA_HOME}"/>
    <property name="config.dir" value="../testconfig"/>
    
    <property file="build.properties"/>
    <taskdef name="propertyregex" classname="net.sf.antcontrib.property.RegexTask"/>
    
    <!-- ivy 配置信息 -->
    <property name="ivy.settings.dir" value="../ivysettings" />
    <ivy:settings file="${ivy.settings.dir}/ivysettings.xml" />
    
    <!-- paths used for compilation and run  -->
    <path id="lib.path.id">
        <fileset dir="${lib.dir}" />
    </path>

    <!-- 加载依赖的jar包 -->
    <target name="resolve" depends="clean-cache" description="--> retreive dependencies with ivy">
        <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]"/>
    </target>
    
    <target name="resolve2" depends="clean-cache,resolve,delTomcatJar" description="--> retreive dependencies with ivy" />
    
    <!-- 编译 -->
    <target name="compile" depends="resolve, clean" description="--> compile and run the project">
        <mkdir dir="${build.dir}" />
        <javac srcdir="${src.dir}" destdir="${build.dir}" encoding="utf8" classpathref="lib.path.id" includeAntRuntime="false" debug="true">
            <exclude name="test/"/>
        </javac>
        <antcall target="delTomcatJar"/>
    </target>
    
    <!-- 打包 -->
    <target name="jar" depends="compile" description="--> make a jar file for this project">
        <mkdir dir="${dest.dir}" />
        <copy todir="${build.dir}">
            <fileset dir="${src.dir}/">
                <exclude name="**/*.java" />
                <exclude name="**/svn/" />
                <exclude name="test/"/>
                <exclude name="local.properties"/>
                <exclude name="log4j.properties"/>
            </fileset>
        </copy>
        <jar destfile="${dest.dir}/${ant.project.name}.jar">
            <fileset dir="${build.dir}" />
        </jar>
    </target>
    
    
    <!-- 发布产品到ivy仓库 -->
    <target name="publish" depends="jar" description=" publish this project in the ivy repository">
        <delete file="${dest.dir}/ivy.xml" />
        <ivy:publish artifactspattern="${dest.dir}/[artifact].[ext]"
            resolver="projects"
            pubrevision="${version}"
            status="release"
            overwrite="true"
        />
        <echo message="project ${ant.project.name} released with version ${version}" />
    </target>
    
    <!-- 发布产品到ivy仓库 -->
    <target name="publishAll">
        <!--
        <ant antfile="build.xml" dir="../tools" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../rmapi" target="publish" inheritall="false" inheritrefs="false"/>
        -->
        <ant antfile="build.xml" dir="../common" target="publish" inheritall="false" inheritrefs="false"/>
        <!--
        <ant antfile="build.xml" dir="../vasp" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../calendarbc" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../calendarexe" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../disksc" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../diskbc" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../rmcs" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../smap" target="publish" inheritall="false" inheritrefs="false"/>
        -->
        <ant antfile="build.xml" dir="../basemail.common" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../basemail.admin" target="publish" inheritall="false" inheritrefs="false"/>
        <ant antfile="build.xml" dir="../basemail.addr" target="publish" inheritall="false" inheritrefs="false"/>
        <antcall target="publish" />
    </target>
    
    <!-- 删除 tomcat 的依赖包 -->
    <target name="delTomcatJar">
        <delete dir="${lib.dir}">
            <include name="jsp-api-7.0.jar"/>    
            <include name="servlet-api-7.0.jar"/>
        </delete>
    </target>
    
    
    <!-- copy to web project -->
    <target name="copy" description="发布webmail项目">
        <echo>复制项目文件到版本发布目录...</echo>
        <delete dir="${webmail.release.path}" />
        <mkdir dir="${webmail.release.path}" />
        <!-- 复制 webmail 的文件 -->
        <copy todir="${webmail.release.path}" overwrite="true">
            <fileset dir="web" >
                <include name="**/"/>
                <exclude name="**/.svn/**"/>
                <exclude name="**/classes/"/>
                <exclude name="**/.DS_Stoe/**"/>
                <exclude name="**/demo/*"/>
                <exclude name="WEB-INF/log/*"/>
                <exclude name="WEB-INF/conf/*"/>
            </fileset>  
        </copy>
        <copy todir="${webmail.release.path}/WEB-INF/classes" overwrite="true">
            <fileset file="${config.dir}/local.properties"/>
        </copy>
        
        <copy todir="${webmail.release.path}/WEB-INF/lib" overwrite="true">
            <fileset dir="${config.dir}/lib/" excludes="**/.svn/**,**/.DS_Stoe/**"/>
        </copy>
       
    </target>
    
    <!-- 上传cmail_webmail 到研发环境 -->
    <target name="upload_webmail" description="" >
        <echo message="upload to tomcat server ${ssh.webmail.host}" />
        <echo message="${ssh.webmail.username}:${ssh.webmail.password}@${ssh.webmail.host}:${ssh.webmail.path}"/>
        <scp todir="${ssh.webmail.username}:${ssh.webmail.password}@${ssh.webmail.host}:${ssh.webmail.path}" port="${ssh.webmail.port}" trust="true" >
           <fileset dir="${webmail.release.path}" />
        </scp>
    </target>
    
    <!-- 发布webmail -->
    <target name="release" description="release all">
        <!-- 删除发布包目录 -->
        <delete dir="${release.releasePath}" />
        
        <!-- 复制 cmail_rm 的文件 -->
        <!--
        <echo>发布 cmail_rm......</echo>
        <ant antfile="build.xml" dir="../rm" target="copy" inheritall="true" inheritrefs="false"/>
        -->
        <!-- 复制 cmail_resource的文件 -->
        <echo>发布 cmail_resource......</echo>
        <ant antfile="build.xml" dir="../resource" target="copy_to_release" inheritall="true" inheritrefs="false"/>
        <!-- 复制 cmail_webmail 的文件 -->
        <echo>发布 cmail_webmail......</echo>
        <antcall target="copy"/>
        
        <!--
        <echo>复制发布所需要的数据库脚本及文档......</echo>
        <copy todir="${release.releasePath}" overwrite="true">
           <fileset dir="${config.dir}" excludes="**/.svn/**,**/local.properties,**/lib/"/>
        </copy>
        <propertyregex property="release.docs.docVersionName" input="${release.docs.docname}" regexp="#VERSION#" replace="${release.version}" defaultvalue="${release.docs.docname}"/>
        <move file="${release.releasePath}/${release.docs.docname}" tofile="${release.releasePath}/${release.docs.docVersionName}"/>
       
        <echo>创建发布包文件......</echo>
        <zip destfile="${release.releasePath}/${release.version}.zip" basedir="${release.releasePath}" excludes="**/*.doc*,**/*.zip*"/>
         -->
    </target>

    <!-- 清空已编译的class -->
    <target name="clean" description="--> clean the project">
        <delete includeemptydirs="true">
            <fileset dir="${basedir}">
                <include name="${build.dir}/**"/>
            </fileset>
        </delete>
    </target>
    
    
    <!-- 清空ivy缓存,以获得更新的jar包 -->
    <target name="clean-cache" description="--> clean the ivy cache">
        <ivy:cleancache />
    </target>
</project>


<?xml version="1.0"?>
<project name="addr" basedir=".">
    <property name="charset" value="utf-8"/>
    <property name="ftp.res.host" value="192.168.9.202" />
    <property name="ftp.res.username" value="cmail_se" />
    <property name="ftp.res.password" value="cmail_se" />
    <property name="ftp.res.port" value="21" />
    <property name="ftp.res.path" value="/Uploads/addr" />
    <property name="ftp.res.local" value="WebRoot/WEB-INF/lang" />
    <target name="download_lang" description="下载语言包到本地">
        <ftp action="get"
             server="${ftp.res.host}"
             userid="${ftp.res.username}"  port="${ftp.res.port}"
             password="${ftp.res.password}" remotedir="${ftp.res.path}">
            <fileset dir="${ftp.res.local}">
                <include name="**/*.properties"/>
            </fileset>
        </ftp>
    </target>
</project>


  1. <project default="jar" name="Acid">  
  2.     <!-- 工程目录结构  
  3.     project  
  4.         |-bin  
  5.         |-src  
  6.         |-lib  
  7.         |-out  
  8.         |-build.xml  
  9.     -->  
  10.     <property name="lib.dir" value="lib"/>  
  11.     <property name="src.dir" value="src"/>  
  12.     <property name="classes.dir" value="bin"/>  
  13.   
  14.     <property name="output.dir" value="out"/>  
  15.     <property name="jarname" value="Test.jar"/>  
  16.     <property name="mainclass" value="com.biao.Test"/>  
  17.   
  18.     <!-- 第三方jar包的路径 -->  
  19.     <path id="lib-classpath">  
  20.         <fileset dir="${lib.dir}">  
  21.             <include name="**/*.jar"/>  
  22.         </fileset>  
  23.     </path>  
  24.   
  25.     <!-- 1. 初始化工作,如创建目录等 -->  
  26.     <target name="init">  
  27.         <mkdir dir="${classes.dir}"/>  
  28.         <mkdir dir="${output.dir}"/>  
  29.     </target>  
  30.   
  31.     <!-- 2. 编译 -->  
  32.     <target name="compile" depends="init">  
  33.         <javac srcdir="${src.dir}" destdir="${classes.dir}">  
  34.             <compilerarg line="-encoding UTF-8"/>  
  35.             <classpath refid="lib-classpath"/>  
  36.         </javac>  
  37.     </target>  
  38.   
  39.     <!-- 3. 打包jar文件 -->  
  40.     <target name="jar" depends="compile">  
  41.         <copy todir="${output.dir}/lib">  
  42.             <fileset dir="${lib.dir}"/>  
  43.         </copy>  
  44.   
  45.         <!--Create a property containing all .jar files,  
  46.         prefix lib/, and seperated with a space-->  
  47.         <pathconvert property="mf.classpath" pathsep=" ">  
  48.             <mapper>  
  49.                 <chainedmapper>  
  50.                     <!-- jar包文件只留文件名,去掉目录信息 -->  
  51.                     <flattenmapper/>  
  52.                     <!-- add lib/ prefix -->  
  53.                     <globmapper from="*" to="lib/*"/>  
  54.                 </chainedmapper>  
  55.             </mapper>  
  56.             <path refid="lib-classpath"/>  
  57.          </pathconvert>  
  58.   
  59.         <!-- jar文件的输出路径 -->  
  60.         <jar destfile="${output.dir}/${jarname}" basedir="${classes.dir}">  
  61.             <manifest>  
  62.                 <attribute name="Main-class" value="${mainclass}"/>  
  63.                 <attribute name="Class-Path" value="${mf.classpath}"/>  
  64.             </manifest>  
  65.         </jar>  
  66.     </target>  
  67. </project> 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值