java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Ant arrow How to use Pathconvert task
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4100
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Pathconvert task E-mail
User Rating: / 1
PoorBest 

Pathconvert

Description

Converts a nested <path> or reference to a Path, FileSet, DirSet, or FileList into a path form for a particular platform, and stores the result in a given property. It can also be used when you need to convert a Path, FileSet, or DirSet into a list, separated by a given character, such as a comma or space, or, conversely, to convert a list of files in a FileList into a path.

Nested <map> elements can be specified to map Windows drive letters to Unix paths, and vice-versa.

More complex transformations can be achieved using a nested <mapper> (since Ant 1.6.2).

Parameters

Attribute Description Required
targetos The target architecture. Must be one of 'unix', 'windows', 'netware', 'tandem' or 'os/2'. This is a shorthand mechanism for specifying both pathsep and dirsep according to the specified target architecture. No
dirsep The character(s) to use as the directory separator in the generated paths. No, defaults to current JVM File.separator
pathsep The character(s) to use as the path-element separator in the generated paths. No, defaults to current JVM File.pathSeparator
property The name of the property in which to place the converted path. Yes
refid What to convert, given as a reference to a <path>, <fileset>, <dirset>, or <filelist> defined elsewhere No; if omitted, a nested <path> element must be supplied.
setonempty Should the property be set, even if the result is the empty string? No; default is "true".

Parameters specified as nested elements

map

Specifies the mapping of path prefixes between Unix and Windows.

Attribute Description Required
from The prefix to match. Note that this value is case-insensitive when the build is running on a Windows platform and case-sensitive when running on a Unix platform. Yes
to The replacement text to use when from is matched. Yes

Each map element specifies a single replacement map to be applied to the elements of the path being processed. If no map entries are specified, then no path prefix mapping is performed.

Note: The map elements are applied in the order specified, and only the first matching map element is applied. So, the ordering of your map elements can be important, if any from values are prefixes of other from values.

path

If the refid attribute is not specified, then a nested <path> element must be supplied. See Path-like Structures for details.

mapper

A single nested <mapper> element can be specified to perform any of various filename transformations (since Ant 1.6.2).

Examples

In the examples below, assume that the ${wl.home} property has the value d:\weblogic, and ${wl.home.unix} has the value /weblogic.

Example 1

    <path id="wl.path">
      <pathelement location="${wl.home}/lib/weblogicaux.jar"/>
      <pathelement location="${wl.home}/classes"/>

      <pathelement location="${wl.home}/mssqlserver4/classes"/>
      <pathelement location="c:\winnt\System32"/>
    </path>
    
    <pathconvert targetos="unix" property="wl.path.unix" refid="wl.path">

      <map from="${wl.home}" to="${wl.home.unix}"/>
      <map from="c:" to=""/>
    </pathconvert>

will generate the path shown below and store it in the property named wl.path.unix.

/weblogic/lib/weblogicaux.jar:/weblogic/classes:
/weblogic/mssqlserver4/classes:/WINNT/SYSTEM32

Example 2

Given a FileList defined as:
  <filelist id="custom_tasks.jars"

        dir="${env.HOME}/ant/lib"
        files="njavac.jar,xproperty.jar"/>
then:
    <pathconvert targetos="unix" 
    property="custom_tasks.jars" 
    refid="custom_tasks.jars">

      <map from="${env.HOME}" to="/usr/local"/>
    </pathconvert>
will convert the list of files to the following Unix path:
/usr/local/ant/lib/njavac.jar:/usr/local/ant/lib/xproperty.jar

Example 3

    <fileset dir="${src.dir}" id="src.files">
      <include name="**/*.java"/>
    </fileset>

  
    <pathconvert pathsep="," property="javafiles" refid="src.files"/>

This example takes the set of files determined by the fileset (all files ending in .java), joins them together separated by commas, and places the resulting list into the property javafiles. The directory separator is not specified, so it defaults to the appropriate character for the current platform. Such a list could then be used in another task, like javadoc, that requires a comma separated list of files.

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.