`
chelsea
  • 浏览: 117888 次
  • 来自: ...
社区版块
存档分类
最新评论

Programming Ant

 
阅读更多

Common Features

1, Initialized Project:

import java.io.File;

import org.apache.tools.ant.Project;

import org.apache.tools.ant.ProjectHelper;

public class InitializedProject extends Project {

public InitializedProject(File buildFile) {

super();

init();

ProjectHelper projectHelper = ProjectHelper.getProjectHelper();

addReference("ant.projectHelper", projectHelper);

projectHelper.parse(this, buildFile);

}

}

2, Share properties with plain java code

<property file="userhome/some.properties" />

3, Organize layered build files or refer tasks/targets/properties in other build file for large scale application

<import file="../../../../../build/imports.xml" />

4, id anywhere for reuse

<path id="test.dist.dir.temp">

<pathelement location="${test.dist.dir}" />

<pathelement location="${dist.dir}" />

</path>

5, method target anywhere for reuse

<target name="dotest">

<someoperate />

</target>

<target name="TestMemoryLeak">
<antcall target="dotest">
<param name="propfile" value="mem-leak.properties" />
<param name="testclass" value="MemoryLeakTest" />
</antcall>
</target>

6, synchronized call

<target name="xdoclet" depends="init, xdoclet.ejb, xdoclet.test" />

6, script ant

although ant is not a script language, it does glue many operations together, it can combine any "executable programs", such as "Java Class", "OS script", "OS executable program", and ant scripts itself. ant also provides many useful tasks, you can use it instead of batch file.

Special Features for Large Scale Software

1, access environment variable:

  <property environment="env"/>
  <echo message="Number of Processors = ${env.NUMBER_OF_PROCESSORS}"/>
  <echo message="ANT_HOME is set to = ${env.ANT_HOME}"/>

2, access JVM variable(http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()):

Key Description of Associated Value
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("/n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory

3, property is immutable

for large scale software development, all source files include ant build files would be committed to SCM system, but many configuration items are not same in every machine, such as Application Server setup folder and listening port; Combining "environment variable, jvm variable, and immutable property", ant provides a perfect solution for this, you can commit default property files to SCM, and put custom property file in your ${user.home}, as long as your build file would load property files in ${user.home} first.

(to be continue...)

分享到:
评论

相关推荐

    apache-ant-1.7.1 完整jar包 含api

    API(Application Programming Interface)是Ant的开发者接口,详细描述了Ant的任务、属性、条件等元素,以及如何在构建文件中使用它们。对于深入理解和自定义Ant构建过程的开发者来说,这是一个宝贵的资源。通过...

    Ant入门与进阶.pdf

    - **极限编程**: 在极限编程(Extreme Programming, XP)中,Ant常被用于支持频繁的构建和测试驱动开发(Test-Driven Development, TDD)。 #### 六、Ant的扩展性 - **自定义任务**: 开发者可以轻松编写自定义的Ant...

    ant简单学习1

    在给定的压缩包文件中,"Computer Programming - Java - Java Development With Ant (2003 Manning Publish).pdf"很可能是一本关于Java开发和Ant使用的书籍。书中可能涵盖了Ant的基本概念、高级特性、实战案例以及与...

    Professional Java Tools for Extreme Programming (JAVA经典书籍英文版)_part2

    The Extreme Programming (XP) methodology enables you to build and test enterprise systems quickly without sacrificing quality. In the last few years, open source developers have created or ...

    Professional Java Tools for Extreme Programming (JAVA经典书籍英文版)_part1

    The Extreme Programming (XP) methodology enables you to build and test enterprise systems quickly without sacrificing quality. In the last few years, open source developers have created or ...

    Programming_Groovy_2.7z

    - Gradle的Groovy DSL(领域特定语言)比Ant或Maven的XML配置更易读、易写。 6. **Spock测试框架** - Groovy还催生了Spock测试框架,它提供了一种声明式的测试语法,使测试代码更具可读性和维护性。 7. **Groovy...

    Wrox.Press.Professional.Java.Tools.for.Extreme.Programming.eBook-LiB.part3

    The Extreme Programming (XP) methodology enables you to build and test enterprise systems quickly without sacrificing quality. In the last few years, open source developers have created or ...

    Wrox.Press.Professional.Java.Tools.for.Extreme.Programming.eBook-LiB.part4

    The Extreme Programming (XP) methodology enables you to build and test enterprise systems quickly without sacrificing quality. In the last few years, open source developers have created or ...

    Manning.Ant.in.Action.2nd.Edition.Jul.2007.pdf

    例如,Slashdot.org称赞它为“组织良好且清晰呈现的宝贵资源”,而Rick Hightower(《Java Tools for Extreme Programming》的合著者)则强烈建议所有使用Ant的开发者都应该阅读此书。 #### 二、主要内容概述 ...

    Spring+JUnit4 +Ant测试报告

    Spring是Java企业级应用开发中最常用的一个框架,它提供了依赖注入(Dependency Injection,DI)和面向切面编程(Aspect-Oriented Programming,AOP)等核心特性。依赖注入使得组件之间解耦,提高了代码的可测试性。...

    Ant Colony Optimization methods and Applications

    动态蚁编程(Dynamic Ant Programming)是一种基于ACO的程序自动生成方法。这种方法允许算法自动构造出能够解决问题的程序代码。本章详细阐述了动态蚁编程的基本思想和技术细节,并通过实例展示了如何使用这种方法来...

    API 文档管理系统 (Koa+React+Ant Design+Mongodb).zip

    在现代软件开发中,API(Application Programming Interface)文档管理系统的存在至关重要,它帮助开发者清晰地理解和使用接口,提高协作效率。本系统采用的技术栈为Koa、React、Ant Design以及Mongodb,这是一套...

    Jacorb ProgrammingGuide

    这通常通过运行 `ant` 命令完成。 ##### 2.3 版本控制 JacORB 使用语义化版本控制(Semantic Versioning),这意味着版本号由三部分组成:主版本号、次版本号和修订号。例如,3.6.0 表示这是一个主要版本更新,...

    Apache Cordova 4 Programming.pdf

    1. **环境搭建**:讲解如何在不同的操作系统上安装和配置Cordova,包括Node.js、Apache Ant或Gradle(根据目标平台的不同)、以及各种平台的SDK。 2. **项目创建与管理**:介绍如何使用Cordova命令行工具创建新项目...

    elm-antd:榆树的官方Ant Design UI Kit

    榆蚂蚁设计 为Elm带来惊人的套件! 完全使用elm-css样式! 无需外部样式表。 只是elm install supermacro/elm-antd ,... 您必须使用Ant.Css.defaultStyles或Ant.Css.createThemedStyles customTheme (请参阅以了解有

    The Groovy Programming Language

    2. **集成工具**:Groovy可以很好地与其他Java工具集成,如Ant和Maven。 3. **社区支持**:Groovy拥有一个活跃的社区,不断贡献新的库和工具。 #### 结论 综上所述,Groovy是一种强大而灵活的编程语言,它充分利用...

    Spring基础教程

    - **创建项目目录和ant build文件**: 根据项目需求设置项目目录结构,并创建ant build文件以支持项目的构建、部署和测试。 - **创建单元测试**: 为持久层编写单元测试,确保数据访问层的正确性。 - **配置...

Global site tag (gtag.js) - Google Analytics