`
tanglei198577
  • 浏览: 59710 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类

Ant

    博客分类:
  • SSH
阅读更多

First,download a apache-ant-1.7.1 from apache site on network.then u need to config the "Path" of environment variables.If the ant unzip at E:\apache-ant-1.7.1,so u need add "E:\apache-ant-1.7.1\bin" to the path.then print the ant -version on cmd:

      Apache Ant version 1.7.1 compiled on June 27 2008

it verified that u r ant work well.

then when I want to use the ant to deploy my project ,I should add a build.xml and build.properties at the root of this project.

the contents are:

  build.xml

<project name="StrutsSample" default="help" basedir=".">

<!-- ===================== Property Definitions =========================== -->

    <!--
         All properties should be defined in this section.
         Any host-specific properties should be defined
         in the build.properties file.

         In this app, the following properties are defined in build.properties:

        o  tomcat.home     - the home directory of your Tomcat installation
        o  webapps.home    - the place to copy the war file to deploy it
    -->

  <property file="build.properties" />
 

  <property name="app.home"          value="." />
  <property name="app.name"          value="StrutsSample" />
  <property name="javadoc.pkg.top"   value="com/yourcompany/struts" />

  <property name="src.home"          value="${app.home}/src"/>
  <property name="lib.home"          value="${app.home}/WebRoot/WEB-INF/lib"/>
  <property name="classes.home"       value="${app.home}/classes"/>
  <property name="deploy.home"       value="${app.home}/deploy"/>
  <property name="doc.home"          value="${app.home}/doc"/>
  <property name="web.home"          value="${app.home}/WebRoot"/>

  <property name="build.home"        value="${app.home}/build"/>
  <property name="build.classes"     value="${build.home}/WEB-INF/classes"/>
  <property name="build.lib"         value="${build.home}/WEB-INF/lib"/>

<!-- ==================== Compilation Classpath =========================== -->

    <!--
         This section creates the classpath for compilation.
    -->

  <path id="compile.classpath">

    <!-- The object files for this application -->
    <pathelement location="${classes.home}"/>

    <!-- The lib files for this application -->
    <fileset dir="${lib.home}">
      <include name="*.jar"/>
      <include name="*.zip"/>
    </fileset>

    <!-- All files/jars that Tomcat makes available -->
    <fileset dir="${tomcat.home}/lib">
      <include name="*.jar"/>
    </fileset>
    <pathelement location="${tomcat.home}/classes"/>

  </path>


<!-- ==================== Build Targets below here========================= -->


<!-- ==================== "help" Target =================================== -->

    <!--
         This is the default ant target executed if no target is specified.
         This helps avoid users just typing 'ant' and running a
         default target that may not do what they are anticipating...
    -->

 <target name="help" >
   <echo message="Please specify a target! [usage: ant &lt;targetname&gt;]" />
   <echo message="Here is a list of possible targets: "/>
   <echo message="  clean-all.....Delete build dir, all .class and war files"/>
   <echo message="  prepare.......Creates directories if required" />
   <echo message="  compile.......Compiles source files" />
   <echo message="  build.........Build war file from .class and other files"/>
   <echo message="  deploy........Copy war file to the webapps directory" />
   <echo message="  javadoc.......Generates javadoc for this application" />
 </target>

<!-- ==================== "clean-all" Target ============================== -->

   <!--
          This target should clean up any traces of the application
          so that if you run a new build directly after cleaning, all
          files will be replaced with what's current in source control
   -->

 <target name="clean-all" >
    <delete dir="${build.home}"/>
    <delete dir="${classes.home}"/>
    <delete dir="${deploy.home}"/>

    <!-- can't delete directory if Tomcat is running -->
    <delete dir="${webapps.home}/${app.name}" failonerror="false"/>

    <!-- deleting the deployed .war file is fine even if Tomcat is running -->
    <delete dir="${webapps.home}/${app.name}.war" />

    <!-- delete the javadoc -->
    <delete dir="${doc.home}"/>

 </target>

<!-- ==================== "prepare" Target ================================ -->

    <!--
          This target is executed prior to any of the later targets
          to make sure the directories exist. It only creates them
          if they need to be created....
          Other, similar, preparation steps can be placed here.
    -->

  <target name="prepare">

    <echo message="Tomcat Home = ${tomcat.home}" />
    <echo message="webapps Home = ${webapps.home}" />

    <mkdir dir="${classes.home}"/>
    <mkdir dir="${deploy.home}"/>

    <mkdir dir="${doc.home}"/>
    <mkdir dir="${doc.home}/api"/>

    <mkdir dir="${build.home}"/>
    <mkdir dir="${build.home}/WEB-INF" />
    <mkdir dir="${build.home}/WEB-INF/classes" />
    <mkdir dir="${build.home}/WEB-INF/lib" />

  </target>

<!-- ==================== "compile" Target ================================ -->

    <!--
          This only compiles java files that are newer
          than their corresponding .class files.
     -->

  <target name="compile" depends="prepare" >
    <javac srcdir="${src.home}" destdir="${classes.home}" debug="yes" >
        <classpath refid="compile.classpath"/>
    </javac>
  </target>

<!-- ==================== "build" Target ================================== -->

    <!--
          This target builds the war file for the application
          by first building the directory structure of the
          application in ${build.home} and then creating the
          war file using the ant <war> task
     -->

  <target name="build" depends="compile" >

    <!-- Copy all the webapp content (jsp's, html, tld's, xml, etc. -->
    <!-- Note that this also copies the META-INF directory -->
    <copy    todir="${build.home}">
      <fileset dir="${web.home}"/>
    </copy>

    <!-- Now, copy all the Java class files -->
    <copy    todir="${build.home}/WEB-INF/classes">
      <fileset dir="${classes.home}"/>
    </copy>

    <!-- Now, copy all the properties files, etc that go on the classpath -->
    <copy    todir="${build.home}/WEB-INF/classes">
      <fileset dir="${src.home}">
         <include name="**/*.properties" />
         <include name="**/*.prop" />
      </fileset>
    </copy>

    <!-- Now, copy all the jar files we need -->
    <copy    todir="${build.home}/WEB-INF/lib">
      <fileset dir="${lib.home}" />
    </copy>

    <!-- Create the <war> file -->
    <jar jarfile="${deploy.home}/${app.name}.war"
         basedir="${build.home}"/>

  </target>

<!-- ==================== "deploy" Target ================================= -->

    <!--
         This target simply copies the war file from the deploy
         directory into the Tomcat webapp directory.
     -->

  <target name="deploy" depends="build" >

    <!-- Copy the contents of the build directory -->
    <copy todir="${webapps.home}"  file="${deploy.home}/${app.name}.war" />

  </target>

<!-- ==================== "doc" Target ==================================== -->

    <!--
         This task creates javadoc. It is dependent upon only the
         'compile' target so it is not executed in a normal build.
         As a result, the target needs to be run on its own.
    -->

  <target name="javadoc" depends="compile">
      <javadoc sourcepath = "${src.home}"
                  destdir = "${doc.home}/api"
             packagenames = "${javadoc.pkg.top}.*"/>
  </target>

</project>

 The build.properties(config the path of Tomcat):

 tomcat.home=C:/Program Files/Apache Software Foundation/Tomcat 6.0
 webapps.home=C\:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps

 then go to the project by cmd:

  print "ant -deploy "to generate the war,classes and so on

  print "ant -javadoc " to generate the document of the classes u want to

then u will found them (This example is based on the book of Sunweiqin):

0
0
分享到:
评论

相关推荐

    apache-ant-1.6.5-bin.zip_ ant 1.6.5_ant_ant-1.6.5_apache ant win

    Apache Ant 是一个开源的构建工具,广泛用于Java项目构建,由Apache软件基金会开发。这个"apache-ant-1.6.5-bin.zip"文件是Ant的1.6.5版本的二进制发行版,适合在Windows操作系统上使用。Ant是基于Java的,它的主要...

    ant.jar下载

    org.apache.tools.ant.Main org.apache.tools.ant.Task org.apache.tools.bzip2.CRC org.apache.tools.ant.Target org.apache.tools.ant.Project org.apache.tools.zip.ZipFile org.apache.tools.zip.ZipLong ...

    开发工具 ant-1.9.6

    开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6开发工具 ant-1.9.6...

    ant ant ant ant

    "Ant ant ant antant ant ant antant ant ant ant" 这个描述可能是在强调Ant在项目构建过程中的重复性和不可或缺性,暗示着它在工程中的频繁使用和核心地位。 Ant的设计理念是“一切都是XML”,它通过XML格式的构建...

    Axure AntDesign元件库

    Axure AntDesign元件库是一款专为Axure设计的高质量组件集合,它旨在帮助原型设计师快速构建基于AntDesign设计系统的Web应用界面。AntDesign是阿里巴巴开源的一款著名前端UI框架,以其优雅、直观、高效的特性广受...

    ANT+协议 VS2015源文件

    ANT+协议是一种无线通信协议,主要用于运动健康和健身设备之间的数据传输。该协议由Garmin公司开发,并在开放源码的基础上推广,使得不同厂商的设备能够无缝共享数据,如心率、速度、距离等运动参数。VS2015源文件指...

    AntDesign3.9Axure组件

    《AntDesign3.9Axure组件:原型设计的利器》 在互联网产品开发流程中,原型设计是一个至关重要的环节,它能清晰地呈现产品的功能结构和交互方式,为后续的开发工作提供明确的方向。AntDesign3.9Axure组件正是这样一...

    mac下ant打包android

    在给定的文件中,`apache-ant-1.9.4-bin.zip`是Ant的一个版本,你需要解压并将其添加到系统路径中,这样命令行就可以识别`ant`命令了。安装完成后,确保你的环境配置正确,包括Android SDK和相关的环境变量(如`...

    ant1.9包下载

    Apache Ant是Java开发中不可或缺的构建工具,它以其灵活性、可扩展性和跨平台特性而闻名。标题中的"ant1.9包下载"指的是Apache Ant 1.9系列的版本,这是该工具的一个重要里程碑,提供了许多增强的功能和修复了已知...

    Ant design axure设计库

    **Ant Design Axure设计库详解** Ant Design是一个广泛使用的开源UI设计框架,源自阿里巴巴集团,专为构建高效、稳定且具有良好用户体验的Web应用而设计。它提供了丰富的组件库,覆盖了网页界面设计的各个方面,...

    apache-ant-1.9.16-bin.zip

    Apache Ant 是一个开源的构建工具,广泛用于Java项目管理,它是Apache软件基金会的产品之一。Ant以其XML为基础的构建文件(build.xml)而著名,这种文件定义了构建过程中的任务序列,使得开发人员能够自动化编译、...

    ant-design-demos

    "ant-design-demos" 是一个基于Ant Design框架的示例集合,主要展示了Ant Design的各种组件和功能在实际应用中的使用方式。Ant Design是一款由阿里集团开发的高质量React UI库,它提供了一系列美观、易用且具有企业...

    apache-ant-1.9.16-bin.tar.gz

    Apache Ant 是一个由Apache软件基金会开发的Java库和命令行工具,其设计目的是驱动构建过程。这个工具的名字“Ant”来源于“蚂蚁”,象征着它在软件工程中的小而有力的角色,能够处理各种复杂的构建任务。在Java开发...

    apache-ant-1.9.9.zip

    Apache Ant 是一个开源的构建工具,广泛用于Java项目,它基于XML来定义构建过程,使得构建脚本具有可读性强、可复用性高的特点。标题中的"apache-ant-1.9.9.zip"表明这是一个包含Apache Ant 1.9.9版本的压缩文件,...

    Ant Design Library 3.0 Axure 组件库

    《Ant Design Library 3.0 与 Axure 组件库详解》 Ant Design Library 3.0 是一款专为Axure设计的组件库,旨在帮助设计师高效、精准地构建高质量的原型。Ant Design,源自阿里巴巴的前端框架,以其优雅的设计风格和...

    apache-ant-1.9.6的jar包

    Apache Ant 是一个开源的构建工具,它主要用于Java项目构建、自动化任务执行,如编译、打包、测试和部署。在Java开发中,Ant以其XML格式的构建文件(build.xml)著称,允许开发者定义项目构建的步骤和依赖关系。...

    ANT文件详解 ant介绍 ANT 命令

    ### ANT文件详解:深入理解ANT及其在项目构建中的应用 #### Ant的概念与起源 Ant,全称为Apache Ant,是一款开源的、跨平台的项目构建工具,最初由James Duncan Davidson开发,现归属于Apache软件基金会Jakarta...

    apache-ant-1.8.2

    Apache Ant 是一个开源的构建工具,它主要用于Java项目构建,由Apache Software Foundation开发并维护。在Java开发领域,Ant以其灵活性和可配置性而被广泛使用,它通过XML格式的构建文件(通常命名为build.xml)来...

    Axure组件库ant.zip

    "Ant"在这里指的是蚂蚁金服(Ant Group)设计系统中的组件,这个组件库是专门为Axure设计的,目的是为了提升产品设计和开发团队的工作效率。 在“Axure组件库ant.zip”中,我们可以推测包含了一系列与蚂蚁金服Ant ...

    AntDesign3.9.x.zip

    《AntDesign3.9.x:一个强大的Axure组件库》 AntDesign3.9.x.zip是一个专门为Axure设计的组件库,它基于流行的前端框架Ant Design的3.9.x版本,为原型设计师提供了丰富的UI元素和组件。这个组件库由开发者在2018年9...

Global site tag (gtag.js) - Google Analytics