ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "asaf.lahav" <asaf.la...@gmail.com>
Subject inconsistent behavior when running from Command line console VS using code
Date Tue, 28 Mar 2006 15:35:32 GMT
Hi,

 

I'm having a problem of inconsistent behavior when I'm using ANT for a build
process.

When I'm running a certain build process from a command line console the
build process succeeds. But when I'm running the same build process from
code (using the code snippet below) the same process fails.

The build.xml file I'm talking about has a target called "generate" which
doesn't require any input parameters. All the required info exists in the
build.xml file.

My question is if anyone encountered such inconsistencies?

Is the code I'm using correct?

What could it be that may have influence on the build process when running
it from code VS running the same process from a command line console?

 

Any suggestions are appreciated.

 

            /**

             * activate an ant build process

             * @param buildFilePath a path to an ANT build xml file

             * @param userProperties a map of user properties to be planted
into the ANT xml file

             * @param target A target to be activated in the ANT build xml
file

             * @throws Exception 

             */

            public static void Activate(String buildFilePath, String target)
throws Exception{

                        

                        File buildFile = new File(buildFilePath);

                        Project project = new Project();

                        

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

                        

                        DefaultLogger consoleLogger = new DefaultLogger();

                        consoleLogger.setErrorPrintStream(System.err);

                        consoleLogger.setOutputPrintStream(System.out);

 
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);

                        

                        project.addBuildListener(consoleLogger);

 

                        try {

                                    project.fireBuildStarted();

                                    project.init();

                                    

                                    ProjectHelper helper =
ProjectHelper.getProjectHelper();

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

                                    helper.parse(project, buildFile);

                                    

                                    if(target==null)

 
project.executeTarget(project.getDefaultTarget());

                                    else

 
project.executeTarget(target);

                                    

                                    project.fireBuildFinished(null);

                        } catch (BuildException e) {

                                    project.fireBuildFinished(e);

                                    throw new Exception("Failed while
creating a new service workspace.",e);

                        } catch(Exception e){

                                    throw new Exception("Failed while
creating a new service workspace.",e);

                        }

            }

 

Asaf Lahav

VP R&D, Prima Grid LTD.

Cellular:  972-54-4717955

Phone:   972-3-6540255

Fax:       972-3-6540254



 


Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message