简体   繁体   English

使用Apache ant的两个问题

[英]Two questions on using Apache ant

I am learning to build automatic Java compiling script using Ant.我正在学习使用 Ant 构建自动 Java 编译脚本。 With respect to the following code segment, what does the default="dist" stand for?关于下面的代码段,default="dist" 代表什么? For the basedir=".", does "."对于 basedir=".","." mean the working directory, which has build.xml stored?是指工作目录,其中存储了 build.xml?

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

With respect to the following segment, what does location="src"/ stand for?关于下面的段,location="src"/ 代表什么?

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

The default attribute indicates the target which will be executed if you are calling ant without any target argument. default属性表示如果您在没有任何目标参数的情况下调用ant将执行的目标。 Thus with this setting, ant will be synonymous to ant dist .因此,使用此设置, ant将与ant dist同义。

The basedir attribute is interpreted relatively to the parent directory of build.xml , yes. basedir属性相对于build.xml的父目录进行解释,是的。 (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.属性任务location属性将相对于项目basedir的路径转换为绝对路径。 Thus, in your case you will get the absolute path of src in the buildfile's directory.因此,在您的情况下,您将在构建文件的目录中获得src的绝对路径。 (It will also do conversion of / and \ to your platform's conventions.) (它还将/\转换为您平台的约定。)

These are things easily read in the Ant Manual这些是Ant 手册中容易阅读的内容

<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.请参阅<property>任务的文档

  1. The goal 'dist' will run by default if you don't ask ant to run another.如果您不要求 ant 运行另一个目标,则目标“dist”将默认运行。

  2. A directory named 'src' in the same directory as the basedir, which is to say, wherever you are sitting when you run ant.与 basedir 位于同一目录中的名为“src”的目录,也就是说,当你运行 ant 时,无论你坐在哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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