From ant-dev-return-12591-apmail-jakarta-ant-dev-archive=jakarta.apache.org@jakarta.apache.org Tue Apr 10 00:23:07 2001 Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 77576 invoked by uid 500); 10 Apr 2001 00:23:04 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 77567 invoked from network); 10 Apr 2001 00:23:03 -0000 To: ant-dev@jakarta.apache.org Subject: [PATCH] Easily invoking ant via Java APIs From: "Linskey, Patrick" Organization: TechTrader, Inc. Date: 09 Apr 2001 20:22:51 -0400 Message-ID: <7td7alob6s.fsf@jsbach.techtrader.com> Lines: 61 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N 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