ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GrĂ¼ner Heinrich <gruener.heinr...@googlemail.com>
Subject Starting Ant From Java
Date Tue, 12 Jun 2012 19:00:35 GMT
Hi User List,

I try to start an Ant Buildfile from Java.
Unfortunately Ant is not able to load custom ant tasks, although I try 
to set the classloader for the thread.

Here is the code snip I use.

     public static void startForNode(final AntRunnerNode ar,boolean wait) {
         Thread t=new Thread() {
             public void run() {
                 try {
                     Project project=new Project();
                     project.init();
                     project.setSystemProperties();

                     ProjectHelper.configureProject(project, 
ar.getBuildFile());

                     project.executeTarget(ar.getTargetName());
                 } catch (Exception e) {
                     e.printStackTrace();
                 }

             }
         };
         
t.setContextClassLoader(Thread.currentThread().getContextClassLoader());
         if (wait) {
             t.run();
         } else {
             t.start();
         }
     }


Any help appreciated.
Thanks,
Stefan.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message