aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes ANT: calling a target from another build file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "ANT: calling a target from another build file" Watch "ANT: calling a target from another build file" New topic
Author

ANT: calling a target from another build file

Jeevan Reddy
Ranch Hand

Joined: Nov 10, 2009
Posts: 142
Hi,

I have two ANT build files say A and B.
I want to call one of B's targets from A. I am using <ant> task to do it. But during this I have to add a directory to B's path. How can I do it?

Please tell me how to do it.

Thanks,
Janardhan.


SCJP 1.6 (94%)
http://faq.javaranch.com/java/JspFaq
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

I must be missing something. For the <ant> task you set 'antfile' to "B" and 'dir' to the directory where 'B' is located. I am not sure what it is that you do not know how to do???


JBoss In Action
Jeevan Reddy
Ranch Hand

Joined: Nov 10, 2009
Posts: 142
Peter Johnson wrote:I must be missing something. For the <ant> task you set 'antfile' to "B" and 'dir' to the directory where 'B' is located. I am not sure what it is that you do not know how to do???


Peter, you are correct. I only need to change the path parameter for "B".

Here is the problem, hope I can make clearer this time.

build file "A" takes java from the environment
build file "B" takes java from the environment

"A" should use java1.6 and "B" should use java1.5. Please tell how to achieve this.

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

OK, that is a completly different question than what you asked originally.

You cannot use the <ant> task to do what you want to do. You will have to use the <exec> instead and run another copy of Ant. I recommend writing a script that invokes Ant with the other JVM and calling that script.

Or you can use the <java> task, though setting up the proper environment for Ant might be a pain (you will have to dig through the ant run script to see what all it does and mimic that).

But before you do any of that, tell me why you need to run script B with the 1.5 JVM.
Jeevan Reddy
Ranch Hand

Joined: Nov 10, 2009
Posts: 142
I think I will follow your first suggestion to write a script and invoke ant build file in that script.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

Please read this again and act on it:

But before you do any of that, tell me why you need to run script B with the 1.5 JVM.


Depending on your answer, I could save you a lot of time and effort, and simplify your build process too.
 
jQuery in Action, 2nd edition
 
subject: ANT: calling a target from another build file