Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

ANT file

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
command to execute:

ant -f build.xml compile

where compile is the target name in your ant file
 
bhaveshkumar chaudhari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<project name="MyProject" default="dist" basedir=".">

for default attribute give the target compile or whatever you want to run as default target.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
bhaveshkumar chaudhari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic