diff --git a/src/main/org/apache/tools/ant/BuildEvent.java b/src/main/org/apache/tools/ant/BuildEvent.java index 4f58fee20..60acd0449 100644 --- a/src/main/org/apache/tools/ant/BuildEvent.java +++ b/src/main/org/apache/tools/ant/BuildEvent.java @@ -61,29 +61,52 @@ public class BuildEvent extends EventObject { private Target target; private Task task; private String message; - private int priority; + private int priority = Project.MSG_VERBOSE; private Throwable exception; + /** - * Constructs a new build event. Fields that are not relevant - * can be set to null, except for the project field which is - * required. + * Construct a BuildEvent for a project level event + * + * @param project the project that emitted the event. */ - public BuildEvent( - Project project, - Target target, - Task task, - String message, - int priority, - Throwable exception) { - - super(getSource(project, target, task)); - + public BuildEvent(Project project) { + super(project); this.project = project; + this.target = null; + this.task = null; + } + + /** + * Construct a BuildEvent for a target level event + * + * @param target the target that emitted the event. + */ + public BuildEvent(Target target) { + super(target); + this.project = target.getProject(); this.target = target; + this.task = null; + } + + /** + * Construct a BuildEvent for a task level event + * + * @param task the task that emitted the event. + */ + public BuildEvent(Task task) { + super(task); + this.project = task.getProject(); + this.target = task.getTarget(); this.task = task; + } + + public void setMessage(String message, int priority) { this.message = message; this.priority = priority; + } + + public void setException(Throwable exception) { this.exception = exception; } @@ -98,6 +121,7 @@ public class BuildEvent extends EventObject { * Returns the target that fired this event. */ public Target getTarget() { + return target; } @@ -139,15 +163,4 @@ public class BuildEvent extends EventObject { public Throwable getException() { return exception; } - - /** - * Returns the object that fired this event. - */ - private static Object getSource(Project project, Target target, Task task) { - if (task != null) return task; - if (target != null) return target; - if (project != null) return project; - - throw new IllegalArgumentException("Project field cannot be null"); - } } \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index b28b5be5e..abeb153df 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -104,8 +104,6 @@ public class Project { private File baseDir; private Vector listeners = new Vector(); - protected Target currentTarget = null; - protected Task currentTask = null; public Project() { } @@ -170,11 +168,15 @@ public class Project { } public void log(String msg, int msgLevel) { - fireMessageLogged(msg, msgLevel); + fireMessageLogged(this, msg, msgLevel); } - public void log(String msg, String tag, int msgLevel) { - fireMessageLogged(msg, msgLevel); + public void log(Task task, String msg, int msgLevel) { + fireMessageLogged(task, msg, msgLevel); + } + + public void log(Target target, String msg, int msgLevel) { + fireMessageLogged(target, msg, msgLevel); } public void setProperty(String name, String value) { @@ -708,20 +710,15 @@ public class Project { public void runTarget(Target target) throws BuildException { - currentTarget = target; - try { - fireTargetStarted(); - currentTarget.execute(); - fireTargetFinished(null); + fireTargetStarted(target); + target.execute(); + fireTargetFinished(target, null); } catch(RuntimeException exc) { - fireTargetFinished(exc); + fireTargetFinished(target, exc); throw exc; } - finally { - currentTarget = null; - } } /** @@ -849,7 +846,7 @@ public class Project { } protected void fireBuildStarted() { - BuildEvent event = createBuildEvent(); + BuildEvent event = new BuildEvent(this); for (int i = 0; i < listeners.size(); i++) { BuildListener listener = (BuildListener) listeners.elementAt(i); listener.buildStarted(event); @@ -857,62 +854,67 @@ public class Project { } protected void fireBuildFinished(Throwable exception) { - BuildEvent event = createBuildEvent(exception); + BuildEvent event = new BuildEvent(this); + event.setException(exception); for (int i = 0; i < listeners.size(); i++) { BuildListener listener = (BuildListener) listeners.elementAt(i); listener.buildFinished(event); } } - protected void fireTargetStarted() { - BuildEvent event = createBuildEvent(); + protected void fireTargetStarted(Target target) { + BuildEvent event = new BuildEvent(target); for (int i = 0; i < listeners.size(); i++) { BuildListener listener = (BuildListener) listeners.elementAt(i); listener.targetStarted(event); } } - protected void fireTargetFinished(Throwable exception) { - BuildEvent event = createBuildEvent(exception); + protected void fireTargetFinished(Target target, Throwable exception) { + BuildEvent event = new BuildEvent(target); + event.setException(exception); for (int i = 0; i < listeners.size(); i++) { BuildListener listener = (BuildListener) listeners.elementAt(i); listener.targetFinished(event); } } - protected void fireTaskStarted() { - BuildEvent event = createBuildEvent(); + protected void fireTaskStarted(Task task) { + BuildEvent event = new BuildEvent(task); for (int i = 0; i < listeners.size(); i++) { BuildListener listener = (BuildListener) listeners.elementAt(i); listener.taskStarted(event); } } - protected void fireTaskFinished(Throwable exception) { - BuildEvent event = createBuildEvent(exception); + protected void fireTaskFinished(Task task, Throwable exception) { + BuildEvent event = new BuildEvent(task); for (int i = 0; i < listeners.size(); i++) { BuildListener listener = (BuildListener) listeners.elementAt(i); listener.taskFinished(event); } } - protected void fireMessageLogged(String message, int priority) { - BuildEvent event = createBuildEvent(message, priority); + private void fireMessageLoggedEvent(BuildEvent event, String message, int priority) { + event.setMessage(message, priority); for (int i = 0; i < listeners.size(); i++) { BuildListener listener = (BuildListener) listeners.elementAt(i); listener.messageLogged(event); } } - public BuildEvent createBuildEvent() { - return new BuildEvent(this, currentTarget, currentTask, null, MSG_VERBOSE, null); + protected void fireMessageLogged(Project project, String message, int priority) { + BuildEvent event = new BuildEvent(project); + fireMessageLoggedEvent(event, message, priority); } - public BuildEvent createBuildEvent(String msg, int priority) { - return new BuildEvent(this, currentTarget, currentTask, msg, priority, null); + protected void fireMessageLogged(Target target, String message, int priority) { + BuildEvent event = new BuildEvent(target); + fireMessageLoggedEvent(event, message, priority); } - public BuildEvent createBuildEvent(Throwable exception) { - return new BuildEvent(this, currentTarget, currentTask, null, MSG_VERBOSE, exception); + protected void fireMessageLogged(Task task, String message, int priority) { + BuildEvent event = new BuildEvent(task); + fireMessageLoggedEvent(event, message, priority); } } diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index b527f789b..d1eaa4fe0 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -327,11 +327,9 @@ public class ProjectHelper { public void init(String tag, AttributeList attrs) throws SAXParseException { task = project.createTask(tag); - project.currentTask = task; configure(task, attrs); task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(), locator.getColumnNumber())); task.init(); - project.currentTask = null; // Top level tasks don't have associated targets if (target != null) { diff --git a/src/main/org/apache/tools/ant/Target.java b/src/main/org/apache/tools/ant/Target.java index 8d0f121b0..a3ae35c0f 100644 --- a/src/main/org/apache/tools/ant/Target.java +++ b/src/main/org/apache/tools/ant/Target.java @@ -123,24 +123,20 @@ public class Target { Task task = (Task) enum.nextElement(); try { - project.currentTask = task; - project.fireTaskStarted(); + project.fireTaskStarted(task); task.execute(); - project.fireTaskFinished(null); + project.fireTaskFinished(task, null); } catch(RuntimeException exc) { if (exc instanceof BuildException) { ((BuildException)exc).setLocation(task.getLocation()); } - project.fireTaskFinished(exc); + project.fireTaskFinished(task, exc); throw exc; } - finally { - project.currentTask = null; - } } } else { - project.log("Skipped because property '" + this.condition + "' not set.", this.name, Project.MSG_VERBOSE); + project.log(this, "Skipped because property '" + this.condition + "' not set.", Project.MSG_VERBOSE); } } } diff --git a/src/main/org/apache/tools/ant/Task.java b/src/main/org/apache/tools/ant/Task.java index daf7fc1d2..a051c5672 100644 --- a/src/main/org/apache/tools/ant/Task.java +++ b/src/main/org/apache/tools/ant/Task.java @@ -77,6 +77,15 @@ public abstract class Task { this.project = project; } + /** + * Get the Project to which this task belongs + * + * @param the task's project. + */ + public Project getProject() { + return project; + } + /** * Sets the target object of this task. * @@ -86,6 +95,35 @@ public abstract class Task { this.target = target; } + /** + * Get the Target to which this task belongs + * + * @param the task's target. + */ + public Target getTarget() { + return target; + } + + /** + * Log a message with the default (INFO) priority. + * + * @param the message to be logged. + */ + public void log(String msg) { + log(msg, Project.MSG_INFO); + } + + /** + * Log a mesage with the give priority. + * + * @param the message to be logged. + * @param msgLevel the message priority at which this message is to be logged. + */ + public void log(String msg, int msgLevel) { + project.log(this, msg, msgLevel); + } + + /** Sets a description of the current action. It will be usefull in commenting * what we are doing. */ diff --git a/src/main/org/apache/tools/ant/TaskAdapter.java b/src/main/org/apache/tools/ant/TaskAdapter.java index cfb83e554..852efae93 100644 --- a/src/main/org/apache/tools/ant/TaskAdapter.java +++ b/src/main/org/apache/tools/ant/TaskAdapter.java @@ -76,13 +76,13 @@ public class TaskAdapter extends Task { Class c=proxy.getClass(); executeM=c.getMethod( "execute", new Class[0] ); if( executeM == null ) { - project.log("No execute in " + proxy.getClass(), "TaskAdapter", project.MSG_ERR); + log("No execute in " + proxy.getClass(), Project.MSG_ERR); throw new BuildException("No execute in " + proxy.getClass()); } executeM.invoke(proxy, null); return; } catch( Exception ex ) { - project.log("Error in " + proxy.getClass(), "TaskAdapter", project.MSG_ERR); + log("Error in " + proxy.getClass(), Project.MSG_ERR); throw new BuildException( ex ); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java index 7ee143031..96923ea04 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -100,7 +100,7 @@ public class Ant extends Task { p1.addBuildListener(new DefaultLogger(out, Project.MSG_INFO)); } catch( IOException ex ) { - project.log( "Ant: Can't set output to " + output ); + log( "Ant: Can't set output to " + output ); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java index 470270d13..5bd0ac778 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Available.java +++ b/src/main/org/apache/tools/ant/taskdefs/Available.java @@ -76,9 +76,9 @@ public class Available extends Task { } public void setClass(String classname) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); + log("The class attribute is deprecated. " + + "Please use the classname attribute.", + Project.MSG_WARN); this.classname = classname; } @@ -107,7 +107,7 @@ public class Available extends Task { File f = new File(file); return f.exists(); } catch (Exception e) { - project.log(e.toString(), "available", Project.MSG_VERBOSE); + log(e.toString(), Project.MSG_VERBOSE); return false; } } @@ -121,7 +121,7 @@ public class Available extends Task { Class.forName(classname); return true; } catch (Throwable t) { - project.log(t.toString(), "available", Project.MSG_VERBOSE); + log(t.toString(), Project.MSG_VERBOSE); return false; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Chmod.java b/src/main/org/apache/tools/ant/taskdefs/Chmod.java index 5595f9879..4e3fe4c74 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Chmod.java +++ b/src/main/org/apache/tools/ant/taskdefs/Chmod.java @@ -81,9 +81,9 @@ public class Chmod extends MatchingTask { } public void setSrc(String src) { - project.log("The src attribute is deprecated. " + - "Please use the file attribute.", - Project.MSG_WARN); + log("The src attribute is deprecated. " + + "Please use the file attribute.", + Project.MSG_WARN); setFile(src); } @@ -100,7 +100,7 @@ public class Chmod extends MatchingTask { if (srcFile != null && srcDir == null) { chmod(srcFile.toString()); } else if(srcFile == null && srcDir == null) { - project.log("The attribute 'file' or 'dir' needs to be set.", Project.MSG_WARN); + log("The attribute 'file' or 'dir' needs to be set.", Project.MSG_WARN); throw new BuildException("Required attribute not set in Chmod", location); } else if(srcFile == null && srcDir != null) { @@ -114,7 +114,7 @@ public class Chmod extends MatchingTask { } } catch (IOException ioe) { // ignore, but warn - project.log("Error in Chmod " + ioe.toString() , Project.MSG_WARN); + log("Error in Chmod " + ioe.toString() , Project.MSG_WARN); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Copydir.java b/src/main/org/apache/tools/ant/taskdefs/Copydir.java index 830491714..393a2b355 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copydir.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copydir.java @@ -105,8 +105,8 @@ public class Copydir extends MatchingTask { String[] files = ds.getIncludedFiles(); scanDir(srcDir, destDir, files); if (filecopyList.size() > 0) { - project.log("Copying " + filecopyList.size() + " files to " - + destDir.getAbsolutePath()); + log("Copying " + filecopyList.size() + " files to " + + destDir.getAbsolutePath()); Enumeration enum = filecopyList.keys(); while (enum.hasMoreElements()) { String fromFile = (String) enum.nextElement(); diff --git a/src/main/org/apache/tools/ant/taskdefs/Delete.java b/src/main/org/apache/tools/ant/taskdefs/Delete.java index 3f484a28b..2e35893f4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Delete.java +++ b/src/main/org/apache/tools/ant/taskdefs/Delete.java @@ -1,37 +1,37 @@ /* * The Apache Software License, Version 1.1 - * + * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * + * notice, this list of conditions and the following disclaimer. + * * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -45,7 +45,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== - * + * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see @@ -54,105 +54,103 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.*; - import java.io.*; /** * Deletes a single file or a set of files defined by a pattern. - * + * * @author stefano@apache.org * @author Tom Dimock tad1@cornell.edu */ public class Delete extends MatchingTask { + private File delDir = null; + private int verbosity = Project.MSG_VERBOSE; + private File f = null; + + /** + * Set the name of a single file to be removed. + * + * @param file the file to be deleted + */ + public void setFile(String file) { + f = project.resolveFile(file); + } + + /** + * Set the directory from which files are to be deleted + * + * @param dir the directory path. + */ + public void setDir(String dir) { + delDir = project.resolveFile(dir); + } + + /** + * Used to force listing of all names of deleted files. + * + * @param verbose "true" or "on" + */ + public void setVerbose(String verbose) { + if ("true".equalsIgnoreCase(verbose.trim()) || "on".equalsIgnoreCase(verbose.trim())) { + this.verbosity = Project.MSG_INFO; + } else { + this.verbosity = Project.MSG_VERBOSE; + } + } + + /** + * Make it so. Delete the file(s). + * + * @throws BuildException + */ + public void execute() throws BuildException { + if (f == null && delDir == null) { + throw new BuildException(" or attribute must be set!"); + } + + // old functionality must still work + if (f != null) { + if (f.exists()) { + if (f.isDirectory()) { + log("Directory: " + f.getAbsolutePath() + " cannot be removed with delete. Use Deltree instead."); + } else { + log("Deleting: " + f.getAbsolutePath()); + + if (!f.delete()) { + throw new BuildException("Unable to delete file " + f.getAbsolutePath()); + } + } + } + } + + // now we'll do the fancy pattern-driven deletes + if (delDir == null) { + return; + } + + if (!delDir.exists()) { + throw new BuildException("dir does not exist!"); + } + + DirectoryScanner ds = super.getDirectoryScanner(delDir); + String[] files = ds.getIncludedFiles(); + + if (files.length > 0) { + log("Deleting " + files.length + " files from " + delDir.getAbsolutePath()); + + for (int i = 0; i < files.length; i++) { + File f = new File(delDir, files[i]); + + if (f.exists()) { + log("Deleting: " + f.getAbsolutePath(), verbosity); + + if (!f.delete()) { + throw new BuildException("Unable to delete " + f.getAbsolutePath()); + } + } + } + } + } - private File delDir = null; - private int verbosity = project.MSG_VERBOSE; - private File f = null; - - /** - * Set the name of a single file to be removed. - * - * @param file the file to be deleted - */ - public void setFile(String file) { - f = project.resolveFile(file); - } - - /** - * Set the directory from which files are to be deleted - * - * @param dir the directory path. - */ - public void setDir(String dir) { - delDir = project.resolveFile(dir); - } - - /** - * Used to force listing of all names of deleted files. - * - * @param verbose "true" or "on" - */ - public void setVerbose(String verbose) { - - if ("true".equalsIgnoreCase(verbose.trim()) || "on".equalsIgnoreCase(verbose.trim())) { - this.verbosity = project.MSG_INFO; - } - else { - this.verbosity = project.MSG_VERBOSE; - } - } - - /** - * Make it so. Delete the file(s). - * - * @throws BuildException - */ - public void execute() throws BuildException { - - if (f == null && delDir == null) { - throw new BuildException(" or attribute must be set!"); - } - - // old functionality must still work - if (f != null) { - if (f.exists()) { - if (f.isDirectory()) { - project - .log("Directory: " + f.getAbsolutePath() - + " cannot be removed with delete. Use Deltree instead."); - } - else { - project.log("Deleting: " + f.getAbsolutePath()); - if (!f.delete()) { - throw new BuildException("Unable to delete file " + f.getAbsolutePath()); - } - } - } - } - - // now we'll do the fancy pattern-driven deletes - if (delDir == null) { - return; - } - if (!delDir.exists()) { - throw new BuildException("dir does not exist!"); - } - DirectoryScanner ds = super.getDirectoryScanner(delDir); - String[] files = ds.getIncludedFiles(); - - if (files.length > 0) { - project.log("Deleting " + files.length + " files from " + delDir.getAbsolutePath()); - for (int i = 0; i < files.length; i++) { - File f = new File(delDir, files[i]); - - if (f.exists()) { - project.log("Deleting: " + f.getAbsolutePath(), verbosity); - if (!f.delete()) { - throw new BuildException("Unable to delete " + f.getAbsolutePath()); - } - } - } - } - } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Deltree.java b/src/main/org/apache/tools/ant/taskdefs/Deltree.java index a0a355100..46700a934 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Deltree.java +++ b/src/main/org/apache/tools/ant/taskdefs/Deltree.java @@ -72,7 +72,7 @@ public class Deltree extends Task { } public void execute() throws BuildException { - project.log("Deleting: " + dir.getAbsolutePath()); + log("Deleting: " + dir.getAbsolutePath()); if (dir.exists()) { if (!dir.isDirectory()) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Exec.java b/src/main/org/apache/tools/ant/taskdefs/Exec.java index b15fdc58c..af1629e25 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Exec.java +++ b/src/main/org/apache/tools/ant/taskdefs/Exec.java @@ -83,10 +83,10 @@ public class Exec extends Task { // test if os match String myos = System.getProperty("os.name"); - project.log("Myos = " + myos, Project.MSG_VERBOSE); + log("Myos = " + myos, Project.MSG_VERBOSE); if ((os != null) && (os.indexOf(myos) < 0)){ // this command will be executed only on the specified OS - project.log("Not found in " + os, Project.MSG_VERBOSE); + log("Not found in " + os, Project.MSG_VERBOSE); return 0; } @@ -106,14 +106,14 @@ public class Exec extends Task { try { // show the command - project.log(command, "exec", Project.MSG_VERBOSE); + log(command, Project.MSG_VERBOSE); // exec command on system runtime Process proc = Runtime.getRuntime().exec(command); if( out!=null ) { fos=new PrintWriter( new FileWriter( out ) ); - project.log("Output redirected to " + out, Project.MSG_VERBOSE); + log("Output redirected to " + out, Project.MSG_VERBOSE); } // copy input and error to the output stream @@ -138,7 +138,7 @@ public class Exec extends Task { // check its exit value err = proc.exitValue(); if (err != 0) { - project.log("Result: " + err, "exec", Project.MSG_ERR); + log("Result: " + err, Project.MSG_ERR); } } catch (IOException ioe) { throw new BuildException("Error exec: " + command, ioe, location); @@ -165,7 +165,7 @@ public class Exec extends Task { protected void outputLog(String line, int messageLevel) { if (fos == null) { - project.log(line, messageLevel); + log(line, messageLevel); } else { fos.println(line); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java index 57a8eaa07..558ed97fd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ b/src/main/org/apache/tools/ant/taskdefs/Expand.java @@ -81,7 +81,7 @@ public class Expand extends Task { File srcF=project.resolveFile(source); File dir=project.resolveFile(dest); - project.log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); + log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); // code from WarExpand ZipInputStream zis = new ZipInputStream(new FileInputStream(srcF)); ZipEntry ze = null; @@ -89,7 +89,7 @@ public class Expand extends Task { while ((ze = zis.getNextEntry()) != null) { try { File f = new File(dir, project.translatePath(ze.getName())); - project.log("expand-file " + ze.getName() , "expand", Project.MSG_VERBOSE ); + log("expand-file " + ze.getName() , Project.MSG_VERBOSE ); // create intermediary directories - sometimes zip don't add them File dirF=new File(f.getParent()); dirF.mkdirs(); @@ -118,7 +118,7 @@ public class Expand extends Task { System.out.println("FileNotFoundException: " + ze.getName() ); } } - project.log("", Project.MSG_VERBOSE ); + log("", Project.MSG_VERBOSE ); } catch (IOException ioe) { ioe.printStackTrace(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index b305b6c3a..d21262739 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -223,11 +223,11 @@ public class FixCRLF extends MatchingTask { } // log options used - project.log("options:" + + log("options:" + " cr=" + (addcr==-1 ? "add" : addcr==0 ? "asis" : "remove") + " tab=" + (addtab==-1 ? "add" : addtab==0 ? "asis" : "remove") + " eof=" + (ctrlz==-1 ? "add" : ctrlz==0 ? "asis" : "remove"), - "fixcrlf", project.MSG_VERBOSE); + Project.MSG_VERBOSE); DirectoryScanner ds = super.getDirectoryScanner(srcDir); String[] files = ds.getIncludedFiles(); @@ -262,9 +262,9 @@ public class FixCRLF extends MatchingTask { boolean eof = ((count>0) && (indata[count-1] == 0x1A)); // log stats (before fixes) - project.log(srcFile + ": size=" + count + " cr=" + cr + + log(srcFile + ": size=" + count + " cr=" + cr + " lf=" + lf + " tab=" + tab + " eof=" + eof, - "fixcrlf", project.MSG_VERBOSE); + Project.MSG_VERBOSE); // determine the output buffer size (slightly pessimisticly) int outsize = count; diff --git a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java index df7c0cd56..7a0f26ce0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java +++ b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java @@ -109,7 +109,7 @@ public class GUnzip extends Task { } if (source.lastModified() > dest.lastModified()) { - project.log("Expanding "+ source.getAbsolutePath() + " to " + log("Expanding "+ source.getAbsolutePath() + " to " + dest.getAbsolutePath()); try { diff --git a/src/main/org/apache/tools/ant/taskdefs/GZip.java b/src/main/org/apache/tools/ant/taskdefs/GZip.java index b1f9b06d9..deaed6438 100644 --- a/src/main/org/apache/tools/ant/taskdefs/GZip.java +++ b/src/main/org/apache/tools/ant/taskdefs/GZip.java @@ -81,13 +81,13 @@ public class GZip extends Task { } public void execute() throws BuildException { - project.log("Building gzip: " + zipFile.getAbsolutePath()); + log("Building gzip: " + zipFile.getAbsolutePath()); try { GZIPOutputStream zOut = new GZIPOutputStream(new FileOutputStream(zipFile)); if (source.isDirectory()) { - project.log ("Cannot Gzip a directory!"); + log ("Cannot Gzip a directory!"); } else { zipFile(source, zOut); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index 43c282596..1e32ffcc7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -82,7 +82,7 @@ public class Get extends Task { throw new BuildException(e.toString()); } - project.log("Getting: " + source); + log("Getting: " + source); File destF=new File(dest); FileOutputStream fos = new FileOutputStream(destF); @@ -93,11 +93,11 @@ public class Get extends Task { is = url.openStream(); break; } catch( IOException ex ) { - project.log( "Error opening connection " + ex ); + log( "Error opening connection " + ex ); } } if( is==null ) { - project.log( "Can't get " + source + " to " + dest); + log( "Can't get " + source + " to " + dest); if( ignoreErrors != null ) return; throw new BuildException( "Can't get " + source + " to " + dest); } @@ -113,7 +113,7 @@ public class Get extends Task { fos.close(); is.close(); } catch (IOException ioe) { - project.log("Error getting " + source + " to " + dest ); + log("Error getting " + source + " to " + dest ); if( ignoreErrors != null ) return; throw new BuildException(ioe.toString()); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java index 940fcfc9f..69a000825 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -86,7 +86,7 @@ public class Java extends Exec { * a separate VM (fork = "yes"). */ public int executeJava() throws BuildException { - project.log("Calling " + classname, "java", project.MSG_VERBOSE); + log("Calling " + classname, Project.MSG_VERBOSE); if (classname == null) { throw new BuildException("Classname must not be null."); @@ -113,8 +113,11 @@ public class Java extends Exec { return run(b.toString()); } else { Vector argList = tokenize(args); - if (jvmargs != null) project.log("JVM args and classpath ignored when same JVM is used.", "java", project.MSG_VERBOSE); - project.log("Java args: " + argList.toString(), "java", project.MSG_VERBOSE); + if (jvmargs != null) { + log("JVM args and classpath ignored when same JVM is used.", Project.MSG_VERBOSE); + } + + log("Java args: " + argList.toString(), Project.MSG_VERBOSE); run(classname, argList); return 0; } @@ -131,9 +134,9 @@ public class Java extends Exec { * Set the source file (deprecated). */ public void setClass(String s) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); + log("The class attribute is deprecated. " + + "Please use the classname attribute.", + Project.MSG_WARN); this.classname = s; } diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 59dd8610b..a5a58897d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -284,8 +284,8 @@ public class Javac extends MatchingTask { } if (compileList.size() > 0) { - project.log("Compiling " + compileList.size() + - " source files to " + destDir); + log("Compiling " + compileList.size() + + " source files to " + destDir); if (compiler.equalsIgnoreCase("classic")) { doClassicCompile(); @@ -302,12 +302,12 @@ public class Javac extends MatchingTask { // copy the support files if (filecopyList.size() > 0) { - project.log("The implicit copying of support files by javac has been deprecated. " + - "Use the copydir task to copy support files explicitly.", - Project.MSG_WARN); + log("The implicit copying of support files by javac has been deprecated. " + + "Use the copydir task to copy support files explicitly.", + Project.MSG_WARN); - project.log("Copying " + filecopyList.size() + - " support files to " + destDir.getAbsolutePath()); + log("Copying " + filecopyList.size() + + " support files to " + destDir.getAbsolutePath()); Enumeration enum = filecopyList.keys(); while (enum.hasMoreElements()) { String fromFile = (String) enum.nextElement(); @@ -348,8 +348,8 @@ public class Javac extends MatchingTask { files[i].indexOf(".java")) + ".class"); if (srcFile.lastModified() > now) { - project.log("Warning: file modified in the future: " + - files[i], project.MSG_WARN); + log("Warning: file modified in the future: " + + files[i], Project.MSG_WARN); } if (srcFile.lastModified() > classFile.lastModified()) { @@ -435,8 +435,8 @@ public class Javac extends MatchingTask { target.append(File.pathSeparator); target.append(f.getAbsolutePath()); } else { - project.log("Dropping from classpath: "+ - f.getAbsolutePath(),project.MSG_VERBOSE); + log("Dropping from classpath: "+ + f.getAbsolutePath(), Project.MSG_VERBOSE); } } @@ -467,7 +467,7 @@ public class Javac extends MatchingTask { */ private void doClassicCompile() throws BuildException { - project.log("Using classic compiler", project.MSG_VERBOSE); + log("Using classic compiler", Project.MSG_VERBOSE); String classpath = getCompileClasspath(false); Vector argList = new Vector(); @@ -505,8 +505,8 @@ public class Javac extends MatchingTask { argList.addElement(extdirs); } - project.log("Compilation args: " + argList.toString(), - project.MSG_VERBOSE); + log("Compilation args: " + argList.toString(), + Project.MSG_VERBOSE); String[] args = new String[argList.size() + compileList.size()]; int counter = 0; @@ -529,14 +529,14 @@ public class Javac extends MatchingTask { counter++; } - project.log(niceSourceList.toString(), project.MSG_VERBOSE); + log(niceSourceList.toString(), Project.MSG_VERBOSE); // XXX // provide the compiler a different message sink - namely our own ByteArrayOutputStream out = new ByteArrayOutputStream(); sun.tools.javac.Main compiler = - new sun.tools.javac.Main(new TaskOutputStream(project, Project.MSG_WARN), "javac"); + new sun.tools.javac.Main(new TaskOutputStream(this, Project.MSG_WARN), "javac"); if (!compiler.compile(args)) { throw new BuildException("Compile failed"); @@ -548,7 +548,7 @@ public class Javac extends MatchingTask { */ private void doModernCompile() throws BuildException { - project.log("Using modern compiler", project.MSG_VERBOSE); + log("Using modern compiler", Project.MSG_VERBOSE); String classpath = getCompileClasspath(false); Vector argList = new Vector(); @@ -580,8 +580,8 @@ public class Javac extends MatchingTask { argList.addElement(extdirs); } - project.log("Compilation args: " + argList.toString(), - project.MSG_VERBOSE); + log("Compilation args: " + argList.toString(), + Project.MSG_VERBOSE); String[] args = new String[argList.size() + compileList.size()]; int counter = 0; @@ -604,7 +604,7 @@ public class Javac extends MatchingTask { counter++; } - project.log(niceSourceList.toString(), project.MSG_VERBOSE); + log(niceSourceList.toString(), Project.MSG_VERBOSE); // This won't build under JDK1.2.2 because the new compiler // doesn't exist there. @@ -643,7 +643,7 @@ public class Javac extends MatchingTask { */ private void doJikesCompile() throws BuildException { - project.log("Using jikes compiler",project.MSG_VERBOSE); + log("Using jikes compiler", Project.MSG_VERBOSE); StringBuffer classpath = new StringBuffer(); classpath.append(getCompileClasspath(true)); @@ -721,8 +721,8 @@ public class Javac extends MatchingTask { if (!warnings) argList.addElement("-nowarn"); - project.log("Compilation args: " + argList.toString(), - project.MSG_VERBOSE); + log("Compilation args: " + argList.toString(), + Project.MSG_VERBOSE); String[] args = new String[argList.size() + compileList.size()]; int counter = 0; @@ -745,12 +745,12 @@ public class Javac extends MatchingTask { counter++; } - project.log(niceSourceList.toString(), project.MSG_VERBOSE); + log(niceSourceList.toString(), Project.MSG_VERBOSE); // XXX // provide the compiler a different message sink - namely our own - JikesOutputParser jop = new JikesOutputParser(project,emacsMode); + JikesOutputParser jop = new JikesOutputParser(this, emacsMode); Jikes compiler = new Jikes(jop,"jikes"); compiler.compile(args); diff --git a/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java b/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java index 5fdd11e01..d6623df83 100644 --- a/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java +++ b/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java @@ -60,7 +60,7 @@ import java.io.*; /** * Serves as an output stream to Javac. This let's us print messages - * out to the project and detect whether or not Javac had an error + * out to the log and detect whether or not Javac had an error * while compiling. * * @author James Duncan Davidson (duncan@x180.com) @@ -68,17 +68,17 @@ import java.io.*; class JavacOutputStream extends OutputStream { - private Project project; + private Task task; private StringBuffer line; private boolean errorFlag = false; /** - * Constructs a new JavacOutputStream with the given project + * Constructs a new JavacOutputStream with the given task * as the output source for messages. */ - JavacOutputStream(Project project) { - this.project = project; + JavacOutputStream(Task task) { + this.task = task; line = new StringBuffer(); } @@ -109,7 +109,7 @@ class JavacOutputStream extends OutputStream { if (s.indexOf("error") > -1) { errorFlag = true; } - project.log(s); + task.log(s); line = new StringBuffer(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 5e0d9d078..cc8d52e40 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -329,7 +329,7 @@ public class Javadoc extends Exec { boolean javadoc1 = (Project.getJavaVersion() == Project.JAVA_1_1); - project.log("Generating Javadoc", project.MSG_INFO); + log("Generating Javadoc", Project.MSG_INFO); Vector argList = new Vector(); @@ -577,9 +577,9 @@ public class Javadoc extends Exec { if (packageList != null) { argList.addElement("@" + packageList); } - project.log("Javadoc args: " + argList.toString(), "javadoc", project.MSG_VERBOSE); + log("Javadoc args: " + argList.toString(), Project.MSG_VERBOSE); - project.log("Javadoc execution", project.MSG_INFO); + log("Javadoc execution", Project.MSG_INFO); StringBuffer b = new StringBuffer(); b.append("javadoc "); @@ -606,9 +606,9 @@ public class Javadoc extends Exec { * patterns. */ private void evaluatePackages(String sourcePath, Vector packages, Vector argList) { - project.log("Parsing source files for packages", project.MSG_INFO); - project.log("Source path = " + sourcePath, project.MSG_VERBOSE); - project.log("Packages = " + packages, project.MSG_VERBOSE); + log("Parsing source files for packages", Project.MSG_INFO); + log("Source path = " + sourcePath, Project.MSG_VERBOSE); + log("Packages = " + packages, Project.MSG_VERBOSE); Vector addedPackages = new Vector(); PathTokenizer tokenizer = new PathTokenizer(sourcePath); @@ -687,7 +687,7 @@ public class Javadoc extends Exec { } } if (count > 0) { - project.log("found " + count + " source files in " + path, "javadoc", project.MSG_VERBOSE); + log("found " + count + " source files in " + path, Project.MSG_VERBOSE); } } else { throw new BuildException("Error occurred during " + path + " evaluation."); @@ -708,7 +708,7 @@ public class Javadoc extends Exec { while (true) { line = reader.readLine(); if (line == null) { - project.log("Could not evaluate package for " + file, "javadoc", project.MSG_WARN); + log("Could not evaluate package for " + file, Project.MSG_WARN); return null; } if (line.trim().startsWith("package ")) { @@ -718,11 +718,11 @@ public class Javadoc extends Exec { } reader.close(); } catch (Exception e) { - project.log("Exception " + e + " parsing " + file, "javadoc", project.MSG_WARN); + log("Exception " + e + " parsing " + file, Project.MSG_WARN); return null; } - project.log(file + " --> " + name, "javadoc", project.MSG_VERBOSE); + log(file + " --> " + name, Project.MSG_VERBOSE); return name; } @@ -736,15 +736,15 @@ public class Javadoc extends Exec { protected void outputLog(String line, int messageLevel) { if (messageLevel==project.MSG_INFO && line.startsWith("Generating ")) { if (queuedLine != null) { - super.outputLog(queuedLine, project.MSG_VERBOSE); + super.outputLog(queuedLine, Project.MSG_VERBOSE); } queuedLine = line; } else { if (queuedLine != null) { if (line.startsWith("Building ")) - super.outputLog(queuedLine, project.MSG_VERBOSE); + super.outputLog(queuedLine, Project.MSG_VERBOSE); else - super.outputLog(queuedLine, project.MSG_INFO); + super.outputLog(queuedLine, Project.MSG_INFO); queuedLine = null; } super.outputLog(line, messageLevel); @@ -753,7 +753,7 @@ public class Javadoc extends Exec { protected void logFlush() { if (queuedLine != null) { - super.outputLog(queuedLine, project.MSG_VERBOSE); + super.outputLog(queuedLine, Project.MSG_VERBOSE); queuedLine = null; } super.logFlush(); diff --git a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java index 69d6f4d97..f9ddb889c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java +++ b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java @@ -14,7 +14,7 @@ import java.io.*; * @author skanthak@muehlheim.de */ public class JikesOutputParser { - protected Project project; + protected Task task; protected boolean errorFlag = false; // no errors so far protected int errors,warnings; protected boolean error = false; @@ -22,11 +22,11 @@ public class JikesOutputParser { /** * Construct a new Parser object - * @param project - project in whichs context we are called + * @param task - task in whichs context we are called */ - protected JikesOutputParser(Project project, boolean emacsMode) { + protected JikesOutputParser(Task task, boolean emacsMode) { super(); - this.project = project; + this.task = task; this.emacsMode = emacsMode; } @@ -88,9 +88,9 @@ public class JikesOutputParser { private void log(String line) { if (!emacsMode) { - project.log("", (error ? Project.MSG_ERR : Project.MSG_WARN)); + task.log("", (error ? Project.MSG_ERR : Project.MSG_WARN)); } - project.log(line, (error ? Project.MSG_ERR : Project.MSG_WARN)); + task.log(line, (error ? Project.MSG_ERR : Project.MSG_WARN)); } /** diff --git a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java index cf98dec77..369804938 100644 --- a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java +++ b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java @@ -76,10 +76,10 @@ public class KeySubst extends Task { Do the execution. */ public void execute() throws BuildException { - project.log("!! KeySubst is deprecated. Use Filter + CopyDir instead. !!"); - project.log("Performing Substitions"); + log("!! KeySubst is deprecated. Use Filter + CopyDir instead. !!"); + log("Performing Substitions"); if ( source == null || dest == null ) { - project.log("Source and destinations must not be null"); + log("Source and destinations must not be null"); return; } BufferedReader br = null; @@ -152,8 +152,8 @@ public class KeySubst extends Task { String name = itok.nextToken(); String value = itok.nextToken(); -// project.log ( "Name: " + name ); -// project.log ( "Value: " + value ); +// log ( "Name: " + name ); +// log ( "Value: " + value ); replacements.put ( name, value ); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java index 0be2f7261..bf78d8674 100644 --- a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -137,9 +137,9 @@ public abstract class MatchingTask extends Task { * @param itemString the string containing the files to include. */ public void setItems(String itemString) { - project.log("The items attribute is deprecated. " + - "Please use the includes attribute.", - Project.MSG_WARN); + log("The items attribute is deprecated. " + + "Please use the includes attribute.", + Project.MSG_WARN); if (itemString == null || itemString.equals("*") || itemString.equals(".")) { createInclude().setName("**"); @@ -173,9 +173,9 @@ public abstract class MatchingTask extends Task { * @param ignoreString the string containing the files to ignore. */ public void setIgnore(String ignoreString) { - project.log("The ignore attribute is deprecated." + - "Please use the excludes attribute.", - Project.MSG_WARN); + log("The ignore attribute is deprecated." + + "Please use the excludes attribute.", + Project.MSG_WARN); if (ignoreString != null && ignoreString.length() > 0) { Vector tmpExcludes = new Vector(); StringTokenizer tok = new StringTokenizer(ignoreString, ", ", false); @@ -266,8 +266,8 @@ public abstract class MatchingTask extends Task { line = patternReader.readLine(); } } catch(IOException ioe) { - project.log("An error occured while reading from pattern file: " - + patternfile, Project.MSG_ERR); + log("An error occured while reading from pattern file: " + + patternfile, Project.MSG_ERR); } } @@ -281,8 +281,8 @@ public abstract class MatchingTask extends Task { if (includesfile != null && includesfile.length() > 0) { File incl = project.resolveFile(includesfile); if (!incl.exists()) { - project.log("Includesfile "+includesfile+" not found.", - Project.MSG_ERR); + log("Includesfile "+includesfile+" not found.", + Project.MSG_ERR); } else { readPatterns(incl, includeList); } @@ -299,8 +299,8 @@ public abstract class MatchingTask extends Task { if (excludesfile != null && excludesfile.length() > 0) { File excl = project.resolveFile(excludesfile); if (!excl.exists()) { - project.log("Excludesfile "+excludesfile+" not found.", - Project.MSG_ERR); + log("Excludesfile "+excludesfile+" not found.", + Project.MSG_ERR); } else { readPatterns(excl, excludeList); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Mkdir.java b/src/main/org/apache/tools/ant/taskdefs/Mkdir.java index e133098c1..039b049eb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Mkdir.java +++ b/src/main/org/apache/tools/ant/taskdefs/Mkdir.java @@ -77,7 +77,7 @@ public class Mkdir extends Task { "succesful for an unknown reason"; throw new BuildException(msg); } - project.log("Created dir: " + dir.getAbsolutePath()); + log("Created dir: " + dir.getAbsolutePath()); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java index 6bcfe03ed..924b49519 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Property.java +++ b/src/main/org/apache/tools/ant/taskdefs/Property.java @@ -105,15 +105,15 @@ public class Property extends Task { if (project.getUserProperty(name) == null) { project.setUserProperty(name, value); } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); + log("Override ignored for " + name, + Project.MSG_VERBOSE); } else if (project.getProperty(name) == null) { project.setProperty(name, value); } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); + log("Override ignored for " + name, + Project.MSG_VERBOSE); } } @@ -128,7 +128,7 @@ public class Property extends Task { private void loadFile (String name) { Properties props = new Properties(); - project.log("Loading " + name, project.MSG_VERBOSE); + log("Loading " + name, Project.MSG_VERBOSE); try { if (new File(name).exists()) { props.load(new FileInputStream(name)); @@ -141,7 +141,7 @@ public class Property extends Task { private void loadResource( String name ) { Properties props = new Properties(); - project.log("Resource Loading " + name, project.MSG_VERBOSE); + log("Resource Loading " + name, Project.MSG_VERBOSE); try { InputStream is = this.getClass().getResourceAsStream(name); if (is != null) { @@ -163,15 +163,15 @@ public class Property extends Task { if (project.getUserProperty(name) == null) { project.setUserProperty(name, v); } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); + log("Override ignored for " + name, + Project.MSG_VERBOSE); } else if (project.getProperty(name) == null) { project.setProperty(name, v); } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); + log("Override ignored for " + name, + Project.MSG_VERBOSE); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java index ae9a1fc8c..068577f52 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java @@ -85,7 +85,7 @@ public class Replace extends MatchingTask { throw new BuildException("Either the file or the dir attribute must be specified"); } - project.log("Replacing " + token + " --> " + value); + log("Replacing " + token + " --> " + value); if (src != null) { processFile(src); diff --git a/src/main/org/apache/tools/ant/taskdefs/Rmic.java b/src/main/org/apache/tools/ant/taskdefs/Rmic.java index 83e785312..9e939abbb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Rmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/Rmic.java @@ -98,9 +98,9 @@ public class Rmic extends MatchingTask { } public void setClass(String classname) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); + log("The class attribute is deprecated. " + + "Please use the classname attribute.", + Project.MSG_WARN); this.classname = classname; } @@ -146,7 +146,7 @@ public class Rmic extends MatchingTask { } if (verify) { - project.log("Verify has been turned on.", Project.MSG_INFO); + log("Verify has been turned on.", Project.MSG_INFO); } File sourceBaseFile = null; if (null != sourceBase) { @@ -193,8 +193,8 @@ public class Rmic extends MatchingTask { } } else { if (compileList.size() > 0) { - project.log("RMI Compiling " + compileList.size() + - " classes to " + baseDir, Project.MSG_INFO); + log("RMI Compiling " + compileList.size() + + " classes to " + baseDir, Project.MSG_INFO); for (int j = 0; j < compileList.size(); j++) { args[i++] = (String) compileList.elementAt(j); @@ -272,16 +272,16 @@ public class Rmic extends MatchingTask { shouldAdd = false; } } catch (ClassNotFoundException e) { - project.log("Unable to verify class " + classname + + log("Unable to verify class " + classname + ". It could not be found.", Project.MSG_WARN); } catch (NoClassDefFoundError e) { - project.log("Unable to verify class " + classname + + log("Unable to verify class " + classname + ". It is not defined.", Project.MSG_WARN); } } if (shouldAdd) { - project.log("Adding: " + classname + " to compile list", - Project.MSG_VERBOSE); + log("Adding: " + classname + " to compile list", + Project.MSG_VERBOSE); compileList.addElement(classname); } } @@ -329,8 +329,8 @@ public class Rmic extends MatchingTask { classFile.getAbsolutePath().indexOf(".class")) + "_Skel.class"); if (classFile.exists()) { if (classFile.lastModified() > now) { - project.log("Warning: file modified in the future: " + - classFile, Project.MSG_WARN); + log("Warning: file modified in the future: " + + classFile, Project.MSG_WARN); } if (classFile.lastModified() > stubFile.lastModified()) { @@ -399,8 +399,8 @@ public class Rmic extends MatchingTask { target.append(File.pathSeparator); target.append(f.getAbsolutePath()); } else { - project.log("Dropping from classpath: "+ - f.getAbsolutePath(), Project.MSG_VERBOSE); + log("Dropping from classpath: "+ + f.getAbsolutePath(), Project.MSG_VERBOSE); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Tar.java b/src/main/org/apache/tools/ant/taskdefs/Tar.java index df9243f9b..46b82e0ca 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tar.java @@ -84,7 +84,7 @@ public class Tar extends MatchingTask { } public void execute() throws BuildException { - project.log("Building tar: "+ tarFile.getAbsolutePath()); + log("Building tar: "+ tarFile.getAbsolutePath()); if (baseDir == null) { throw new BuildException("basedir attribute must be set!"); diff --git a/src/main/org/apache/tools/ant/taskdefs/TaskOutputStream.java b/src/main/org/apache/tools/ant/taskdefs/TaskOutputStream.java index fa8f94a76..fc0e30664 100644 --- a/src/main/org/apache/tools/ant/taskdefs/TaskOutputStream.java +++ b/src/main/org/apache/tools/ant/taskdefs/TaskOutputStream.java @@ -71,7 +71,7 @@ import java.io.*; public class TaskOutputStream extends OutputStream { - private Project project; + private Task task; private StringBuffer line; private int msgOutputLevel; @@ -80,8 +80,8 @@ public class TaskOutputStream extends OutputStream { * as the output source for messages. */ - TaskOutputStream(Project project, int msgOutputLevel) { - this.project = project; + TaskOutputStream(Task task, int msgOutputLevel) { + this.task = task; this.msgOutputLevel = msgOutputLevel; line = new StringBuffer(); @@ -111,7 +111,7 @@ public class TaskOutputStream extends OutputStream { private void processLine() { String s = line.toString(); - project.log(s, msgOutputLevel); + task.log(s, msgOutputLevel); line = new StringBuffer(); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Taskdef.java b/src/main/org/apache/tools/ant/taskdefs/Taskdef.java index c33200603..31b56e703 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Taskdef.java +++ b/src/main/org/apache/tools/ant/taskdefs/Taskdef.java @@ -95,9 +95,9 @@ public class Taskdef extends Task { } public void setClass(String v) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); + log("The class attribute is deprecated. " + + "Please use the classname attribute.", + Project.MSG_WARN); value = v; } diff --git a/src/main/org/apache/tools/ant/taskdefs/Touch.java b/src/main/org/apache/tools/ant/taskdefs/Touch.java index b5f930f69..acd3be1e7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Touch.java +++ b/src/main/org/apache/tools/ant/taskdefs/Touch.java @@ -112,9 +112,9 @@ public class Touch extends Task { */ public void execute() throws BuildException { if (file.exists() && project.getJavaVersion() == Project.JAVA_1_1) { - project.log("Cannot change the modification time of " - + file + " in JDK 1.1", - Project.MSG_WARN); + log("Cannot change the modification time of " + + file + " in JDK 1.1", + Project.MSG_WARN); return; } @@ -130,9 +130,8 @@ public class Touch extends Task { } if (millis >= 0 && project.getJavaVersion() == Project.JAVA_1_1) { - project.log(file + - " will be created but its modification time cannot be set in JDK 1.1", - Project.MSG_WARN); + log(file + " will be created but its modification time cannot be set in JDK 1.1", + Project.MSG_WARN); } touch(); @@ -143,7 +142,7 @@ public class Touch extends Task { */ void touch() throws BuildException { if (!file.exists()) { - project.log("Creating "+file, Project.MSG_INFO); + log("Creating "+file, Project.MSG_INFO); try { FileOutputStream fos = new FileOutputStream(file); fos.write(new byte[0]); @@ -181,8 +180,8 @@ public class Touch extends Task { } try { - project.log("Setting modification time for "+file, - Project.MSG_VERBOSE); + log("Setting modification time for "+file, + Project.MSG_VERBOSE); setLastModified.invoke(file, times); } catch (InvocationTargetException ite) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Untar.java b/src/main/org/apache/tools/ant/taskdefs/Untar.java index 6bad0cdfb..29e75f0aa 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Untar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Untar.java @@ -94,7 +94,7 @@ public class Untar extends Task { } File dir=project.resolveFile(dest); - project.log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); + log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); // code from WarExpand TarInputStream tis = new TarInputStream(new FileInputStream(srcF)); TarEntry te = null; @@ -102,8 +102,7 @@ public class Untar extends Task { while ((te = tis.getNextEntry()) != null) { try { File f = new File(dir, project.translatePath(te.getName())); - project.log("expand-file " + te.getName() , "untar", - Project.MSG_VERBOSE ); + log("expand-file " + te.getName(), Project.MSG_VERBOSE ); // create intermediary directories - sometimes tar don't add them File dirF=new File(f.getParent()); dirF.mkdirs(); @@ -129,8 +128,8 @@ public class Untar extends Task { } } catch(FileNotFoundException ex) { - project.log("FileNotFoundException: " + te.getName(), - Project.MSG_WARN); + log("FileNotFoundException: " + te.getName(), + Project.MSG_WARN); } } } catch (IOException ioe) { diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index b41e8d838..a6ca82a75 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -120,7 +120,7 @@ public class XSLTProcess extends MatchingTask { throw new BuildException(msg); } scanner = getDirectoryScanner(baseDir); - project.log("Transforming into "+destDir,project.MSG_INFO); + log("Transforming into "+destDir, Project.MSG_INFO); // if processor wasn't specified, default it to xslp or xalan, // depending on which is in the classpath @@ -136,17 +136,17 @@ public class XSLTProcess extends MatchingTask { } } - project.log("Using "+liaison.getClass().toString(),project.MSG_VERBOSE); + log("Using "+liaison.getClass().toString(), Project.MSG_VERBOSE); try { // Create a new XSL processor with the specified stylesheet if (xslFile != null) { String file = new File(baseDir,xslFile.toString()).toString(); - project.log("Loading stylesheet " + file, project.MSG_INFO); + log("Loading stylesheet " + file, Project.MSG_INFO); liaison.setStylesheet( file ); } } catch (Exception ex) { - project.log("Failed to read stylesheet " + xslFile,project.MSG_INFO); + log("Failed to read stylesheet " + xslFile, Project.MSG_INFO); throw new BuildException(ex); } @@ -296,7 +296,7 @@ public class XSLTProcess extends MatchingTask { outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt); if (inFile.lastModified() > outFile.lastModified()) { //-- command line status - project.log("Processing " + xmlFile + " to " + outFile,project.MSG_VERBOSE); + log("Processing " + xmlFile + " to " + outFile, Project.MSG_VERBOSE); liaison.transform(inFile.toString(), outFile.toString()); } @@ -304,7 +304,7 @@ public class XSLTProcess extends MatchingTask { catch (Exception ex) { // If failed to process document, must delete target document, // or it will not attempt to process it the second time - project.log("Failed to process " + inFile,project.MSG_INFO); + log("Failed to process " + inFile, Project.MSG_INFO); outFile.delete(); throw new BuildException(ex); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index 1af5fc920..c40847f00 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -120,7 +120,7 @@ public class Zip extends MatchingTask { upToDate = false; if (upToDate) return; - project.log("Building "+ archiveType +": "+ zipFile.getAbsolutePath()); + log("Building "+ archiveType +": "+ zipFile.getAbsolutePath()); try { ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(zipFile)); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java index f230646b0..3a2b9e103 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java @@ -442,7 +442,7 @@ public class NetRexxC extends MatchingTask { // compile the source files if (compileList.size() > 0) { - project.log("Compiling " + compileList.size() + " source files to " + destDir); + log("Compiling " + compileList.size() + " source files to " + destDir); doNetRexxCompile(); } } @@ -479,7 +479,7 @@ public class NetRexxC extends MatchingTask { */ private void copyFilesToDestination() { if (filecopyList.size() > 0) { - project.log("Copying " + filecopyList.size() + " files to " + destDir.getAbsolutePath()); + log("Copying " + filecopyList.size() + " files to " + destDir.getAbsolutePath()); Enumeration enum = filecopyList.keys(); while (enum.hasMoreElements()) { String fromFile = (String)enum.nextElement(); @@ -499,7 +499,7 @@ public class NetRexxC extends MatchingTask { * Peforms a copmile using the NetRexx 1.1.x compiler */ private void doNetRexxCompile() throws BuildException { - project.log("Using NetRexx compiler", project.MSG_VERBOSE); + log("Using NetRexx compiler", Project.MSG_VERBOSE); String classpath = getCompileClasspath(); StringBuffer compileOptions = new StringBuffer(); StringBuffer fileList = new StringBuffer(); @@ -529,7 +529,7 @@ public class NetRexxC extends MatchingTask { compileOptions.append(compileOptionsArray[i]); compileOptions.append(" "); } - project.log(compileOptions.toString(), project.MSG_VERBOSE); + log(compileOptions.toString(), Project.MSG_VERBOSE); String eol = System.getProperty("line.separator"); StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" + eol); @@ -540,7 +540,7 @@ public class NetRexxC extends MatchingTask { niceSourceList.append(eol); } - project.log(niceSourceList.toString(), project.MSG_VERBOSE); + log(niceSourceList.toString(), Project.MSG_VERBOSE); // need to set java.class.path property and restore it later // since the NetRexx compiler has no option for the classpath @@ -554,15 +554,15 @@ public class NetRexxC extends MatchingTask { new Rexx(compileArgs), new PrintWriter(out)); if (rc > 1) { // 1 is warnings from real NetRexxC - project.log(out.toString(), Project.MSG_ERR); + log(out.toString(), Project.MSG_ERR); String msg = "Compile failed, messages should have been provided."; throw new BuildException(msg); } else if (rc == 1) { - project.log(out.toString(), Project.MSG_WARN); + log(out.toString(), Project.MSG_WARN); } else { - project.log(out.toString(), Project.MSG_INFO); + log(out.toString(), Project.MSG_INFO); } } finally { // need to reset java.class.path property @@ -648,8 +648,8 @@ public class NetRexxC extends MatchingTask { target.append(File.pathSeparator); target.append(f.getAbsolutePath()); } else { - project.log("Dropping from classpath: "+ - f.getAbsolutePath(),project.MSG_VERBOSE); + log("Dropping from classpath: "+ + f.getAbsolutePath(), Project.MSG_VERBOSE); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java b/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java index bcd2df1ae..e7f32a76c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java @@ -151,10 +151,10 @@ public class RenameExtensions extends MatchingTask { if (replace || !destFile.exists()) { list.put(srcFile, destFile); } else { - project.log("Rejecting file: '" + srcFile + "' for rename as replace is false and file exists", Project.MSG_VERBOSE); + log("Rejecting file: '" + srcFile + "' for rename as replace is false and file exists", Project.MSG_VERBOSE); } } else { - project.log("File '"+ filename + "' doesn't match fromExtension: '" + fromExtension + "'", Project.MSG_VERBOSE); + log("File '"+ filename + "' doesn't match fromExtension: '" + fromExtension + "'", Project.MSG_VERBOSE); } } return list;