Apache Jakarta and Beyond: A Java Programmeramp;#039;s Introduction [Electronic resources]

Larne Pekowsky

نسخه متنی -صفحه : 207/ 20
نمايش فراداده

2.5. Paths

Figure 2.2 might be constructed as

<classpath>
<pathelement path="src"/>
<pathelement path="jars/canetoad.jar"/>
<pathelement path="jars/xml-apis.jar"/>
</classpath>

In addition to building paths from single pathelements, paths can also be built from filesets, as in the following:

<fileset id="alljars">
<include name="**/*.jar"/>
</fileset>
<classpath>
<pathelement path="src"/>
<fileset refid="alljars"/>
</classpath>

which builds a CLASSPATH consisting of all the jars and the src directory.

Note that variables such as CLASSPATH are valid only within the build file where they are defined. There is no way for any Java program to change the global CLASSPATH that is used when other Java programs start running.

The filesets within paths may also have nested elements, and paths may have identifiers by which they can be used in other paths. Ant is a very logical program and in general behaves as expected. If it seems like it should be possible to combine any of the constructs that have been presented so far, then the odds are that they can indeed be combined.