Solved

classpath needed inside build.xml file

Posted on 2006-11-07
5
168 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 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now