ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Linskey, Patrick" <plins...@techtrader.com>
Subject [PATCH] Easily invoking ant via Java APIs
Date Tue, 10 Apr 2001 00:22:51 GMT
Hello,

I'm integrating ant into an IDE as the primary compilation tool, and
was hoping to be able to trivially invoke ant as if it were invoked
from a shell prompt. Unfortunately, the 'main' method in
org.apache.tools.ant.Main invokes System.exit(), and the Main
constructor and 'runBuild' methods are protected and private,
respectively. 

So, my only option given the standard binaries is to duplicate the
command-line options that ant currently parses, and interface with the
Project class directly. I'd rather not do that, because I'd like the
users of this IDE to pretty much use the ant command line interface
as-is.

For the time being, I have patched Main.java (see patch below) to set
the access for both the constructor and the 'runBuild' method to
public. In the long term, I'd like to see these changes or some
similar mechanism for trivially invoking ant rolled into the Jakarta
sources, so I can ship the IDE with a standard jar rather than a
patched one.


Thanks,

-Patrick



Index: ./src/main/org/apache/tools/ant/Main.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
retrieving revision 1.33
diff -u -r1.33 Main.java
--- ./src/main/org/apache/tools/ant/Main.java	2001/03/16 14:27:12	1.33
+++ ./src/main/org/apache/tools/ant/Main.java	2001/04/10 00:18:49
@@ -159,7 +159,7 @@
         }
     }
 
-    protected Main(String[] args) throws BuildException {
+    public Main(String[] args) throws BuildException {
 
         String searchForThis = null;
 
@@ -364,7 +364,7 @@
     /**
      * Executes the build.
      */
-    private void runBuild() throws BuildException {
+    public void runBuild() throws BuildException {
 
         if (!readyToRun) {
             return;



-- 
Patrick Linskey      plinskey@techtrader.com
Software Engineer    phone: 202.349.2577
TechTrader, Inc.     www.techtrader.com

Mime
View raw message