Have you tried using the deprecated method "ph.configureProject(p, new
File("build-test.xml"));" instead of "ph.parse(p, new
File("build-test.xml"));"


Best Regards,

Praful Aggarwal
[EMAIL PROTECTED]
Ph : +353-1-6659256

"There are only 10 types of people in the world. Those that understand
Binary, and those that don't."


                                                                                
                                      
                      Andy Kriger                                               
                                      
                      <[EMAIL PROTECTED]        To:       Ant Users List 
<[email protected]>                         
                      l.com>                   cc:                              
                                      
                                               Subject:  Re: How can I execute 
Ant targets from within a Java         
                      24/01/2005 02:33          program?                        
                                      
                      Please respond to                                         
                                      
                      "Ant Users List"                                          
                                      
                                                                                
                                      
                                                                                
                                      




Still no luck. I'm including my code and build files to see if that
gives anyone ideas. If you comment out the import statement the main
method works fine.

Here's my main method...
public static void main(String[] args) {
                         BuildLogger logger = new DefaultLogger();
                         logger.setMessageOutputLevel(Project.MSG_INFO);
                         logger.setOutputPrintStream(System.out);
                         logger.setErrorPrintStream(System.out);
                         logger.setEmacsMode(true);

                         ProjectHelper ph =
ProjectHelper.getProjectHelper();
                         Project p = new Project();
                         p.addBuildListener(logger);
                         p.setUserProperty("ant.home",
"/usr/share/ant-core");
                         p.setUserProperty("ant.version", "1.6.2");
                         p.setKeepGoingMode(true);
                         p.init();
                         ph.parse(p, new File("build-test.xml"));
             }

Here's build-test.xml...
<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="default" basedir=".">
    <description>Test script</description>
    <import file="./build-import.xml"/>
    <target name="default" depends="shout">
        <echo message="i am the default target"/>
    </target>
    <target name="shout">
        <echo message="shouting"/>
    </target>
</project>

Here's build-import.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="myImport" default="import-default" basedir=".">
    <description>Imported script</description>
    <target name="import-default">
        <echo message="i am the default target"/>
    </target>
</project>



On Sun, 23 Jan 2005 17:52:22 -0800, Alexey N. Solofnenko
<[EMAIL PROTECTED]> wrote:
> You need to set ant.home Java property, not the environment variable, if
> you want to launch ANT yourself.
>
> - Alexey.
>
> Andy Kriger wrote:
>
> >I am playing around with executing Ant targets from Java code.
> >
> >Here's what I am trying to do (based on what I've seen in mailing list
posts)...
> >
> >       public static void main(String[] args) {
> >               ProjectHelper ph = ProjectHelper.getProjectHelper();
> >               Project p = new Project();
> >               ph.parse(p, new java.io.File("build.xml"));
> >               System.out.println(p.getBaseDir());
> >               System.out.println(p.getDefaultTarget());
> >       }
> >
> >But I get ...
> >Exception in thread "main" build.xml:6: Could not create task or type
> >of type: description.
> >
> >The $ANT_HOME env var is set and I have all of the $ANT_HOME/lib dirs
> >on my classpath. So, either that's not the way to create an in-memory
> >version of a build script that can be called from code or there's
> >something more I need to do with my classpath so that the
> >ProjectHelper can find all the JARs.
> >
> >Can anyone point me in the right direction?
> >
> >thx
> >andy
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> --
> ------------------------------------------------------------------------
> / Alexey N. Solofnenko
> home: http://trelony.cjb.net/
> /
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








*******************************************************************
 The information contained in this communication is intended solely
 for the use of the individual or entity to whom it is addressed. 
 It may contain confidential or legally privileged information.   
 If you are not the intended recipient you are hereby notified that
 any disclosure, copying,  distribution or taking any action in 
 reliance on the contents of this information is strictly 
 prohibited and may be unlawful.  If you have received this 
 communication in error, please notify us immediately by responding
 to this email and then delete it from your system.  
 
 Any personal opinions expressed in this e-mail are views of the 
 individual and do not necessarily reflect the views of the EBS 
 Building Society.   The content of this e-mail may have been sent 
 without the authority of the EBS.
 
 EBS cannot guarantee that this e-mail and attachments are free of 
 viruses and you must ensure that you carry out your own virus 
 checks. EBS accepts no liability for any loss or damage caused by 
 software viruses.
 
 www.ebs.ie

*******************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to