Frequently Used Nested Parameters and Elements


Nested parameters can be used within certain tasks tags, as children. Some of the most frequent ones are listed below in order to shorten the definition a tasks , by avoiding repetition.

Classpath Element

The classpath task allows tasks to use paths and class paths efficiently :

 <classpath path="[path]"/> 

Nested Parameters

  • pathelement: Class used to specify both paths and class paths. Pathelement is used as a nested element for many other tasks:

     <classpath> <pathelement path="[path]"/> </classpath> 
    • path: A comma-separated list of paths:

       <classpath> <pathelement path="[path]"/> </classpath> 
    • location: A comma-separated list of paths, relative to the base directory of the project:

       <classpath> <pathelement location="classes"/> 
  • < /classpath >

  • fileset: Specifies a collections of files (see section Frequently Used Nested Parameters and Elements at the end of this chapter for more information).

     <fileset dir="/src/java" >     <include name="**/*.java"/>     <exclude name="**/*Test*"/> </fileset> 

The above example includes all Java source except those with the substring Test in their filename.

Mapper Element

The mapper task simply maps a file to a target. Keep in mind that this task is used in conjunction with other tasks.

 <mapper type="identity"/> 

In the above the to and from are ignored and the files are copied into a parallel subdirectory hierarchy as the source to the destination (e.g., c:\src\xptool\Hello.java copied to d:\backup\src\xptool\Hello.java).

 <mapper type="flatten"/> 

Unlike the first example, copy all the files from the source to the destination, but all in the source directory with no subdirectory hierarchy (e.g., c:\src\xptool\Hello.java copied to d:\backup\Hello.java).

 <mapper type="glob" from="*.java" to="*.java.bak"/> 

Copy *.java files to *.java.bak files (e.g., c:\src\xptool\Hello.java copied to d:\backup\src\xptool\ Hello.java.bak).

Parameters

  • type: Several types have been defined internally to this class:

    • identity: The target is identical to the source name.

    • flatten: The target is identical to the source name and is stripped of any directory structure, effectively making the branch flat.

    • merge: The type will map all entries to the same target using the mapper s to parameter.

    • glob: Patterns will be matched using the mapper s to and from parameters. The to parameter will be used to specify the pattern-matching names . The from parameter will be used to specify the target pattern.

    • regexp: Patterns will be evaluated against a regular expression using the mapper s to and from parameters. The to parameter will be used to specify the regular expression to match names. The from parameter will be used to specify the regular expression for the target pattern.

  • classname: Specifies the implementation by class name.

  • classpath: The class path to use when looking up the class name.

  • classpathref: A class path used in looking up a class specified by the reference id of one of the build files elements:

     <project ... >   <path id="project.class.path">     <pathelement location="lib/"/>     <pathelement path="${java.class.path}/"/>       </path> <available classname="Foo" classpathref="project.class.path"/> 
  • from: Refer to the earlier implementations of the type parameter of the mapper task to see how and when from is used.

  • to: Refer to the earlier implementations of the type parameter of the mapper task to see how and when to is used.

Nested Parameters

  • classpath: A definition was listed above.

Fileset Element

The fileset task defines groups of files in a branch of a directory structure:

 <fileset dir="src/" > 

Parameters

  • dir*: Base of the branch in the directory structure from which the fileset will be built.

  • defaultexcludes: Value of yes or no ; specifies whether default excludes are used.

  • includes: Comma-separated list of patterns to include in the file set. All other files are excluded.

  • includesfile: File source of patterns to include in the file set. All other files will be excluded.

  • excludes: Comma-separated list of patterns to exclude in the file set. All other files are included.

  • excludesfile: File source of patterns to exclude in the file set. All other files will be included.

Nested Parameters

  • patternset: A definition can be found defined above at the start of the section Frequently Used Nested Parameters.

Patternset Element

The patternset task provides a way to group patterns for later use. It is commonly used nested in a fileset task:

 <patternset id="junit.test.sources" > <include name="**/*Test*.java" />      <exclude name="**/AllTests.java" /> </patternset> 

Parameters

  • includes: Comma-separated list of patterns to include in the file set. All other files are excluded.

  • includesfile: File source of patterns to include in the file set. All other files will be excluded.

  • excludes: Comma-separated list of patterns to exclude in the file set. All other files are included.

  • excludesfile: File source of patterns to exclude in the file set. All other files will be included.

Zipfileset Element

The zipfileset task defines groups of files in a branch of a directory structure:

 <zipfileset dir="src/" > 

Parameters

  • prefix: File that specifies the path of a Zip archive where files will be added.

  • fullpath: Directory in which a single file is added to an archive.

  • src: Zip file whose extracted contents should be included in the archive.

  • dir * : Base of the branch in the directory structure from which the file set will be built.

  • defaultexcludes: Value of yes or no ; specifies whether default excludes are used.

  • includes: Comma-separated list of patterns to include in the file set. All other files are excluded.

  • includesfile: File source of patterns to include in the file set. All other files will be excluded.

  • excludes: Comma-separated list of patterns to exclude in the file set. All other files are included.

  • excludesfile: File source of patterns to exclude in the file set. All other files will be included.




Professional Java Tools for Extreme Programming
Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)
ISBN: 0764556177
EAN: 2147483647
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net