Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add one folder in classpath for ant script?

I need to add a folder in current classpath for ant script that I have written for running java files. How can it be done?

like image 719
M.J. Avatar asked Oct 21 '10 10:10

M.J.


People also ask

What is classpath in Ant?

Ant classpath: discussion dir defined before this code is run, and that variable points to your lib directory, which contains all of the jar files needed by your application. This code also creates a variable named class. path which can be referenced later in your Ant script using the variable syntax ${class. path} .

What is Basedir in build xml?

The 'basedir' is the base directory from which any relative directories used within the Ant build file are referenced from. If this is omitted the parent directory of the build file will be used.

How do you pass an argument to an Ant build?

Discussion. If you want to pass arguments to Ant, you can enter those arguments in the Arguments box of the dialog opened by right-clicking your build file, clicking Run Ant, and clicking the Main tab. You can see that dialog in Figure 7-15 (note that you also can set the build file location and base directory here).


2 Answers

You could add it as an attribute

<java classpath="${extraDir}"
      classname="pkg.Class">
      ...
</java>

Or using the nested <classpath> tag:

<java classname="pkg.Class">
  <classpath>
    <pathelement path="${extraDir}"/>
  </classpath>
</java>

See the documentation for the Java task.

like image 197
aioobe Avatar answered Oct 28 '22 20:10

aioobe


i added the following line in the tag of the task and it ran successfully.

<pathelement path="C:\JunitTest\folderIsHere"/>

and after this the script ran successfully.

like image 41
M.J. Avatar answered Oct 28 '22 21:10

M.J.