Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 34237 invoked from network); 27 Apr 2009 19:47:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Apr 2009 19:47:44 -0000 Received: (qmail 55764 invoked by uid 500); 27 Apr 2009 19:47:43 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 55684 invoked by uid 500); 27 Apr 2009 19:47:42 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 55674 invoked by uid 99); 27 Apr 2009 19:47:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2009 19:47:42 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ashpublic@mac.com designates 17.148.16.87 as permitted sender) Received: from [17.148.16.87] (HELO asmtpout012.mac.com) (17.148.16.87) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2009 19:47:33 +0000 MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Received: from [192.168.100.200] ([81.111.142.61]) by asmtp012.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KIR00M5JYXPB790@asmtp012.mac.com> for user@ant.apache.org; Mon, 27 Apr 2009 12:46:51 -0700 (PDT) Message-id: <35F966C7-EC35-4BA7-9F15-B59A969153D1@mac.com> From: Ashley Williams To: Ant Users List In-reply-to: Content-transfer-encoding: quoted-printable Subject: Re: Calling ant programatically Date: Mon, 27 Apr 2009 20:46:33 +0100 References: <47E97D51-4D88-4A6B-B628-6B769CB0011F@mac.com> <54A3D383-AD74-4275-B3D3-A3D9433D4002@mac.com> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org Didn't make any difference. I did however get the stack trace from the =20= ant java task vm and the only non daemon thread dump looks like this: Thread [main] (Suspended)=09 ProcessImpl.waitFor() line: not available [native method]=09 Execute.waitFor(Process) line: 551=09 Execute.execute() line: 482=09 Java.fork(String[]) line: 784=09 Java.executeJava(CommandlineJava) line: 211=09 Java.executeJava() line: 132=09 Java.execute() line: 105=09 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: = not =20 available [native method]=09 NativeMethodAccessorImpl.invoke(Object, Object[]) line: not = available=09 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not =20= available=09 Method.invoke(Object, Object...) line: not available=09 DispatchUtils.execute(Object) line: 106=09 Java(Task).perform() line: 348=09 Target.execute() line: 357=09 Target.performTasks() line: 385=09 Project.executeSortedTargets(Vector) line: 1337=09 Project.executeTarget(String) line: 1306=09 ProtoProject.antTest() line: 105=09 ProtoProject.main(String[]) line: 58=09 On 27 Apr 2009, at 20:13, Martin Gainty wrote: > > in your programmatic call what happens if you put in a > execTask.setFailonerror(true); > execTask.setFailIfExecutionFails(true); > = http://api.dpml.net/ant/1.7.0/org/apache/tools/ant/taskdefs/ExecTask.html#= setFailIfExecutionFails(boolean) > > before the execute() > > public static void main(String[] args) throws IOException > { > // top level project > Project project =3D new Project(); > project.setName("project"); > project.init(); > > // project has a target child > Target target =3D new Target(); > target.setName("target"); > project.addTarget(target); > > // target has an exec child > ExecTask execTask =3D new ExecTask(); > execTask.setProject(project); > execTask.setExecutable("cmd.exe"); > > execTask.setSpawn(true); > > execTask.setDir(new File(".")); > > addArg(execTask, "/c"); > > addArg(execTask, "start"); > > addArg(execTask, "test.bat"); > > execTask.setFailonerror(true); > execTask.setFailIfExecutionFails(true); > > target.addTask(execTask); > target.execute(); > > } > ? > Martin > ______________________________________________ > Disclaimer and Confidentiality/Verzicht und =20 > Vertraulichkeitanmerkung / Note de d=E9ni et de confidentialit=E9 > This message is confidential. If you should not be the intended =20 > receiver, then we ask politely to report. Each unauthorized =20 > forwarding or manufacturing of a copy is inadmissible. This message =20= > serves only for the exchange of information and has no legal binding =20= > effect. Due to the easy manipulation of emails we cannot take =20 > responsibility over the the contents. > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene =20 > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede =20 > unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. =20= > Diese Nachricht dient lediglich dem Austausch von Informationen und =20= > entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten =20 > Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den =20 > Inhalt uebernehmen. > Ce message est confidentiel et peut =EAtre privil=E9gi=E9. Si vous = n'=EAtes =20 > pas le destinataire pr=E9vu, nous te demandons avec bont=E9 que pour =20= > satisfaire informez l'exp=E9diteur. N'importe quelle diffusion non =20 > autoris=E9e ou la copie de ceci est interdite. Ce message sert =E0 =20 > l'information seulement et n'aura pas n'importe quel effet =20 > l=E9galement obligatoire. =C9tant donn=E9 que les email peuvent = facilement =20 > =EAtre sujets =E0 la manipulation, nous ne pouvons accepter aucune =20 > responsabilit=E9 pour le contenu fourni. > > > > > > >> From: ashpublic@mac.com >> To: user@ant.apache.org >> Subject: Re: Calling ant programatically >> Date: Mon, 27 Apr 2009 18:42:04 +0100 >> >> Ok here's a little more context. >> >> It seems that the exec/spawn=3Dtrue command works as expected when >> called on its own directly from java.exe >> but not from an intermediate ant java task, so: >> >> 1. GOOD... When I launch the cmd.exe from a programmatic ant exec >> task, the exec task and java.exe both complete, and the dos window >> remains until I close it ( I've left a large gap in the chain >> description so it lines up with the next example): >> >> >> >> java.exe --- >>> >> = ant >> -exec (spawn=3Dtrue) ---> cmd.exe >> (terminates before dos cmd.exe window is closed) >> >> >> 2. BAD... When I insert an programmatic ant java task, the exec task >> appears to complete but the ant java task doesn't. Then when >> I close the dos window the java.exe process completes also. This is >> despite the ant-exec spawn attribute being true. >> >> >> >> java.exe ---> ant-java (fork=3Dtrue, spawn=3Dfalse) ---> = ant- >> exec (spawn=3Dtrue) ---> cmd.exe >> (terminates only when dos cmd.exe window is closed) >> >> >> I know it looks a little unusual to have the extra ant-java task in >> there but it is necessary for my use-case and I don't have >> the option to set spawn to true for it. Any ideas? >> >> Many Thanks >> - Ashley >> >> >> On 24 Apr 2009, at 13:20, Ashley Williams wrote: >> >>> Hi, >>> >>> I would like to know how to start a batch file in a new dos window >>> without blocking the java process and so naturally I >>> tried the following that does work: >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> However I need to be able to do this from java and so I used the >>> following snippet of code that I thought would >>> represent the same functionality as the ant script: >>> >>> public static void main(String[] args) throws IOException { >>> // top level project >>> Project project =3D new Project(); >>> project.setName("project"); >>> project.init(); >>> >>> // project has a target child >>> Target target =3D new Target(); >>> target.setName("target"); >>> project.addTarget(target); >>> =09 >>> // target has an exec child >>> ExecTask execTask =3D new ExecTask(); >>> execTask.setProject(project); >>> target.addTask(execTask); >>> execTask.setExecutable("cmd.exe"); >>> execTask.setSpawn(true); >>> execTask.setDir(new File(".")); >>> addArg(execTask, "/c"); >>> addArg(execTask, "start"); >>> addArg(execTask, "test.bat"); >>> target.execute(); >>> } >>> >>> However it doesn't matter whether or not I set true of false for the >>> spawn property the java process blocks >>> every time until I close the dos window by hand. Is there something >>> else I need to do to more closely >>> replicate the ant script? >>> >>> Cheers >>> - Ashley >>> >>> = --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org >>> For additional commands, e-mail: user-help@ant.apache.org >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org >> For additional commands, e-mail: user-help@ant.apache.org >> > > _________________________________________________________________ > Rediscover Hotmail=AE: Get quick friend updates right in your inbox. > = http://windowslive.com/RediscoverHotmail?ocid=3DTXT_TAGLM_WL_HM_Rediscover= _Updates2_042009 --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org