2 Replies Latest reply: Dec 2, 2013 12:07 AM by shaz90 RSS

    Run Ant script using Java in webcenter portal

    shaz90

      Hi all,

       

      I have requirement where in i have to execute an ant script using java or any means in webcenter portal.

      Ant script should be executed upon an action trigger.

      Please help me towards this.

       

       

      Thanks & regards,

      Shakir

        • 2. Re: Run Ant script using Java in webcenter portal
          shaz90

          Hey all,

          Here is the solution, that i got finally

           

                      File buildFile = new File("myBuild.xml");

                    

                      Project p = new Project();

                      p.setUserProperty("ant.file", buildFile.getAbsolutePath());

                

                      DefaultLogger consoleLogger = new DefaultLogger();

                      consoleLogger.setErrorPrintStream(System.err);

                      consoleLogger.setOutputPrintStream(System.out);

                      consoleLogger.setMessageOutputLevel(Project.MSG_INFO);

                      p.addBuildListener(consoleLogger);

                      p.init();

                      ProjectHelper helper = ProjectHelper.getProjectHelper();

                      p.addReference("ant.projectHelper", helper);

                      helper.parse(p, buildFile);

                      p.executeTarget(p.getDefaultTarget());

                

          Regards,

          Shakir