Hi Martin, I'm using the execute method from the class org.apache.tools.ant.Project.
Thanks Jay On Mon, Nov 2, 2009 at 4:34 PM, Martin Gainty <mgai...@hotmail.com> wrote: > > any way to take a look at the code for executeTarget > project.executeTarget(taskName);? > Martin Gainty > ______________________________________________ > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht > dient lediglich dem Austausch von Informationen und entfaltet keine > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le > destinataire prévu, nous te demandons avec bonté que pour satisfaire > informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie > de ceci est interdite. Ce message sert à l'information seulement et n'aura > pas n'importe quel effet légalement obligatoire. Étant donné que les email > peuvent facilement être sujets à la manipulation, nous ne pouvons accepter > aucune responsabilité pour le contenu fourni. > > > > > > To: user@ant.apache.org > > From: sjsel...@gmail.com > > Subject: Ant build script executing <sql> task using java code > > Date: Tue, 3 Nov 2009 00:11:56 +0000 > > > > Hi, > > > > When I tried to execute a sql task during server start up using a java > code, it > > completely freezes the app server disabling the users making any further > > request. > > > > Here is the sample code i have (this is a standalone java code in which > nothing > > gets printed after the call to execute the specified task in ant). > > > > <code> > > > > import org.apache.tools.ant.*; > > > > import java.io.*; > > import java.util.*; > > > > > > public class AntRunnerTest > > { > > > > private Project project; > > > > public void executeTask(String taskName){ > > try{ > > project = new Project(); > > > > > > DefaultLogger consoleLogger = new > > DefaultLogger(); > > > consoleLogger.setErrorPrintStream(System.err); > > > consoleLogger.setOutputPrintStream(System.out); > > > > consoleLogger.setMessageOutputLevel(Project.MSG_INFO); > > project.addBuildListener(consoleLogger); > > > > project.fireBuildStarted(); > > project.init(); > > project.setBasedir(new String(".")); > > ProjectHelper helper = > > ProjectHelper.getProjectHelper(); > > project.addReference("ant.projectHelper", > > helper); > > helper.parse(project, new File("build- > > copy.xml")); > > project.executeTarget(taskName); > > project.fireBuildFinished(null); > > }catch(Exception ex){ > > > System.out.println("Exception..."+ex.getMessage()); > > project.fireBuildFinished(ex); > > } > > } > > public static void main(String args[]){ > > try{ > > AntRunnerTest newInst = new AntRunnerTest(); > > System.out.println("Before"); > > newInst.executeTask("sql"); > > System.out.println("After"); > > > > }catch(Exception e){System.out.println(""+e);} > > } > > > > } > > </code> > > and the ant build script > > > > <code> > > <project name="document monitor" basedir="."> > > <property file ="${basedir}/build.properties"/> > > <target name="sql"> > > <sql > > driver="${db.mysql.driver}" > > url="${db.mysql.url}" > > userid="${db.mysql.dtsmonitor.username}" > > password="${db.mysql.dtsmonitor.password}" > > onerror="continue" > > print="true" > > > > > <transaction> <![CDATA[ select now() ]]> > </transaction> > > </sql> > > </target> > > </project> > > > > </code> > > > > > > > > > > The debug string "After" never gets printed in the console. > > > > -Jay > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > > For additional commands, e-mail: user-h...@ant.apache.org > > > > _________________________________________________________________ > Hotmail: Trusted email with Microsoft's powerful SPAM protection. > http://clk.atdmt.com/GBL/go/177141664/direct/01/ > http://clk.atdmt.com/GBL/go/177141664/direct/01/ >