📜  蚂蚁-属性任务

📅  最后修改于: 2020-11-18 07:51:38             🧑  作者: Mango


Ant构建文件是用XML编写的,它不允许像使用您喜欢的编程语言一样声明变量。但是,正如您可能想像的那样,如果Ant允许声明诸如项目名称,项目源目录等变量,这将很有用。

Ant使用允许您指定属性的property元素。这允许将属性从一个版本更改为另一个版本,或从一个环境更改为另一个环境。

默认情况下,Ant提供以下可在构建文件中使用的预定义属性-

Sr.No. Properties & Description
1

ant.file

The full location of the build file.

2

ant.version

The version of the Apache Ant installation.

3

basedir

The basedir of the build, as specified in the basedir attribute of the project element.

4

ant.java.version

The version of the JDK that is used by Ant.

5

ant.project.name

The name of the project, as specified in the name atrribute of the project element.

6

ant.project.default-target

The default target of the current project.

7

ant.project.invoked-targets

Comma separated list of the targets that were invoked in the current project.

8

ant.core.lib

The full location of the Ant jar file.

9

ant.home

The home directory of Ant installation.

10

ant.library.dir

The home directory for Ant library files – typically ANT_HOME/lib folder.

Ant还使系统属性(例如:file.separator)可用于构建文件。

除上述内容外,用户还可以使用property元素定义其他属性。以下示例显示如何定义一个名为sitename的属性-



   
   
   
      Apache Ant version is ${ant.version} - You are at ${sitename} 
   

在上述构建文件上运行Ant将产生以下输出-

C:\>ant
Buildfile: C:\build.xml

info: [echo] Apache Ant version is Apache Ant(TM) version 1.8.2  
      compiled on December 20 2010 - You are at www.tutorialspoint.com

BUILD SUCCESSFUL
Total time: 0 seconds
C:\>