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?
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} .
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.
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With