开发者

Two questions on using Apache ant

I am learning to build automatic Java compiling script using Ant. With respect to the following code segment, what does the default="dist" stand for? For the basedir="开发者_运维知识库.", does "." mean the working directory, which has build.xml stored?

<project name="Myproject" default="dist" basedir=".">

With respect to the following segment, what does location="src"/ stand for?

<property name = "src" location="src"/>


The default attribute indicates the target which will be executed if you are calling ant without any target argument. Thus with this setting, ant will be synonymous to ant dist.

The basedir attribute is interpreted relatively to the parent directory of build.xml, yes. (This directory is usually the same as the current working directory, but does not have to be.)

The location attribute of the property task converts a path relative to the projects basedir to an absolute path. Thus, in your case you will get the absolute path of src in the buildfile's directory. (It will also do conversion of / and \ to your platform's conventions.)


These are things easily read in the Ant Manual

<project name="Myproject" default="dist" basedir=".">

This defines the default target to be be run if none is specified

<property name = "src" location="src"/>

See the documentation for the <property> task.


  1. The goal 'dist' will run by default if you don't ask ant to run another.

  2. A directory named 'src' in the same directory as the basedir, which is to say, wherever you are sitting when you run ant.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜