classpath needed inside build.xml file

I have this scenario:

There is a text file(first.txt) and it is located in (souceApp/EAR/PresentationApp) and I need to copy this file to another file (first.jsp) and the first.jsp should be placed in the (sourceApp/WAR/testWebApp) .
This should be done in the build.xml file.
The build.xml file is present for each webapp inside WAR and also present in the souceAppdirectory.

The build.xml present in the sourceApp is the main/parent build.xml which will  refer to build.xml for WAR,EAR...etc..,

Here is what I did:

<target name="copy-file" des="copies file>
<copy file ="first.txt" tofile="first.jsp" overwrite="yes" />

I want to know the  what would be the classpath (the loactions )for "first.txt"  and first.jsp inside the above mentioned target .

first.jsp is not exiting in the testWebApp. I believe the copy target will create a new file called first.jsp before its copied from first.txt.

also wated to know if this target "copy file" should be written inside build.xml of testWebApp or build.xml of sourceApp?

Any help would be greatly appreciated.


Who is Participating?
mbvvsatishConnect With a Mentor Commented:
ok. i understood wrongly.
in you  build.xml of testWebApp you might have pointed the project to a base directory
something like
<project name="TestWebapp" basedir="C:/souceApp">

so you can specify you classpath fo myfile.txt with respect to you basedir.

if your basedir is souceApp/EAR then you can use ${basedir}/EAR/PresentationApp/myfile.txt
you can do like this
1. copy the file to the destination directory

 <copy file="myfile.txt" todir="../some/other/dir"/>

2. and Rename the file that is copied in the destination directory

<rename src="foo.jar" dest="${name}-${version}.jar" replace="yes" />

>> also wated to know if this target "copy file" should be written inside build.xml of testWebApp or build.xml of sourceApp?

that is up to you. you can write in any build.xml file.
i prefer writing in build.xml of testWebApp if you have only one webapp.
if you have more than one webapps and you want to do the same file copy for all the webapps, you better do it in your main build.xml
pacchureddyAuthor Commented:
why do we have to copy the myfile.txt to a directory and then rename.
instead copy "myfile.txt" to another file (here in my case i wanted to as myfile.jsp)

<copy file ="myfile.txt" tofile="myfile.jsp" overwrite="yes" />

i have more than one webapp , but the file to be copied(myfile.jsp) needs to be placed in testWebApp's root folder

if i am writing this copy target in build.xml of testWebApp then what should be correct way of specifying the file location for "myfile.txt"

<copy file="(classpath)myfile.txt" tofile="myfile.jsp"/>

need to know the classpath for myfile.txt..... myfile.txt is present in the following directory structure:

souceApp/EAR/PresentationApp and myfile.jsp should be in souceApp/WAR/testWebApp
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.