You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by "Preston L. Bannister" <pr...@home.com> on 2001/01/17 04:02:33 UTC

Integrating Ant into JBuilder

I was looking for a way to run Ant from JBuilder
and ran across AntRunner:

  http://www.dieter-bogdoll.de/java/AntRunner/

While this works there are some non-ideal bits...

Ant is run by calling:

  try {
	org.apache.tools.ant.Main.main(splitArgs);
  } catch (SecurityException exp) {
	// Ant tries to System.exit(), that is not allowed and will be catched
here.
  }

Looking to call Ant a bit more directly I took the source
of main() and coded direct calls to the Main() constructor
and runBuild() only to find these are not public...

Going far enough down to get public functions looks way
more complicated than I really need (laziness as a virtue :).

What I'd like to do is make Main() and runBuild() public,
and hook the output streams to feed directly into the IDE
message window.

Am I heading down the wrong path with Ant??

--
Preston L. Bannister
preston@home.com
http://members.home.com/preston/


Re: Integrating Ant into JBuilder

Posted by "Simeon H.K. Fitch" <si...@fitch.net>.
"Preston L. Bannister" wrote:
> 
> I was looking for a way to run Ant from JBuilder
> and ran across AntRunner:
> 
>   http://www.dieter-bogdoll.de/java/AntRunner/
> 

<snip> 

> Looking to call Ant a bit more directly I took the source
> of main() and coded direct calls to the Main() constructor
> and runBuild() only to find these are not public...
> 

<snip> 

> What I'd like to do is make Main() and runBuild() public,
> and hook the output streams to feed directly into the IDE
> message window.
> 
> Am I heading down the wrong path with Ant??
> 

It is well known that Ant is very unfriendly when it comes to embedding
it/using it as an API. On Antidote, I've basically deferred doing
anything "elegant" relative to calling Ant until the core data model is
reimplemented.

However, for another approach to calling Ant from inside another
application, look at the class
org.apache.tools.ant.gui.core.ProjectManager, which is in the Antidote
source directory in CVS (jakarta-ant/src/antidote/...). In there you
will find a method called build() which launches a thread to execute a
build via the Ant "API". 

The way that Antidote is able to feed the output to a console window is
by registering a BuildListener with the Ant core and displaying the
event contents as they are fired. You will find the code to do this also
in the ProjectManager class. The code for the console window is in the
class org.apache.tools.ant.gui.modules.console.Console.


Good luck,

Simeon

-- 
Mustard Seed Software
mailto:simeon@fitch.net
fax:1.309.424.4982

Re: Integrating Ant into JBuilder

Posted by Peter Donald <do...@apache.org>.
At 07:02  16/1/01 -0800, Preston L. Bannister wrote:
>Looking to call Ant a bit more directly I took the source
>of main() and coded direct calls to the Main() constructor
>and runBuild() only to find these are not public...

right ;)

>What I'd like to do is make Main() and runBuild() public,
>and hook the output streams to feed directly into the IDE
>message window.

right - I think that you will find that there is a number of other
"gotchas" with respect to running ant this way. It was never designed for
such embedding and thus there is a lot of access to static resources,
mucking with classloaders, caching data etc. Consequently it may take a bit
of work

For Ant2.0 we are starting afresh and this will be possible (actually
easy-peasy) thou if you try to start doing the same for Ant1.x I am sure it
would be much appreciated. Thou I gotta warn you it isn't easy ;)

>Am I heading down the wrong path with Ant??

nope ;)

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*