开发者

Extending an Ant path?

What does it mean to extend a path with another path in ANT?

if I have the folloing:

<path>
  <pathelement path="build/classes;lib/junit.jar" />
</path>

Does it mean that Ant break开发者_运维百科s build/classes;lib/junit.jar into build/classes and lib/junit.jar

in other words, does ant think that we are defining two path elements?

Thank you so much in advance. Any help will be appreciated.


Your example:

<path>
  <pathelement path="build/classes;lib/junit.jar" />
</path>

is equivalent to:

<path>
  <pathelement path="build/classes" />
  <pathelement path="lib/junit.jar" />
</path>

in both cases the path that created includes the contents of the build/classes directory plus the contents of the jarfile lib/junit.jar.

This mechanism allows you to dynamically create the required paths within your build file, rather than having to construct the combined string build/classes;lib/junit.jar.

For example, if you had the classes directory and the path to the junit jar specified in properties, you could than combine them into a single path:

<property name="classes.dir" location="build/classes" />
<property name="junit.jar" location="lib/junit.jar" />

...

<path>
  <pathelement path="${classes.dir}" />
  <pathelement path="${junit.jar}" />
</path>

This path would be the same as the examples above.

You could also refer to each of these items individually in other parts of your build file, and would only have to make changes in one place if either value needed to be changed.


The operation of the pathelement tag is documented here

You can specify PATH- and CLASSPATH-type references using both ":" and ";" as separator characters. Ant will convert the separator to the correct character of the current operating system.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜