简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM