More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Convert the path in to properties 
 

This example illustrates how to convert path in to properties. In this example, refid is a reference to an object defined elsewhere in the file.

 

Convert the path in to properties

                         

This example illustrates how to convert path in to properties. In this example, refid is a reference to an object defined elsewhere in the file. The reference allows you to reuse the chunks of the build file so that common classpath and path can be shared among targets. Many tasks have a refid attribute assigning the value of reference object to the property name with the name attribute. In this example, the java file is converted from src directory to build directory and the lib directory refers to the common lib directory of apache tomcat home directory. The path of tomcat home is changed in to the property name. The source code of build.xml is as follows:

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<project name="convert path" default="compile" basedir=".">
  <property environment="env"/>
  <property name="tomcatHome" value="${env.TOMCAT_HOME}"/>
  <property name="dir.src" value="src"/>
  <property name="dir.build" value="build"/>
  <property name="dir.lib" value="lib"/>

  <path id="project.classpath">
    <pathelement location="${dir.src}"/>
    <fileset dir="${tomcatHome}/common/lib">
      <include name="*.jar"/>
    </fileset>    
    <fileset dir="${dir.lib}">
      <include name="*.jar"/>
    </fileset>
  </path>

  <target name="clean">
    <delete dir="${dir.build}"/>
    <delete dir="${dir.lib}"/>
  </target>

  <target name="prepare" depends="clean">
    <mkdir dir="${dir.build}"/>
    <mkdir dir="${dir.lib}"/>
    <mkdir dir="${dir.src}"/>
  </target>

  
<target name="compile" depends="prepare">
    <pathconvert targetos="windows" property="windowsPath" refid="project.classpath"/>
    <echo>Path Directory = ${windowsPath}</echo>
    <javac destdir="${dir.build}" srcdir="${dir.src}">
      <classpath refid="project.classpath"/>
    </javac>
  </target>

</project>

 

If you run the program, the following output will be generated.


Download Source Code
 

                         

» View all related tutorials
Related Tags: sql c database xml file url data ui build property user sed password word driver vi name using this element

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.