使用ant打jar包

写个build.xml,用来构建war包

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. -->
<project basedir="." default="build" name="ActivationManagementSystem">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../eclipse"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.6"/>
    <property name="source" value="1.6"/>
    <path id="Web App Libraries.libraryclasspath">
        <pathelement location="WebContent/WEB-INF/lib/FCKeditor-2.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/antlr-2.7.6.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/aopalliance.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/asm-attrs.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/asm-commons-2.2.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/asm-util-2.2.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/asm.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/aspectjlib.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/aspectjrt.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/aspectjweaver.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/c3p0-0.9.0.4.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/cglib-2.1.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/cglib-nodep-2.1_3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-attributes-api.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-attributes-compiler.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-beanutils-1.7.0.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-codec-1.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-collections-2.1.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-collections-3.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-collections-3.2.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-fileupload.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-httpclient-3.1-alpha1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-httpclient-3.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-io-1.4.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-lang-2.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/commons-logging-1.0.4.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/displaytag-1.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/displaytag-export-poi-1.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/dom4j-1.6.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/ehcache-1.2.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/ejb3-persistence.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/ezmorph-1.0.4.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/freemarker-2.3.15.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/freemarker-2.3.8.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/hibernate-annotations.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/hibernate-commons-annotations.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/hibernate-entitymanager.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/hibernate-validator.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/hibernate3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/htmlparser.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/itext-1.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jaas.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/javacsv.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/javassist.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jaxen-1.1-beta-7.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jboss-archive-browsing.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jdbc2_0-stdext.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/json-lib-2.2.1-jdk15.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jsonplugin-0.7.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jstl.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jta.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/jxl.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/log4j-1.2.15.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/mail.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/mysql-connector-java-5.0.0.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/ognl-2.7.3.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/poi-2.5.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/servlet-api.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/spring-agent.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/spring-aspects.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/spring-tomcat-weaver.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/spring.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/standard.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/struts2-core-2.0.11.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/struts2-spring-plugin-2.0.11.1.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/xerces-2.6.2.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/xml-apis.jar"/>
        <pathelement location="WebContent/WEB-INF/lib/xwork-2.0.4.jar"/>
        <pathelement location="WebContent/WEB-INF/classes"/>
    </path>
    <path id="EAR Libraries.libraryclasspath"/>
    <path id="ActivationManagementSystem.classpath">
        <pathelement location="build/classes"/>
        <path refid="Web App Libraries.libraryclasspath"/>
        <path refid="EAR Libraries.libraryclasspath"/>
    </path>
    <target name="init">
        <mkdir dir="build/classes"/>
        <copy includeemptydirs="false" todir="build/classes">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="build/classes"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="build/classes" source="${source}" target="${target}" includeantruntime="false">
            <src path="src"/>
            <classpath refid="ActivationManagementSystem.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="FileOperate">
        <java classname="com.active.utils.system.Constants.FileOperate" failοnerrοr="true" fork="yes">
            <classpath refid="ActivationManagementSystem.classpath"/>
        </java>
    </target>
    <target name="FileOperator">
        <java classname="com.active.utils.system.Constants.FileOperator" failοnerrοr="true" fork="yes">
            <classpath refid="ActivationManagementSystem.classpath"/>
        </java>
    </target>
    <target name="make.war"  depends="build">
          <!-- war为打包web项目压缩文件, destfile为目标输出文件,basedir为需要打包的web项目目录  -->
          <war destfile="ActivationManagementSystem.war" basedir="WebContent" needxmlfile="false"></war>
     </target>
</project>


该应用导入了很多第三方的jar包。

注:该build.xml使用eclipse导出,只添加了make.war。

<war destfile="ActivationManagementSystem.war" basedir="WebContent" needxmlfile="false"></war>中

basedir="WebContent"是指定需要放入jar包的目录。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值