ANT 打包 配置文件 build.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<project basedir="." default="run_batch" name="AbsPackage">
	
	<property name="encoding" value="UTF-8" />
	<property name="ant.package" value="/ANT_PACKAGE"/>
	<property name="expand_jar" value="/ant_jar"/>
	<property name="abswar_name" value="absbank"/>
	<property name="absbatch_name" value="AbsBank_Batch"></property>
	<!-- 源-->
    <property environment="env"/>
    <property name="joyinframework.location" value="../joyinframework"/>
    <property name="com.joyintech.core.location" value="../com.joyintech.core"/>
    <property name="com.joyintech.entity.location" value="../com.joyintech.entity"/>
    <property name="com.joyintech.accounting.location" value="../com.joyintech.accounting"/>
	<property name="com.joyintech.batch.location" value="../com.joyintech.batch"/>
	<property name="absear.location" value="../absear"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.6"/>
    <property name="source" value="1.6"/>
	
	<property name="zssapp.location" value="../zssapp"/>
	
	<!-- 目标-->
	<property name="abs.target" value="${ant.package}/ABSBANK"/>
	<property name="joyinframework.target" value="${abs.target}/joyinframework"/>
    <property name="com.joyintech.core.target" value="${abs.target}/com.joyintech.core"/>
    <property name="com.joyintech.entity.target" value="${abs.target}/com.joyintech.entity"/>
    <property name="com.joyintech.accounting.target" value="${abs.target}/com.joyintech.accounting"/>
	<property name="com.joyintech.batch.target" value="${abs.target}/com.joyintech.batch"/>
	<property name="zssapp.target" value="${abs.target}/zssapp"/>
	
    <path id="expand.jar">
    	<fileset dir="${expand_jar}">
    	    <include name="**/*.jar" />
    	</fileset>
    </path>
	
    <path id="libraryclasspath">
    	<fileset dir="${joyinframework.target}/WEB-INF/lib/">
    		<include name="**/*.jar" />
    	</fileset>
    </path>
	
	<path id="classpath">
        <path refid="expand.jar"/>
        <path refid="libraryclasspath"/>
    </path>
	
	<path id="classpathForZssapp">
		<fileset dir="${zssapp.target}/WEB-INF/lib/">
		    <include name="**/*.jar" />
		</fileset>
		<path refid="expand.jar"/>
	</path>
	
	<!--初始化 -->
    <target name="init" depends="clean">
    	
    	<mkdir dir="${abs.target}"/>
    	<mkdir dir="${joyinframework.target}"/>
    	
    	<copy todir="${joyinframework.target}" overwrite="yes">
		     <fileset dir="${joyinframework.location}/WebContent"></fileset>
		</copy>
        <mkdir dir="${joyinframework.target}/WEB-INF/classes"/>
        <copy includeemptydirs="false" todir="${joyinframework.target}/WEB-INF/classes">
            <fileset dir="${joyinframework.location}/src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    	
    	<mkdir dir="${com.joyintech.core.target}"/>
        <copy includeemptydirs="false" todir="${com.joyintech.core.target}">
            <fileset dir="${com.joyintech.core.location}/src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
        	</fileset>
    	</copy>
    	
    	<mkdir dir="${com.joyintech.entity.target}"/>
        <copy includeemptydirs="false" todir="${com.joyintech.entity.target}">
            <fileset dir="${com.joyintech.entity.location}/src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
        	</fileset>
    	</copy>
    	
    	<mkdir dir="${com.joyintech.accounting.target}"/>
        <copy includeemptydirs="false" todir="${com.joyintech.accounting.target}">
            <fileset dir="${com.joyintech.accounting.location}/src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
        	</fileset>
    	</copy>
    	
    	<mkdir dir="${com.joyintech.batch.target}"/>
        <copy includeemptydirs="false" todir="${com.joyintech.batch.target}">
            <fileset dir="${com.joyintech.batch.location}/src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
        	</fileset>
    	</copy>
    	
    	<mkdir dir="${zssapp.target}"/>
    	<copy todir="${zssapp.target}" overwrite="yes">
		     <fileset dir="${zssapp.location}/WebContent"></fileset>
		</copy>
        <mkdir dir="${zssapp.target}/WEB-INF/classes"/>
        <copy includeemptydirs="false" todir="${zssapp.target}/WEB-INF/classes">
            <fileset dir="${zssapp.location}/src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
    	</copy>
    	
    </target>
	
    <target name="clean">
    	<echo message="delete document ----${abs.target}----"></echo>
        <delete dir="${abs.target}"/>
    </target>
	
	<target  name="build_core" depends="init">
	        <echo message="${ant.project.name}: ${ant.file}"/>
	        <javac debug="true" debuglevel="${debuglevel}" destdir="${com.joyintech.core.target}" encoding="${encoding}" source="${source}" target="${target}" includeAntRuntime="false">
	            <src path="${com.joyintech.core.location}/src"/>
	            <classpath refid="classpath"/>
	        </javac>
			<jar destfile="${joyinframework.target}/WEB-INF/lib/com.joyintech.core.jar" basedir="${com.joyintech.core.target}"  />
	</target>
	
	<target  name="build_entity" depends="build_core">
	        <echo message="${ant.project.name}: ${ant.file}"/>
	        <javac debug="true" debuglevel="${debuglevel}" destdir="${com.joyintech.entity.target}" encoding="${encoding}" source="${source}" target="${target}" includeAntRuntime="false">
	            <src path="${com.joyintech.entity.location}/src"/>
	            <classpath refid="classpath"/>
	        </javac>
			<jar destfile="${joyinframework.target}/WEB-INF/lib/com.joyintech.entity.jar" basedir="${com.joyintech.entity.target}" />
	</target>
	
	<target  name="build_account" depends="build_entity">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="${com.joyintech.accounting.target}" encoding="${encoding}" source="${source}" target="${target}" includeAntRuntime="false">
            <src path="${com.joyintech.accounting.location}/src"/>
            <classpath refid="classpath"/>
        </javac>
		<jar destfile="${joyinframework.target}/WEB-INF/lib/com.joyintech.accounting.jar" basedir="${com.joyintech.accounting.target}"  />
	</target>
	
	<target  name="build_batch" depends="build_account">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="${com.joyintech.batch.target}" encoding="${encoding}" source="${source}" target="${target}" includeAntRuntime="false">
            <src path="${com.joyintech.batch.location}/src"/>
            <classpath refid="classpath"/>
        </javac>
		<jar destfile="${joyinframework.target}/WEB-INF/lib/com.joyintech.batch.jar" basedir="${com.joyintech.batch.target}">
			<exclude name="**/log4j.xml"/>
		</jar>
	</target>
	
    <target name="build-project" depends="build_batch">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="${joyinframework.target}/WEB-INF/classes" encoding="${encoding}" source="${source}" target="${target}" includeAntRuntime="false">
            <src path="${joyinframework.location}/src"/>
            <classpath refid="classpath"/>
        	<!--<compilerarg value="-Xlint:unchecked"/>
            <compilerarg value="-Xlint:deprecation"/>
            <compilerarg value="-Xlint"/>-->
        </javac>
    </target>
	
	 <target name="build-zssapp" depends="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="${zssapp.target}/WEB-INF/classes" encoding="GBK" source="${source}" target="${target}" includeAntRuntime="false">
            <src path="${zssapp.location}/src"/>
            <classpath refid="classpathForZssapp"/>
        	<!--<compilerarg value="-Xlint:unchecked"/>
            <compilerarg value="-Xlint:deprecation"/>
            <compilerarg value="-Xlint"/>-->
        </javac>
    </target>
	
	<!--生成abs.war包-->
	<target name="abswar" depends="build-zssapp">
        <war webxml="${joyinframework.target}/WEB-INF/web.xml" destfile="${abs.target}/${abswar_name}.war">
            <fileset dir="${joyinframework.target}">
                <include name="**/*.*" />
            </fileset>
        </war>
	</target>

	<!--生成war包-->
	<target name="zssappwar" depends="abswar">
        <war webxml="${zssapp.target}/WEB-INF/web.xml" destfile="${abs.target}/zssapp.war">
            <fileset dir="${zssapp.target}">
                <include name="**/*.*" />
            </fileset>
        </war>
	</target>

	<target name="earpackage" depends="run_batch">
		 <ear destfile="${abs.target}/${abswar_name}.ear" appxml="${absear.location}/META-INF/application.xml">
            <fileset dir="${abs.target}">
                <include name="${abswar_name}.war"/>
                <include name="zssapp.war"/>
            </fileset>
        </ear>
	</target>
	
	<!--生成批处理可运行jar包-->
	<target name="run_batch" depends="zssappwar">
        
		<mkdir dir="${abs.target}/Batch_Lib/Batch_Lib"/>
		 <copy includeemptydirs="false" todir="${abs.target}/Batch_Lib/Batch_Lib">
            <fileset dir="${expand_jar}">
                <include name="**/*.jar"/>
        	</fileset>
		 	<fileset dir="${joyinframework.target}/WEB-INF/lib/">
		 		<include name="aopalliance-1.0.jar"/>
		 		<include name="colt-1.2.0.jar"/>
		 		<include name="commons-codec.jar"/>
		 		<include name="commons-collections.jar"/>
		 		<include name="commons-digester.jar"/>
		 		<include name="commons-fileupload.jar"/>
		 		<include name="commons-io.jar"/>
		 		<include name="commons-lang-2.4.jar"/>
		 		<include name="commons-lang3-3.1.jar"/>
		 		<include name="commons-logging-1.1.1.jar"/>
		 		<include name="geronimo-annotation_1.0_spec-1.0.jar"/>
		 		<include name="geronimo-ejb_3.0_spec-1.0.1.jar"/>
		 		<include name="geronimo-interceptor_3.0_spec-1.0.jar"/>
		 		<include name="geronimo-jpa_3.0_spec-1.0.jar"/>
		 		<include name="geronimo-jta_1.1_spec-1.0-tsr.jar"/>
		 		<include name="geronimo-jta_1.1_spec-1.0.jar"/>
		 		<include name="javassist-3.4.ga.jar"/>
		 		<include name="log4j-1.2.15.jar"/>
		 		<include name="ognl-2.6.9-patch-20090427.jar"/>
		 		<include name="ojdbc6-6.0.jar"/>
		 		<include name="quartz-1.8.6.jar"/>
		 		<include name="s2-extension-2.4.48.jar"/>
		 		<include name="s2-framework-2.4.48.jar"/>
		 		<include name="s2-tiger-2.4.48.jar"/>
		 		<include name="slf4j-api-1.7.2.jar"/>
		 		<include name="slf4j-log4j12-1.7.2.jar"/>
		 		<include name="db2java.jar"/>
		 		<include name="db2jcc_javax.jar"/>
	 			<include name="db2jcc_license_cisuz.jar"/>
	 			<include name="db2jcc_license_cu.jar"/>
	 			<include name="db2jcc.jar"/>
		 		<include name="db2policy.jar"/>
		 		<include name="db2jcc4.jar"/>	
				<include name="com.joyintech.algo.jar"/>
				<include name="com.joyintech.assetalgo.jar"/>
				<include name="com.joyintech.core.jar"/>
				<include name="com.joyintech.entity.jar"/>
				<include name="com.joyintech.accounting.jar"/>
		 	</fileset>
    	</copy>
		
		<path id="classPathForBatch">
			<fileset dir="${abs.target}/Batch_Lib/Batch_Lib">
			    <include name="**/*.jar" />
			</fileset>
			<path refid="expand.jar"/>
		</path>
		
		<pathconvert property="mf.classpath" pathsep=" ">
            <mapper>
                <chainedmapper>
                    <!-- jar包文件只留文件名,去掉目录信息 -->
                    <flattenmapper/>
                    <!-- add lib/ prefix -->
                    <globmapper from="*" to="Batch_Lib/*"/>
                </chainedmapper>
            </mapper>
            <path refid="classPathForBatch"/>
         </pathconvert>

        <!-- 运行jar文件的输出路径 -->
        <jar destfile="${abs.target}/${absbatch_name}.jar" basedir="${com.joyintech.batch.target}">
            <manifest>
                <attribute name="Main-class" value="com.joyintech.batch.BatchStarter"/>
                <attribute name="Class-Path" value="${mf.classpath}"/>
            </manifest>
        </jar>
		
		<tar destfile="${abs.target}/${absbatch_name}.tar" basedir="${abs.target}/Batch_Lib" >
			<fileset dir="${abs.target}">
				<include name="${absbatch_name}.jar"/>
			</fileset>
			<fileset dir="${com.joyintech.batch.location}">
				<include name="startup.*"/>
				<include name="readme.rd"/>
			</fileset>
		</tar>
    </target>
	<!-- 源码文件的输出路径 -->
	<target name="sources" depends="run_batch">
		<!-- -->
		<copy todir="${joyinframework.location}/WebContent/WEB-INF/lib/">
			 <fileset dir="${joyinframework.target}/WEB-INF/lib/">
				<include name="com.joyintech.core.jar"/>
				<include name="com.joyintech.accounting.jar"/>
			 </fileset>
		</copy>
		<!-- -->
		<jar jarfile="${abs.target}/com.joyintech.accounting-sources.jar" basedir="${com.joyintech.accounting.location}">  
		</jar>
		<jar jarfile="${abs.target}/com.joyintech.core-sources.jar" basedir="${com.joyintech.core.location}">  
		</jar>
		<jar jarfile="${abs.target}/com.joyintech.entity-sources.jar" basedir="${com.joyintech.entity.location}">  
		</jar>
		<jar jarfile="${abs.target}/com.joyintech.batch-sources.jar" basedir="${com.joyintech.batch.location}">  
		</jar>
		<jar jarfile="${abs.target}/joyinframework-sources.jar" basedir="${joyinframework.location}">  
			 <exclude name="build.xml"/>
			 <exclude name="readme.rd"/>
		</jar>
		<jar jarfile="${abs.target}/zssapp-sources.jar" basedir="${zssapp.location}">
		</jar>
		<!-- -->
		<zip destfile="${abs.target}/${abswar_name}-sources.zip">
			<fileset dir="${abs.target}">
				<include name="joyinframework-sources.jar"/>
				<include name="zssapp-sources.jar"/>
				<include name="com.joyintech.entity-sources.jar"/>
				<include name="com.joyintech.batch-sources.jar"/>
			</fileset>
			<fileset dir="${joyinframework.location}">
				<include name="readme.rd"/>
			</fileset>
		</zip>
		<!-- -->
		<delete dir="${joyinframework.location}/WebContent/WEB-INF/lib/">
			<include name="com.joyintech.core.jar"/>
			<include name="com.joyintech.accounting.jar"/>
		</delete>
		<echo message="delete over files..."/>
	</target>
</project>

 

展开阅读全文

没有更多推荐了,返回首页