DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=40642>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=40642 Summary: [PATCH] Ant.java support for command line options in a subbuild Product: Ant Version: 1.6.5 Platform: All OS/Version: other Status: NEW Severity: enhancement Priority: P2 Component: Core tasks AssignedTo: dev@ant.apache.org ReportedBy: [EMAIL PROTECTED] Adds support for a custom logger in the sub-build, a custom message level in the logger, emacs-mode for the logger, and keep-going-mode for the project. I ran the diff against 1.6.5 but you dev's should look for a few things I left for you (exception handling, mainly). See also bugs 29236 and 36667. Diff output begins... --- Ant-OLD.java Thu Jun 02 15:19:55 2005 +++ Ant-NEW.java Fri Sep 29 11:12:29 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 The Apache Software Foundation + * Copyright 2000-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ */ public class Ant extends Task { - /** the basedir where is executed the build file */ + /** the basedir where is executed the build file */ private File dir = null; /** @@ -76,6 +76,20 @@ /** the output */ private String output = null; + /** class name of logger */ + private String loggerClassName = "org.apache.tools.ant.DefaultLogger"; + + /** message output level */ + private String level = null; + + private int messageOutputLevel = Project.MSG_INFO; + + /** set emacs mode ? */ + private boolean emacsMode = false; + + /** set keep-going mode? */ + private boolean keepGoing = false; + /** should we inherit properties from the parent ? */ private boolean inheritAll = true; @@ -167,14 +181,26 @@ } try { out = new PrintStream(new FileOutputStream(outfile)); - DefaultLogger logger = new DefaultLogger(); - logger.setMessageOutputLevel(Project.MSG_INFO); + Class c = Class.forName(loggerClassName); + BuildLogger logger = (BuildLogger)(c.newInstance()); + logger.setMessageOutputLevel(messageOutputLevel); + logger.setEmacsMode(emacsMode); logger.setOutputPrintStream(out); logger.setErrorPrintStream(out); newProject.addBuildListener(logger); - } catch (IOException ex) { + } + catch (IOException ex) { log("Ant: Can't set output to " + output); } + catch (ClassNotFoundException cnfe) { + /* Ant devs - provide 'catch' code */ + } + catch (IllegalAccessException iae) { + /* Ant devs - provide 'catch' code */ + } + catch (InstantiationException ie) { + /* Ant devs - provide 'catch' code */ + } } getProject().initSubProject(newProject); @@ -331,7 +357,7 @@ } try { - ProjectHelper.configureProject(newProject, new File(antFile)); + ProjectHelper.getProjectHelper().parse(newProject, new File(antFile)); //fixes a deprecations } catch (BuildException ex) { throw ProjectHelper.addLocationToBuildException( ex, getLocation()); @@ -608,6 +634,76 @@ */ public void setOutput(String s) { this.output = s; + } + + /** + * Sets the message output level of the logger to the desired level. The value + * can be any of these strings: INFO, WARNING, ERROR, VERBOSE, or DEBUG. + * @param s the message output level to set the logger to. + * @throws BuildException if the output level argument is not a legal value. + */ + public void setLevel(String s) throws BuildException { + if (s.equalsIgnoreCase("INFO")) { + messageOutputLevel = Project.MSG_INFO; + } + else if (s.equalsIgnoreCase("WARNING")) { + messageOutputLevel = Project.MSG_WARN; + } + else if (s.equalsIgnoreCase("ERROR")) { + messageOutputLevel = Project.MSG_ERR; + } + else if (s.equalsIgnoreCase("VERBOSE")) { + messageOutputLevel = Project.MSG_VERBOSE; + } + else if (s.equalsIgnoreCase("DEBUG")) { + messageOutputLevel = Project.MSG_DEBUG; + } + else { + throw new BuildException("Unsupported message output level. "+ + "Specify any of: ERROR, WARNING, INFO, VERBOSE, DEBUG."); + } + level = s; + log("Setting log message level to "+level, Project.MSG_DEBUG); + } + + /** + * Set the logger to that of the specified class name. This logger must + * implement the BuildLogger interface. + * @param s the fully-resolved class name to use for logging. + */ + public void setLoggerClassName(String s) throws BuildException { + try { + Class c = Class.forName(s); + if (! c instanceof BuildLogger) { + throw new BuildException("The specified logger class " + s + + " does not implement the BuildLogger interface"); + } + } catch (Exception e) { + throw new BuildException("Unable to instantiate specified logger " + + "class " + s + " : " + e.getClass().getName()); + } + + loggerClassName = s; + log("Setting logger to instance of "+loggerClassName,Project.MSG_DEBUG); + } + + /** + * Sets whether the logger should use Emacs mode. + * @param b boolean value indicating whether Emacs mode should be enabled. + */ + public void setEmacsMode(boolean b) { + emacsMode = b; + log("Setting emacs mode to "+(b?"true":"false"),Project.MSG_DEBUG); + } + + /** + * Sets whether the sub-project should have its "keep going" mode enabled. + * @param b boolean value indicating whether sub-project should keep-going + * after an exception is encountered, if the project may do so. + */ + public void setKeepGoing(boolean b) { + keepGoing = b; + log("Setting keep-going mode to "+(b?"true":"false"),Project.MSG_DEBUG); } /** -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]