You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Sungho Maeung <sm...@dawning.com> on 2007/01/03 21:03:01 UTC
Problem with startAnt()
Dear Ant User Group.
I am having a problem to execute Ant via Java. After startAnt()
executed, the Hello.xml was done successfully, but it does not go
though the next step which supports to be printing out the output
"Hello, it is done".
another strange thing is when i run it on Dos command line as "C:\>ant
-f Hello\Hello.xml", it finished properly. Only it does not happen via Java
Does anyone know about this issue ? Do I need to something that I do not
know? I have researched theUserGroup , and Ant manual , but I could not
find any useful information to resolve this problem.
I am looking forward to hearing from any of you.
Thanks
Sungho
===========================================================
String[] args = new String[2];
args[0] = new String("-f") ;
args[1] = new String ("Hello\Hello.xml");
org.apache.tools.ant.launch.AntMain a_oAntExe = new
org.apache.tools.ant.Main();
a_oAntExe.startAnt(args, null, null);
System.out.println("Hello, it is done");
===========================================================
Hello.xml
------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="hibernate-reveng" name="HibernateTools">
<target name="hibernate-reveng">
<taskdef classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib" name="hibernatetool" />
<hibernatetool destdir="C:\projects\sniplus-main-10272006">
<jdbcconfiguration packagename="HibernateCfg.Hello"
propertyfile="C:\projects\sniplus-main-10272006\HibernateCfg\Hello\Hello.properties"
/>
<hbm2hbmxml destdir="C:\projects\sniplus-main-10272006" />
<hbm2java />
</hibernatetool>
</target>
</project>
----------------------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Problem with startAnt()
Posted by Steve Loughran <st...@apache.org>.
Sungho Maeung wrote:
> Dear Ant User Group.
>
> I am having a problem to execute Ant via Java. After startAnt()
> executed, the Hello.xml was done successfully, but it does not go
> though the next step which supports to be printing out the output
> "Hello, it is done".
>
> another strange thing is when i run it on Dos command line as "C:\>ant
> -f Hello\Hello.xml", it finished properly. Only it does not happen via Java
> Does anyone know about this issue ? Do I need to something that I do not
> know? I have researched theUserGroup , and Ant manual , but I could not
> find any useful information to resolve this problem.
>
> I am looking forward to hearing from any of you.
>
> Thanks
> Sungho
>
> ===========================================================
> String[] args = new String[2];
> args[0] = new String("-f") ;
> args[1] = new String ("Hello\Hello.xml");
> org.apache.tools.ant.launch.AntMain a_oAntExe = new
> org.apache.tools.ant.Main();
> a_oAntExe.startAnt(args, null, null);
> System.out.println("Hello, it is done");
> ===========================================================
>
> Hello.xml
> ------------------------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project basedir="." default="hibernate-reveng" name="HibernateTools">
> <target name="hibernate-reveng">
> <taskdef classname="org.hibernate.tool.ant.HibernateToolTask"
> classpathref="toolslib" name="hibernatetool" />
> <hibernatetool destdir="C:\projects\sniplus-main-10272006">
> <jdbcconfiguration packagename="HibernateCfg.Hello"
> propertyfile="C:\projects\sniplus-main-10272006\HibernateCfg\Hello\Hello.properties"
> />
> <hbm2hbmxml destdir="C:\projects\sniplus-main-10272006" />
> <hbm2java />
> </hibernatetool>
> </target>
> </project>
> ----------------------------------------------------------------------------------------
when it ships, Ant in Action will show you how to embed ant inside your
app. If you cannot wait until may, you can look at the code to do it,
which is in sourceforge:
http://antbook.cvs.sourceforge.net/antbook/examples/sections/extending/ch18_extras/embed/
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Problem with startAnt()
Posted by trad-ex <tr...@inter7.jp>.
Hi, Sungho
org.apache.tools.ant.Main#startAnt calls System.exit(0) internally.
So, the Java process was terminated, IMHO.
You should use org.apache.tools.ant.Project#executeTarget( String ), or
org.apache.tools.ant.Project#executeTargets( Vector )
Best Regards,
trad-ex
>Dear Ant User Group.
>
>I am having a problem to execute Ant via Java. After startAnt()
>executed, the Hello.xml was done successfully, but it does not go
>though the next step which supports to be printing out the output
>"Hello, it is done".
>
>another strange thing is when i run it on Dos command line as "C:\>ant
>-f Hello\Hello.xml", it finished properly. Only it does not happen via Java
>Does anyone know about this issue ? Do I need to something that I do not
>know? I have researched theUserGroup , and Ant manual , but I could not
>find any useful information to resolve this problem.
>
>I am looking forward to hearing from any of you.
>
>Thanks
>Sungho
>
>===========================================================
> String[] args = new String[2];
> args[0] = new String("-f") ;
> args[1] = new String ("Hello\Hello.xml");
> org.apache.tools.ant.launch.AntMain a_oAntExe = new
>org.apache.tools.ant.Main();
>a_oAntExe.startAnt(args, null, null);
> System.out.println("Hello, it is done");
>===========================================================
>
>Hello.xml
>---------------------------------------------------------------------------
>---------------
>
><?xml version="1.0" encoding="UTF-8"?>
><project basedir="." default="hibernate-reveng" name="HibernateTools">
> <target name="hibernate-reveng">
> <taskdef classname="org.hibernate.tool.ant.HibernateToolTask"
>classpathref="toolslib" name="hibernatetool" />
> <hibernatetool destdir="C:\projects\sniplus-main-10272006">
> <jdbcconfiguration packagename="HibernateCfg.Hello"
>propertyfile="C:\projects\sniplus-main-10272006\HibernateCfg\Hello\Hello.
>properties"
>/>
> <hbm2hbmxml destdir="C:\projects\sniplus-main-10272006" />
> <hbm2java />
> </hibernatetool>
> </target>
></project>
>---------------------------------------------------------------------------
>-------------
>
>
>
>---------------------------------------------------------------------
>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