<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>
- <project default="jar" name="Acid">
- <!-- 工程目录结构
- project
- |-bin
- |-src
- |-lib
- |-out
- |-build.xml
- -->
- <property name="lib.dir" value="lib"/>
- <property name="src.dir" value="src"/>
- <property name="classes.dir" value="bin"/>
- <property name="output.dir" value="out"/>
- <property name="jarname" value="Test.jar"/>
- <property name="mainclass" value="com.biao.Test"/>
- <!-- 第三方jar包的路径 -->
- <path id="lib-classpath">
- <fileset dir="${lib.dir}">
- <include name="**/*.jar"/>
- </fileset>
- </path>
- <!-- 1. 初始化工作,如创建目录等 -->
- <target name="init">
- <mkdir dir="${classes.dir}"/>
- <mkdir dir="${output.dir}"/>
- </target>
- <!-- 2. 编译 -->
- <target name="compile" depends="init">
- <javac srcdir="${src.dir}" destdir="${classes.dir}">
- <compilerarg line="-encoding UTF-8"/>
- <classpath refid="lib-classpath"/>
- </javac>
- </target>
- <!-- 3. 打包jar文件 -->
- <target name="jar" depends="compile">
- <copy todir="${output.dir}/lib">
- <fileset dir="${lib.dir}"/>
- </copy>
- <!--Create a property containing all .jar files,
- prefix lib/, and seperated with a space-->
- <pathconvert property="mf.classpath" pathsep=" ">
- <mapper>
- <chainedmapper>
- <!-- jar包文件只留文件名,去掉目录信息 -->
- <flattenmapper/>
- <!-- add lib/ prefix -->
- <globmapper from="*" to="lib/*"/>
- </chainedmapper>
- </mapper>
- <path refid="lib-classpath"/>
- </pathconvert>
- <!-- jar文件的输出路径 -->
- <jar destfile="${output.dir}/${jarname}" basedir="${classes.dir}">
- <manifest>
- <attribute name="Main-class" value="${mainclass}"/>
- <attribute name="Class-Path" value="${mf.classpath}"/>
- </manifest>
- </jar>
- </target>
- </project>