Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

classpath needed inside build.xml file

Posted on 2006-11-07
5
Medium Priority
?
183 Views
Last Modified: 2011-09-20
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" />
</target>

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.

 

0
Comment
Question by:pacchureddy
  • 2
5 Comments
 
LVL 10

Expert Comment

by:mbvvsatish
ID: 17895869
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
0
 

Author Comment

by:pacchureddy
ID: 17901382
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
0
 
LVL 10

Accepted Solution

by:
mbvvsatish earned 2000 total points
ID: 17904324
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question