<?xml version="1.0"?> <project name="dxcc" default="buildplugins" basedir=".."> <property name="build.lib.dir" value="${basedir}/build/lib"/> <property name="target.dir" value="${basedir}/target"/> <property name="deploy.dir" value="${basedir}/deploy"/> <property name="target.plugins.dir" value="${basedir}/target/plugins"/> <property name="lib.web.dir" value="${basedir}/WebRoot/WEB-INF/lib"/> <property name="plugin.src.dir" value="${basedir}/src/plugins" /> <property name="compile.dir" value="${basedir}/WebRoot/WEB-INF/classes" /> <property name="localdeploy.dir" value="E:/apache-tomcat-7.0.63-dxcc/webapps/dxcc/plugins" /> <taskdef resource="net/sf/antcontrib/antlib.xml"><!-- 需要将ant-contrib.jar文件加到myeclipse配置ant类路径下 --> <classpath> <pathelement location="${basedir}/build/lib/ant-contrib.jar"/> </classpath> </taskdef> <path id="compile.dependencies"> <fileset dir="${build.lib.dir}" includes="rt.jar,servlet.jar"/> <fileset dir="${lib.web.dir}" includes="**/*.jar"/> <pathelement location="${compile.dir}"/> </path> <!-- clean ================================================================================== --> <target name="clean"> <delete dir="${target.dir}"/> <delete dir="${deploy.dir}"/> <!-- <delete dir="${localdeploy.dir}"/>--> </target> <!-- init ================================================================================== --> <target name="init" depends="clean"> <mkdir dir="${target.dir}"/> <mkdir dir="${deploy.dir}"/> <mkdir dir="${target.plugins.dir}"/> </target> <!-- build all plugins in plugins src folder ================================================ --> <target name="buildplugins" depends="anttasks,init" description="遍历插件文件夹"> <subdirinfo dir="${plugin.src.dir}" property="dirlist" ifexists="plugin.xml" except="admin" /> <for list="${dirlist}" param="plugin" trim="true"> <sequential> <buildplugin plugin="@{plugin}" pluginsrc="${plugin.src.dir}"/> </sequential> </for> </target> <!-- anttasks ============================================================================== --> <target name="anttasks" description="自定义ant遍历目录接口"> <taskdef name="subdirinfo" classname="org.jivesoftware.ant.SubDirInfoTask"> <classpath> <pathelement location="${basedir}/build/lib/ant-subdirtask.jar" /> </classpath> </taskdef> </target> <!-- localdeploy =========================================================================== --> -----------------部署全部插件 <target name="localdeploy" depends="anttasks,init" description="本地部署"> <subdirinfo dir="${plugin.src.dir}" property="dirlist" ifexists="plugin.xml" except="admin" /> <for list="${dirlist}" param="plugin" trim="true"> <sequential> <deployplugin plugin="@{plugin}" pluginsrc="${plugin.src.dir}"/> </sequential> </for> </target>
<target name="amobile" depends="anttasks,init" description="遍历插件文件夹"> -----------------------部署指定插件
<deployplugin plugin="oa" pluginsrc="${plugin.src.dir}"/>
<deployplugin plugin="websites" pluginsrc="${plugin.src.dir}"/>
<deployplugin plugin="salary" pluginsrc="${plugin.src.dir}"/>
<deployplugin plugin="newResearch" pluginsrc="${plugin.src.dir}"/>
<deployplugin plugin="cloud" pluginsrc="${plugin.src.dir}"/>
<deployplugin plugin="thesis" pluginsrc="${plugin.src.dir}"/>
<deployplugin plugin="tmprt_check_sys" pluginsrc="${plugin.src.dir}"/>
<deployplugin plugin="sam" pluginsrc="${plugin.src.dir}" />
<deployplugin plugin="boh_sys" pluginsrc="${plugin.src.dir}" />
<deployplugin plugin="periodical" pluginsrc="${plugin.src.dir}" />
</target>
<!-- deployplugin (MACRO) =================================================================== --> <macrodef name="deployplugin" description="建立插件宏"> <attribute name="plugin"/> <attribute name="pluginsrc"/> <sequential> <copy todir="${localdeploy.dir}/@{plugin}" overwrite="true"> <fileset dir="@{pluginsrc}/@{plugin}"> <include name="**/*.*"/> <exclude name="src/**/*.*"/> </fileset> </copy> </sequential> </macrodef> <!-- buildplugin (MACRO) =================================================================== --> <macrodef name="buildplugin" description="建立插件宏"> <attribute name="plugin"/> <attribute name="pluginsrc"/> <sequential> <mkdir dir="${target.plugins.dir}/@{plugin}/classes"/> <mkdir dir="${target.plugins.dir}/@{plugin}/lib"/> <mkdir dir="${target.plugins.dir}/@{plugin}/web"/> <!-- Compile java classes --> <javac destdir="${target.plugins.dir}/@{plugin}/classes" includeAntRuntime="no" debug="on" source="1.6" target="1.6" > <compilerarg line="-encoding UTF-8 "/> <src path="@{pluginsrc}/@{plugin}/src/java"/> <classpath> <path refid="compile.dependencies"/> <!-- Jars used by the plugin to compile with --> <fileset dir="@{pluginsrc}/@{plugin}" includes="lib/*.jar"/> </classpath> </javac> <!-- Jar the plugin --> <jar jarfile="${target.plugins.dir}/@{plugin}/lib/@{plugin}.jar"> <fileset dir="${target.plugins.dir}/@{plugin}/classes"/> </jar> <!-- copy the plugin --> <copy todir="${target.plugins.dir}/@{plugin}" overwrite="true"> <fileset dir="@{pluginsrc}/@{plugin}"> <include name="**/*.*"/> <exclude name="src/**/*.*"/> </fileset> </copy> <!-- Jar the plugin for deploy --> <jar jarfile="${deploy.dir}/@{plugin}.jar"> <fileset dir="${target.plugins.dir}/@{plugin}"> <include name="**/*.*"/> <exclude name="classes/**/*.*"/> </fileset> </jar> </sequential> </macrodef> </project>