Grüner Heinrich | 12 Jun 2012 21:00

Starting Ant From Java

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();
(Continue reading)


Gmane