aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes ANT file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "ANT file" Watch "ANT file" New topic
Author

ANT file

bhaveshkumar chaudhari
Greenhorn

Joined: Nov 14, 2008
Posts: 3
I'm doing automation of testing. I have a build.xml(ant file) which in turn compiles the code. But the problem is how to execute the command so that file code will get compiled automatically.


Thanks,<br />Bhaveshkumar Chaudhari
aleem khan
Ranch Hand

Joined: Aug 07, 2008
Posts: 94
command to execute:

ant -f build.xml compile

where compile is the target name in your ant file


SCJP(1.4), SCWCD, Oracle 9i SQL certified, Oracle PLSQL Developer Certified Associate
bhaveshkumar chaudhari
Greenhorn

Joined: Nov 14, 2008
Posts: 3
Hi Aleem,

Thanks for the reply. I'm still confused. In the command given by you "ant -f build.xml compile" compile is the target name in your ant file. I have build.xml at some location. If we do it manually we give the path of the build file in command prompt and type 'ant' and run the build.xml the same thing I want to do with java program. I mean to say my program won't depend upon the content of the build file.
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

<project name="MyProject" default="dist" basedir=".">

for default attribute give the target compile or whatever you want to run as default target.


My Blog SCJP 5 SCWCD 5
Manish Doomra
Greenhorn

Joined: Sep 05, 2008
Posts: 21
Originally posted by bhaveshkumar chaudhari:
I'm doing automation of testing. I have a build.xml(ant file) which in turn compiles the code. But the problem is how to execute the command so that file code will get compiled automatically.


According, to my understanding, what you want to do is:-
1) Want to Compile your java classes(source code)
2) Confused about what target to call for compilation of your code

Now, as you say that you already have build file named- build.xml, In your build file look for project tag which will be written as


In the above piece of code, in project tag, default target name is mentioned, so it will be called by default if you do not mention any target name with ant command.

if the build file name is build.xml, then no need to mention the build file name, so your command to execute the default target would be 'ant'.

And in default target above, the javac task is called, which does the compilation thing.

For more about ant visit here:- Ant Manual

Let me know, if your query got solved...


Manish Doomra
bhaveshkumar chaudhari
Greenhorn

Joined: Nov 14, 2008
Posts: 3
Thanks all for showing interest. Finally I got the solution from my lead. I created one batch file named "compile.bat" which looks like this,

@echo off

cd %1%

ant

Then I executed the command "Process process = Runtime.getRuntime().exec(sb.toString());" where sb is the string buffer which holds the path of the compile.bat and build.xml.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ANT file