Nemo

Nemo 关注TA

路漫漫其修远兮,吾将上下而求索。

Nemo

Nemo

关注TA

路漫漫其修远兮,吾将上下而求索。

  •  普罗旺斯
  • 负责帅就完事了
  • 写了1,495,102字

该文章投稿至Nemo社区   Java  板块 复制链接


Ant build.xml打包JAR

发布于 2016/01/11 10:36 1,971浏览 0回复 3,682

这套脚本目前是公司这边在用的,先记录在博客,备忘~


==========build.xml=============

<project name="Webapp Precompilation" default="all" basedir=".">
  <property file="build.properties"/>
<!-- 编译jsp文件 -->
  <target name="jspc">
    <taskdef classname="org.apache.jasper.JspC" name="jasper2">
      <classpath id="jspc.classpath">
      <!-- 设定工程依赖的jar包 -->
        <pathelement location="${java.home}/../lib/tools.jar"/>
        <fileset dir="${tomcat.home}/bin">
          <include name="*.jar"/>
        </fileset>
        <fileset dir="${tomcat.home}/lib">
          <include name="*.jar"/>
        </fileset>
      </classpath>
    </taskdef>
    <jasper2
    javaEncoding="utf-8"
      validateXml="false"  verbose="9" 
      uriroot="${webapp.path}" 
      outputDir="${webapp.path}/WEB-INF/src"
      webXmlFragment="${webapp.path}/WEB-INF/generated2-web.xml" />
  
  </target>
  <target name="compile">
    <mkdir dir="${webapp.path}/WEB-INF/classes"/>
    <mkdir dir="${webapp.path}/WEB-INF/lib"/>
    <javac destdir="${webapp.path}/WEB-INF/classes" 
    optimize="of" 
    encoding="utf-8" 
    debug="on" failonerror="false" 
    srcdir="${webapp.path}/WEB-INF/src" 
    excludes="**/*.smap">
      <classpath>
        <pathelement location="${webapp.path}/WEB-INF/classes"/>
        <fileset dir="${webapp.path}/WEB-INF/lib">
          <include name="*.jar"/>
        </fileset>
        <fileset dir="${tomcat.home}/lib">
          <include name="*.jar"/>
        </fileset>
        <!--pathelement location="${tomcat.home}/common/classes"/>
        <fileset dir="${tomcat.home}/common/lib">
          <include name="*.jar"/>
        </fileset>
        <pathelement location="${tomcat.home}/shared/classes"/>
        <fileset dir="${tomcat.home}/shared/lib">
          <include name="*.jar"/>
        </fileset-->
        <fileset dir="${tomcat.home}/bin">
          <include name="*.jar"/>
        </fileset>
      </classpath>
      <include name="**"/>
      <!--exclude name="tags/**"/-->
    </javac>
    <jar jarfile="${webapp.path}/WEB-INF/lib/cadre.jar" basedir="${webapp.path}/WEB-INF/classes"/>
  </target>
  <target name="all" depends="jspc,compile"></target>
</project>



=========build.properties============

tomcat.home=D:/tools/apache-tomcat-7.0.47/
webapp.path=E:/Nemo_work04/sms/WebContent/
src.path =E:/Nemo_work04/sms/src/



点赞(0)
点了个评