This patch removes the concept of currentTarget and currentTask from the BuildEvents code. To facilitate this I have moved logging to the task level which now passes a task pointer to the project's log method. Task level logging may also allow for more fine grained control of logging in the future. I have left the Project's log methods public to allow people's custom tasks to continue to work. In the future these can become private. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267740 13f79535-47bb-0310-9956-ffa450edef68master
@@ -61,29 +61,52 @@ public class BuildEvent extends EventObject { | |||||
private Target target; | private Target target; | ||||
private Task task; | private Task task; | ||||
private String message; | private String message; | ||||
private int priority; | |||||
private int priority = Project.MSG_VERBOSE; | |||||
private Throwable exception; | 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.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.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; | this.task = task; | ||||
} | |||||
public void setMessage(String message, int priority) { | |||||
this.message = message; | this.message = message; | ||||
this.priority = priority; | this.priority = priority; | ||||
} | |||||
public void setException(Throwable exception) { | |||||
this.exception = exception; | this.exception = exception; | ||||
} | } | ||||
@@ -98,6 +121,7 @@ public class BuildEvent extends EventObject { | |||||
* Returns the target that fired this event. | * Returns the target that fired this event. | ||||
*/ | */ | ||||
public Target getTarget() { | public Target getTarget() { | ||||
return target; | return target; | ||||
} | } | ||||
@@ -139,15 +163,4 @@ public class BuildEvent extends EventObject { | |||||
public Throwable getException() { | public Throwable getException() { | ||||
return exception; | 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"); | |||||
} | |||||
} | } |
@@ -104,8 +104,6 @@ public class Project { | |||||
private File baseDir; | private File baseDir; | ||||
private Vector listeners = new Vector(); | private Vector listeners = new Vector(); | ||||
protected Target currentTarget = null; | |||||
protected Task currentTask = null; | |||||
public Project() { | public Project() { | ||||
} | } | ||||
@@ -170,11 +168,15 @@ public class Project { | |||||
} | } | ||||
public void log(String msg, int msgLevel) { | 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) { | public void setProperty(String name, String value) { | ||||
@@ -708,20 +710,15 @@ public class Project { | |||||
public void runTarget(Target target) | public void runTarget(Target target) | ||||
throws BuildException { | throws BuildException { | ||||
currentTarget = target; | |||||
try { | try { | ||||
fireTargetStarted(); | |||||
currentTarget.execute(); | |||||
fireTargetFinished(null); | |||||
fireTargetStarted(target); | |||||
target.execute(); | |||||
fireTargetFinished(target, null); | |||||
} | } | ||||
catch(RuntimeException exc) { | catch(RuntimeException exc) { | ||||
fireTargetFinished(exc); | |||||
fireTargetFinished(target, exc); | |||||
throw exc; | throw exc; | ||||
} | } | ||||
finally { | |||||
currentTarget = null; | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -849,7 +846,7 @@ public class Project { | |||||
} | } | ||||
protected void fireBuildStarted() { | protected void fireBuildStarted() { | ||||
BuildEvent event = createBuildEvent(); | |||||
BuildEvent event = new BuildEvent(this); | |||||
for (int i = 0; i < listeners.size(); i++) { | for (int i = 0; i < listeners.size(); i++) { | ||||
BuildListener listener = (BuildListener) listeners.elementAt(i); | BuildListener listener = (BuildListener) listeners.elementAt(i); | ||||
listener.buildStarted(event); | listener.buildStarted(event); | ||||
@@ -857,62 +854,67 @@ public class Project { | |||||
} | } | ||||
protected void fireBuildFinished(Throwable exception) { | 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++) { | for (int i = 0; i < listeners.size(); i++) { | ||||
BuildListener listener = (BuildListener) listeners.elementAt(i); | BuildListener listener = (BuildListener) listeners.elementAt(i); | ||||
listener.buildFinished(event); | 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++) { | for (int i = 0; i < listeners.size(); i++) { | ||||
BuildListener listener = (BuildListener) listeners.elementAt(i); | BuildListener listener = (BuildListener) listeners.elementAt(i); | ||||
listener.targetStarted(event); | 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++) { | for (int i = 0; i < listeners.size(); i++) { | ||||
BuildListener listener = (BuildListener) listeners.elementAt(i); | BuildListener listener = (BuildListener) listeners.elementAt(i); | ||||
listener.targetFinished(event); | 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++) { | for (int i = 0; i < listeners.size(); i++) { | ||||
BuildListener listener = (BuildListener) listeners.elementAt(i); | BuildListener listener = (BuildListener) listeners.elementAt(i); | ||||
listener.taskStarted(event); | 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++) { | for (int i = 0; i < listeners.size(); i++) { | ||||
BuildListener listener = (BuildListener) listeners.elementAt(i); | BuildListener listener = (BuildListener) listeners.elementAt(i); | ||||
listener.taskFinished(event); | 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++) { | for (int i = 0; i < listeners.size(); i++) { | ||||
BuildListener listener = (BuildListener) listeners.elementAt(i); | BuildListener listener = (BuildListener) listeners.elementAt(i); | ||||
listener.messageLogged(event); | 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); | |||||
} | } | ||||
} | } |
@@ -327,11 +327,9 @@ public class ProjectHelper { | |||||
public void init(String tag, AttributeList attrs) throws SAXParseException { | public void init(String tag, AttributeList attrs) throws SAXParseException { | ||||
task = project.createTask(tag); | task = project.createTask(tag); | ||||
project.currentTask = task; | |||||
configure(task, attrs); | configure(task, attrs); | ||||
task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(), locator.getColumnNumber())); | task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(), locator.getColumnNumber())); | ||||
task.init(); | task.init(); | ||||
project.currentTask = null; | |||||
// Top level tasks don't have associated targets | // Top level tasks don't have associated targets | ||||
if (target != null) { | if (target != null) { | ||||
@@ -123,24 +123,20 @@ public class Target { | |||||
Task task = (Task) enum.nextElement(); | Task task = (Task) enum.nextElement(); | ||||
try { | try { | ||||
project.currentTask = task; | |||||
project.fireTaskStarted(); | |||||
project.fireTaskStarted(task); | |||||
task.execute(); | task.execute(); | ||||
project.fireTaskFinished(null); | |||||
project.fireTaskFinished(task, null); | |||||
} | } | ||||
catch(RuntimeException exc) { | catch(RuntimeException exc) { | ||||
if (exc instanceof BuildException) { | if (exc instanceof BuildException) { | ||||
((BuildException)exc).setLocation(task.getLocation()); | ((BuildException)exc).setLocation(task.getLocation()); | ||||
} | } | ||||
project.fireTaskFinished(exc); | |||||
project.fireTaskFinished(task, exc); | |||||
throw exc; | throw exc; | ||||
} | } | ||||
finally { | |||||
project.currentTask = null; | |||||
} | |||||
} | } | ||||
} else { | } 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); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -77,6 +77,15 @@ public abstract class Task { | |||||
this.project = project; | 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. | * Sets the target object of this task. | ||||
* | * | ||||
@@ -86,6 +95,35 @@ public abstract class Task { | |||||
this.target = target; | 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 | /** Sets a description of the current action. It will be usefull in commenting | ||||
* what we are doing. | * what we are doing. | ||||
*/ | */ | ||||
@@ -76,13 +76,13 @@ public class TaskAdapter extends Task { | |||||
Class c=proxy.getClass(); | Class c=proxy.getClass(); | ||||
executeM=c.getMethod( "execute", new Class[0] ); | executeM=c.getMethod( "execute", new Class[0] ); | ||||
if( executeM == null ) { | 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()); | throw new BuildException("No execute in " + proxy.getClass()); | ||||
} | } | ||||
executeM.invoke(proxy, null); | executeM.invoke(proxy, null); | ||||
return; | return; | ||||
} catch( Exception ex ) { | } 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 ); | throw new BuildException( ex ); | ||||
} | } | ||||
@@ -100,7 +100,7 @@ public class Ant extends Task { | |||||
p1.addBuildListener(new DefaultLogger(out, Project.MSG_INFO)); | p1.addBuildListener(new DefaultLogger(out, Project.MSG_INFO)); | ||||
} | } | ||||
catch( IOException ex ) { | catch( IOException ex ) { | ||||
project.log( "Ant: Can't set output to " + output ); | |||||
log( "Ant: Can't set output to " + output ); | |||||
} | } | ||||
} | } | ||||
@@ -76,9 +76,9 @@ public class Available extends Task { | |||||
} | } | ||||
public void setClass(String classname) { | 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; | this.classname = classname; | ||||
} | } | ||||
@@ -107,7 +107,7 @@ public class Available extends Task { | |||||
File f = new File(file); | File f = new File(file); | ||||
return f.exists(); | return f.exists(); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
project.log(e.toString(), "available", Project.MSG_VERBOSE); | |||||
log(e.toString(), Project.MSG_VERBOSE); | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
@@ -121,7 +121,7 @@ public class Available extends Task { | |||||
Class.forName(classname); | Class.forName(classname); | ||||
return true; | return true; | ||||
} catch (Throwable t) { | } catch (Throwable t) { | ||||
project.log(t.toString(), "available", Project.MSG_VERBOSE); | |||||
log(t.toString(), Project.MSG_VERBOSE); | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
@@ -81,9 +81,9 @@ public class Chmod extends MatchingTask { | |||||
} | } | ||||
public void setSrc(String src) { | 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); | setFile(src); | ||||
} | } | ||||
@@ -100,7 +100,7 @@ public class Chmod extends MatchingTask { | |||||
if (srcFile != null && srcDir == null) { | if (srcFile != null && srcDir == null) { | ||||
chmod(srcFile.toString()); | chmod(srcFile.toString()); | ||||
} else if(srcFile == null && srcDir == null) { | } 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); | throw new BuildException("Required attribute not set in Chmod", location); | ||||
} else if(srcFile == null && srcDir != null) { | } else if(srcFile == null && srcDir != null) { | ||||
@@ -114,7 +114,7 @@ public class Chmod extends MatchingTask { | |||||
} | } | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
// ignore, but warn | // ignore, but warn | ||||
project.log("Error in Chmod " + ioe.toString() , Project.MSG_WARN); | |||||
log("Error in Chmod " + ioe.toString() , Project.MSG_WARN); | |||||
} | } | ||||
} | } | ||||
@@ -105,8 +105,8 @@ public class Copydir extends MatchingTask { | |||||
String[] files = ds.getIncludedFiles(); | String[] files = ds.getIncludedFiles(); | ||||
scanDir(srcDir, destDir, files); | scanDir(srcDir, destDir, files); | ||||
if (filecopyList.size() > 0) { | 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(); | Enumeration enum = filecopyList.keys(); | ||||
while (enum.hasMoreElements()) { | while (enum.hasMoreElements()) { | ||||
String fromFile = (String) enum.nextElement(); | String fromFile = (String) enum.nextElement(); | ||||
@@ -1,37 +1,37 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | |||||
* | |||||
* Copyright (c) 1999 The Apache Software Foundation. All rights | * Copyright (c) 1999 The Apache Software Foundation. All rights | ||||
* reserved. | * reserved. | ||||
* | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright | * 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 | * 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 | * 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 | * 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" | * 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 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | ||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | * 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 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* ==================================================================== | * ==================================================================== | ||||
* | |||||
* | |||||
* This software consists of voluntary contributions made by many | * This software consists of voluntary contributions made by many | ||||
* individuals on behalf of the Apache Software Foundation. For more | * individuals on behalf of the Apache Software Foundation. For more | ||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
@@ -54,105 +54,103 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
import java.io.*; | import java.io.*; | ||||
/** | /** | ||||
* Deletes a single file or a set of files defined by a pattern. | * Deletes a single file or a set of files defined by a pattern. | ||||
* | |||||
* | |||||
* @author stefano@apache.org | * @author stefano@apache.org | ||||
* @author Tom Dimock <a href="mailto:tad1@cornell.edu">tad1@cornell.edu</a> | * @author Tom Dimock <a href="mailto:tad1@cornell.edu">tad1@cornell.edu</a> | ||||
*/ | */ | ||||
public class Delete extends MatchingTask { | 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("<file> or <dir> attribute must be set!"); | |||||
} | |||||
// old <delete> 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("<file> or <dir> attribute must be set!"); | |||||
} | |||||
// old <delete> 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()); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
@@ -72,7 +72,7 @@ public class Deltree extends Task { | |||||
} | } | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
project.log("Deleting: " + dir.getAbsolutePath()); | |||||
log("Deleting: " + dir.getAbsolutePath()); | |||||
if (dir.exists()) { | if (dir.exists()) { | ||||
if (!dir.isDirectory()) { | if (!dir.isDirectory()) { | ||||
@@ -83,10 +83,10 @@ public class Exec extends Task { | |||||
// test if os match | // test if os match | ||||
String myos = System.getProperty("os.name"); | 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)){ | if ((os != null) && (os.indexOf(myos) < 0)){ | ||||
// this command will be executed only on the specified OS | // 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; | return 0; | ||||
} | } | ||||
@@ -106,14 +106,14 @@ public class Exec extends Task { | |||||
try { | try { | ||||
// show the command | // show the command | ||||
project.log(command, "exec", Project.MSG_VERBOSE); | |||||
log(command, Project.MSG_VERBOSE); | |||||
// exec command on system runtime | // exec command on system runtime | ||||
Process proc = Runtime.getRuntime().exec(command); | Process proc = Runtime.getRuntime().exec(command); | ||||
if( out!=null ) { | if( out!=null ) { | ||||
fos=new PrintWriter( new FileWriter( out ) ); | 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 | // copy input and error to the output stream | ||||
@@ -138,7 +138,7 @@ public class Exec extends Task { | |||||
// check its exit value | // check its exit value | ||||
err = proc.exitValue(); | err = proc.exitValue(); | ||||
if (err != 0) { | if (err != 0) { | ||||
project.log("Result: " + err, "exec", Project.MSG_ERR); | |||||
log("Result: " + err, Project.MSG_ERR); | |||||
} | } | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
throw new BuildException("Error exec: " + command, ioe, location); | throw new BuildException("Error exec: " + command, ioe, location); | ||||
@@ -165,7 +165,7 @@ public class Exec extends Task { | |||||
protected void outputLog(String line, int messageLevel) { | protected void outputLog(String line, int messageLevel) { | ||||
if (fos == null) { | if (fos == null) { | ||||
project.log(line, messageLevel); | |||||
log(line, messageLevel); | |||||
} else { | } else { | ||||
fos.println(line); | fos.println(line); | ||||
} | } | ||||
@@ -81,7 +81,7 @@ public class Expand extends Task { | |||||
File srcF=project.resolveFile(source); | File srcF=project.resolveFile(source); | ||||
File dir=project.resolveFile(dest); | 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 | // code from WarExpand | ||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(srcF)); | ZipInputStream zis = new ZipInputStream(new FileInputStream(srcF)); | ||||
ZipEntry ze = null; | ZipEntry ze = null; | ||||
@@ -89,7 +89,7 @@ public class Expand extends Task { | |||||
while ((ze = zis.getNextEntry()) != null) { | while ((ze = zis.getNextEntry()) != null) { | ||||
try { | try { | ||||
File f = new File(dir, project.translatePath(ze.getName())); | 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 | // create intermediary directories - sometimes zip don't add them | ||||
File dirF=new File(f.getParent()); | File dirF=new File(f.getParent()); | ||||
dirF.mkdirs(); | dirF.mkdirs(); | ||||
@@ -118,7 +118,7 @@ public class Expand extends Task { | |||||
System.out.println("FileNotFoundException: " + ze.getName() ); | System.out.println("FileNotFoundException: " + ze.getName() ); | ||||
} | } | ||||
} | } | ||||
project.log("</log:expand>", Project.MSG_VERBOSE ); | |||||
log("</log:expand>", Project.MSG_VERBOSE ); | |||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
ioe.printStackTrace(); | ioe.printStackTrace(); | ||||
} | } | ||||
@@ -223,11 +223,11 @@ public class FixCRLF extends MatchingTask { | |||||
} | } | ||||
// log options used | // log options used | ||||
project.log("options:" + | |||||
log("options:" + | |||||
" cr=" + (addcr==-1 ? "add" : addcr==0 ? "asis" : "remove") + | " cr=" + (addcr==-1 ? "add" : addcr==0 ? "asis" : "remove") + | ||||
" tab=" + (addtab==-1 ? "add" : addtab==0 ? "asis" : "remove") + | " tab=" + (addtab==-1 ? "add" : addtab==0 ? "asis" : "remove") + | ||||
" eof=" + (ctrlz==-1 ? "add" : ctrlz==0 ? "asis" : "remove"), | " eof=" + (ctrlz==-1 ? "add" : ctrlz==0 ? "asis" : "remove"), | ||||
"fixcrlf", project.MSG_VERBOSE); | |||||
Project.MSG_VERBOSE); | |||||
DirectoryScanner ds = super.getDirectoryScanner(srcDir); | DirectoryScanner ds = super.getDirectoryScanner(srcDir); | ||||
String[] files = ds.getIncludedFiles(); | String[] files = ds.getIncludedFiles(); | ||||
@@ -262,9 +262,9 @@ public class FixCRLF extends MatchingTask { | |||||
boolean eof = ((count>0) && (indata[count-1] == 0x1A)); | boolean eof = ((count>0) && (indata[count-1] == 0x1A)); | ||||
// log stats (before fixes) | // log stats (before fixes) | ||||
project.log(srcFile + ": size=" + count + " cr=" + cr + | |||||
log(srcFile + ": size=" + count + " cr=" + cr + | |||||
" lf=" + lf + " tab=" + tab + " eof=" + eof, | " lf=" + lf + " tab=" + tab + " eof=" + eof, | ||||
"fixcrlf", project.MSG_VERBOSE); | |||||
Project.MSG_VERBOSE); | |||||
// determine the output buffer size (slightly pessimisticly) | // determine the output buffer size (slightly pessimisticly) | ||||
int outsize = count; | int outsize = count; | ||||
@@ -109,7 +109,7 @@ public class GUnzip extends Task { | |||||
} | } | ||||
if (source.lastModified() > dest.lastModified()) { | if (source.lastModified() > dest.lastModified()) { | ||||
project.log("Expanding "+ source.getAbsolutePath() + " to " | |||||
log("Expanding "+ source.getAbsolutePath() + " to " | |||||
+ dest.getAbsolutePath()); | + dest.getAbsolutePath()); | ||||
try { | try { | ||||
@@ -81,13 +81,13 @@ public class GZip extends Task { | |||||
} | } | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
project.log("Building gzip: " + zipFile.getAbsolutePath()); | |||||
log("Building gzip: " + zipFile.getAbsolutePath()); | |||||
try { | try { | ||||
GZIPOutputStream zOut = new GZIPOutputStream(new FileOutputStream(zipFile)); | GZIPOutputStream zOut = new GZIPOutputStream(new FileOutputStream(zipFile)); | ||||
if (source.isDirectory()) { | if (source.isDirectory()) { | ||||
project.log ("Cannot Gzip a directory!"); | |||||
log ("Cannot Gzip a directory!"); | |||||
} else { | } else { | ||||
zipFile(source, zOut); | zipFile(source, zOut); | ||||
} | } | ||||
@@ -82,7 +82,7 @@ public class Get extends Task { | |||||
throw new BuildException(e.toString()); | throw new BuildException(e.toString()); | ||||
} | } | ||||
project.log("Getting: " + source); | |||||
log("Getting: " + source); | |||||
File destF=new File(dest); | File destF=new File(dest); | ||||
FileOutputStream fos = new FileOutputStream(destF); | FileOutputStream fos = new FileOutputStream(destF); | ||||
@@ -93,11 +93,11 @@ public class Get extends Task { | |||||
is = url.openStream(); | is = url.openStream(); | ||||
break; | break; | ||||
} catch( IOException ex ) { | } catch( IOException ex ) { | ||||
project.log( "Error opening connection " + ex ); | |||||
log( "Error opening connection " + ex ); | |||||
} | } | ||||
} | } | ||||
if( is==null ) { | if( is==null ) { | ||||
project.log( "Can't get " + source + " to " + dest); | |||||
log( "Can't get " + source + " to " + dest); | |||||
if( ignoreErrors != null ) return; | if( ignoreErrors != null ) return; | ||||
throw new BuildException( "Can't get " + source + " to " + dest); | throw new BuildException( "Can't get " + source + " to " + dest); | ||||
} | } | ||||
@@ -113,7 +113,7 @@ public class Get extends Task { | |||||
fos.close(); | fos.close(); | ||||
is.close(); | is.close(); | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
project.log("Error getting " + source + " to " + dest ); | |||||
log("Error getting " + source + " to " + dest ); | |||||
if( ignoreErrors != null ) return; | if( ignoreErrors != null ) return; | ||||
throw new BuildException(ioe.toString()); | throw new BuildException(ioe.toString()); | ||||
} | } | ||||
@@ -86,7 +86,7 @@ public class Java extends Exec { | |||||
* a separate VM (fork = "yes"). | * a separate VM (fork = "yes"). | ||||
*/ | */ | ||||
public int executeJava() throws BuildException { | public int executeJava() throws BuildException { | ||||
project.log("Calling " + classname, "java", project.MSG_VERBOSE); | |||||
log("Calling " + classname, Project.MSG_VERBOSE); | |||||
if (classname == null) { | if (classname == null) { | ||||
throw new BuildException("Classname must not be null."); | throw new BuildException("Classname must not be null."); | ||||
@@ -113,8 +113,11 @@ public class Java extends Exec { | |||||
return run(b.toString()); | return run(b.toString()); | ||||
} else { | } else { | ||||
Vector argList = tokenize(args); | 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); | run(classname, argList); | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -131,9 +134,9 @@ public class Java extends Exec { | |||||
* Set the source file (deprecated). | * Set the source file (deprecated). | ||||
*/ | */ | ||||
public void setClass(String s) { | 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; | this.classname = s; | ||||
} | } | ||||
@@ -284,8 +284,8 @@ public class Javac extends MatchingTask { | |||||
} | } | ||||
if (compileList.size() > 0) { | 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")) { | if (compiler.equalsIgnoreCase("classic")) { | ||||
doClassicCompile(); | doClassicCompile(); | ||||
@@ -302,12 +302,12 @@ public class Javac extends MatchingTask { | |||||
// copy the support files | // copy the support files | ||||
if (filecopyList.size() > 0) { | 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(); | Enumeration enum = filecopyList.keys(); | ||||
while (enum.hasMoreElements()) { | while (enum.hasMoreElements()) { | ||||
String fromFile = (String) enum.nextElement(); | String fromFile = (String) enum.nextElement(); | ||||
@@ -348,8 +348,8 @@ public class Javac extends MatchingTask { | |||||
files[i].indexOf(".java")) + ".class"); | files[i].indexOf(".java")) + ".class"); | ||||
if (srcFile.lastModified() > now) { | 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()) { | if (srcFile.lastModified() > classFile.lastModified()) { | ||||
@@ -435,8 +435,8 @@ public class Javac extends MatchingTask { | |||||
target.append(File.pathSeparator); | target.append(File.pathSeparator); | ||||
target.append(f.getAbsolutePath()); | target.append(f.getAbsolutePath()); | ||||
} else { | } 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 { | private void doClassicCompile() throws BuildException { | ||||
project.log("Using classic compiler", project.MSG_VERBOSE); | |||||
log("Using classic compiler", Project.MSG_VERBOSE); | |||||
String classpath = getCompileClasspath(false); | String classpath = getCompileClasspath(false); | ||||
Vector argList = new Vector(); | Vector argList = new Vector(); | ||||
@@ -505,8 +505,8 @@ public class Javac extends MatchingTask { | |||||
argList.addElement(extdirs); | 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()]; | String[] args = new String[argList.size() + compileList.size()]; | ||||
int counter = 0; | int counter = 0; | ||||
@@ -529,14 +529,14 @@ public class Javac extends MatchingTask { | |||||
counter++; | counter++; | ||||
} | } | ||||
project.log(niceSourceList.toString(), project.MSG_VERBOSE); | |||||
log(niceSourceList.toString(), Project.MSG_VERBOSE); | |||||
// XXX | // XXX | ||||
// provide the compiler a different message sink - namely our own | // provide the compiler a different message sink - namely our own | ||||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||||
sun.tools.javac.Main compiler = | 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)) { | if (!compiler.compile(args)) { | ||||
throw new BuildException("Compile failed"); | throw new BuildException("Compile failed"); | ||||
@@ -548,7 +548,7 @@ public class Javac extends MatchingTask { | |||||
*/ | */ | ||||
private void doModernCompile() throws BuildException { | private void doModernCompile() throws BuildException { | ||||
project.log("Using modern compiler", project.MSG_VERBOSE); | |||||
log("Using modern compiler", Project.MSG_VERBOSE); | |||||
String classpath = getCompileClasspath(false); | String classpath = getCompileClasspath(false); | ||||
Vector argList = new Vector(); | Vector argList = new Vector(); | ||||
@@ -580,8 +580,8 @@ public class Javac extends MatchingTask { | |||||
argList.addElement(extdirs); | 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()]; | String[] args = new String[argList.size() + compileList.size()]; | ||||
int counter = 0; | int counter = 0; | ||||
@@ -604,7 +604,7 @@ public class Javac extends MatchingTask { | |||||
counter++; | 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 | // This won't build under JDK1.2.2 because the new compiler | ||||
// doesn't exist there. | // doesn't exist there. | ||||
@@ -643,7 +643,7 @@ public class Javac extends MatchingTask { | |||||
*/ | */ | ||||
private void doJikesCompile() throws BuildException { | private void doJikesCompile() throws BuildException { | ||||
project.log("Using jikes compiler",project.MSG_VERBOSE); | |||||
log("Using jikes compiler", Project.MSG_VERBOSE); | |||||
StringBuffer classpath = new StringBuffer(); | StringBuffer classpath = new StringBuffer(); | ||||
classpath.append(getCompileClasspath(true)); | classpath.append(getCompileClasspath(true)); | ||||
@@ -721,8 +721,8 @@ public class Javac extends MatchingTask { | |||||
if (!warnings) | if (!warnings) | ||||
argList.addElement("-nowarn"); | 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()]; | String[] args = new String[argList.size() + compileList.size()]; | ||||
int counter = 0; | int counter = 0; | ||||
@@ -745,12 +745,12 @@ public class Javac extends MatchingTask { | |||||
counter++; | counter++; | ||||
} | } | ||||
project.log(niceSourceList.toString(), project.MSG_VERBOSE); | |||||
log(niceSourceList.toString(), Project.MSG_VERBOSE); | |||||
// XXX | // XXX | ||||
// provide the compiler a different message sink - namely our own | // 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"); | Jikes compiler = new Jikes(jop,"jikes"); | ||||
compiler.compile(args); | compiler.compile(args); | ||||
@@ -60,7 +60,7 @@ import java.io.*; | |||||
/** | /** | ||||
* Serves as an output stream to Javac. This let's us print messages | * 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. | * while compiling. | ||||
* | * | ||||
* @author James Duncan Davidson (duncan@x180.com) | * @author James Duncan Davidson (duncan@x180.com) | ||||
@@ -68,17 +68,17 @@ import java.io.*; | |||||
class JavacOutputStream extends OutputStream { | class JavacOutputStream extends OutputStream { | ||||
private Project project; | |||||
private Task task; | |||||
private StringBuffer line; | private StringBuffer line; | ||||
private boolean errorFlag = false; | 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. | * as the output source for messages. | ||||
*/ | */ | ||||
JavacOutputStream(Project project) { | |||||
this.project = project; | |||||
JavacOutputStream(Task task) { | |||||
this.task = task; | |||||
line = new StringBuffer(); | line = new StringBuffer(); | ||||
} | } | ||||
@@ -109,7 +109,7 @@ class JavacOutputStream extends OutputStream { | |||||
if (s.indexOf("error") > -1) { | if (s.indexOf("error") > -1) { | ||||
errorFlag = true; | errorFlag = true; | ||||
} | } | ||||
project.log(s); | |||||
task.log(s); | |||||
line = new StringBuffer(); | line = new StringBuffer(); | ||||
} | } | ||||
@@ -329,7 +329,7 @@ public class Javadoc extends Exec { | |||||
boolean javadoc1 = (Project.getJavaVersion() == Project.JAVA_1_1); | 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(); | Vector argList = new Vector(); | ||||
@@ -577,9 +577,9 @@ public class Javadoc extends Exec { | |||||
if (packageList != null) { | if (packageList != null) { | ||||
argList.addElement("@" + packageList); | 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(); | StringBuffer b = new StringBuffer(); | ||||
b.append("javadoc "); | b.append("javadoc "); | ||||
@@ -606,9 +606,9 @@ public class Javadoc extends Exec { | |||||
* patterns. | * patterns. | ||||
*/ | */ | ||||
private void evaluatePackages(String sourcePath, Vector packages, Vector argList) { | 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(); | Vector addedPackages = new Vector(); | ||||
PathTokenizer tokenizer = new PathTokenizer(sourcePath); | PathTokenizer tokenizer = new PathTokenizer(sourcePath); | ||||
@@ -687,7 +687,7 @@ public class Javadoc extends Exec { | |||||
} | } | ||||
} | } | ||||
if (count > 0) { | 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 { | } else { | ||||
throw new BuildException("Error occurred during " + path + " evaluation."); | throw new BuildException("Error occurred during " + path + " evaluation."); | ||||
@@ -708,7 +708,7 @@ public class Javadoc extends Exec { | |||||
while (true) { | while (true) { | ||||
line = reader.readLine(); | line = reader.readLine(); | ||||
if (line == null) { | 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; | return null; | ||||
} | } | ||||
if (line.trim().startsWith("package ")) { | if (line.trim().startsWith("package ")) { | ||||
@@ -718,11 +718,11 @@ public class Javadoc extends Exec { | |||||
} | } | ||||
reader.close(); | reader.close(); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
project.log("Exception " + e + " parsing " + file, "javadoc", project.MSG_WARN); | |||||
log("Exception " + e + " parsing " + file, Project.MSG_WARN); | |||||
return null; | return null; | ||||
} | } | ||||
project.log(file + " --> " + name, "javadoc", project.MSG_VERBOSE); | |||||
log(file + " --> " + name, Project.MSG_VERBOSE); | |||||
return name; | return name; | ||||
} | } | ||||
@@ -736,15 +736,15 @@ public class Javadoc extends Exec { | |||||
protected void outputLog(String line, int messageLevel) { | protected void outputLog(String line, int messageLevel) { | ||||
if (messageLevel==project.MSG_INFO && line.startsWith("Generating ")) { | if (messageLevel==project.MSG_INFO && line.startsWith("Generating ")) { | ||||
if (queuedLine != null) { | if (queuedLine != null) { | ||||
super.outputLog(queuedLine, project.MSG_VERBOSE); | |||||
super.outputLog(queuedLine, Project.MSG_VERBOSE); | |||||
} | } | ||||
queuedLine = line; | queuedLine = line; | ||||
} else { | } else { | ||||
if (queuedLine != null) { | if (queuedLine != null) { | ||||
if (line.startsWith("Building ")) | if (line.startsWith("Building ")) | ||||
super.outputLog(queuedLine, project.MSG_VERBOSE); | |||||
super.outputLog(queuedLine, Project.MSG_VERBOSE); | |||||
else | else | ||||
super.outputLog(queuedLine, project.MSG_INFO); | |||||
super.outputLog(queuedLine, Project.MSG_INFO); | |||||
queuedLine = null; | queuedLine = null; | ||||
} | } | ||||
super.outputLog(line, messageLevel); | super.outputLog(line, messageLevel); | ||||
@@ -753,7 +753,7 @@ public class Javadoc extends Exec { | |||||
protected void logFlush() { | protected void logFlush() { | ||||
if (queuedLine != null) { | if (queuedLine != null) { | ||||
super.outputLog(queuedLine, project.MSG_VERBOSE); | |||||
super.outputLog(queuedLine, Project.MSG_VERBOSE); | |||||
queuedLine = null; | queuedLine = null; | ||||
} | } | ||||
super.logFlush(); | super.logFlush(); | ||||
@@ -14,7 +14,7 @@ import java.io.*; | |||||
* @author skanthak@muehlheim.de | * @author skanthak@muehlheim.de | ||||
*/ | */ | ||||
public class JikesOutputParser { | public class JikesOutputParser { | ||||
protected Project project; | |||||
protected Task task; | |||||
protected boolean errorFlag = false; // no errors so far | protected boolean errorFlag = false; // no errors so far | ||||
protected int errors,warnings; | protected int errors,warnings; | ||||
protected boolean error = false; | protected boolean error = false; | ||||
@@ -22,11 +22,11 @@ public class JikesOutputParser { | |||||
/** | /** | ||||
* Construct a new Parser object | * 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(); | super(); | ||||
this.project = project; | |||||
this.task = task; | |||||
this.emacsMode = emacsMode; | this.emacsMode = emacsMode; | ||||
} | } | ||||
@@ -88,9 +88,9 @@ public class JikesOutputParser { | |||||
private void log(String line) { | private void log(String line) { | ||||
if (!emacsMode) { | 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)); | |||||
} | } | ||||
/** | /** | ||||
@@ -76,10 +76,10 @@ public class KeySubst extends Task { | |||||
Do the execution. | Do the execution. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | 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 ) { | if ( source == null || dest == null ) { | ||||
project.log("Source and destinations must not be null"); | |||||
log("Source and destinations must not be null"); | |||||
return; | return; | ||||
} | } | ||||
BufferedReader br = null; | BufferedReader br = null; | ||||
@@ -152,8 +152,8 @@ public class KeySubst extends Task { | |||||
String name = itok.nextToken(); | String name = itok.nextToken(); | ||||
String value = itok.nextToken(); | String value = itok.nextToken(); | ||||
// project.log ( "Name: " + name ); | |||||
// project.log ( "Value: " + value ); | |||||
// log ( "Name: " + name ); | |||||
// log ( "Value: " + value ); | |||||
replacements.put ( name, value ); | replacements.put ( name, value ); | ||||
} | } | ||||
} | } | ||||
@@ -137,9 +137,9 @@ public abstract class MatchingTask extends Task { | |||||
* @param itemString the string containing the files to include. | * @param itemString the string containing the files to include. | ||||
*/ | */ | ||||
public void setItems(String itemString) { | 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("*") | if (itemString == null || itemString.equals("*") | ||||
|| itemString.equals(".")) { | || itemString.equals(".")) { | ||||
createInclude().setName("**"); | createInclude().setName("**"); | ||||
@@ -173,9 +173,9 @@ public abstract class MatchingTask extends Task { | |||||
* @param ignoreString the string containing the files to ignore. | * @param ignoreString the string containing the files to ignore. | ||||
*/ | */ | ||||
public void setIgnore(String ignoreString) { | 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) { | if (ignoreString != null && ignoreString.length() > 0) { | ||||
Vector tmpExcludes = new Vector(); | Vector tmpExcludes = new Vector(); | ||||
StringTokenizer tok = new StringTokenizer(ignoreString, ", ", false); | StringTokenizer tok = new StringTokenizer(ignoreString, ", ", false); | ||||
@@ -266,8 +266,8 @@ public abstract class MatchingTask extends Task { | |||||
line = patternReader.readLine(); | line = patternReader.readLine(); | ||||
} | } | ||||
} catch(IOException ioe) { | } 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) { | if (includesfile != null && includesfile.length() > 0) { | ||||
File incl = project.resolveFile(includesfile); | File incl = project.resolveFile(includesfile); | ||||
if (!incl.exists()) { | if (!incl.exists()) { | ||||
project.log("Includesfile "+includesfile+" not found.", | |||||
Project.MSG_ERR); | |||||
log("Includesfile "+includesfile+" not found.", | |||||
Project.MSG_ERR); | |||||
} else { | } else { | ||||
readPatterns(incl, includeList); | readPatterns(incl, includeList); | ||||
} | } | ||||
@@ -299,8 +299,8 @@ public abstract class MatchingTask extends Task { | |||||
if (excludesfile != null && excludesfile.length() > 0) { | if (excludesfile != null && excludesfile.length() > 0) { | ||||
File excl = project.resolveFile(excludesfile); | File excl = project.resolveFile(excludesfile); | ||||
if (!excl.exists()) { | if (!excl.exists()) { | ||||
project.log("Excludesfile "+excludesfile+" not found.", | |||||
Project.MSG_ERR); | |||||
log("Excludesfile "+excludesfile+" not found.", | |||||
Project.MSG_ERR); | |||||
} else { | } else { | ||||
readPatterns(excl, excludeList); | readPatterns(excl, excludeList); | ||||
} | } | ||||
@@ -77,7 +77,7 @@ public class Mkdir extends Task { | |||||
"succesful for an unknown reason"; | "succesful for an unknown reason"; | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
project.log("Created dir: " + dir.getAbsolutePath()); | |||||
log("Created dir: " + dir.getAbsolutePath()); | |||||
} | } | ||||
} | } | ||||
@@ -105,15 +105,15 @@ public class Property extends Task { | |||||
if (project.getUserProperty(name) == null) { | if (project.getUserProperty(name) == null) { | ||||
project.setUserProperty(name, value); | project.setUserProperty(name, value); | ||||
} else { | } else { | ||||
project.log("Override ignored for " + name, | |||||
project.MSG_VERBOSE); | |||||
log("Override ignored for " + name, | |||||
Project.MSG_VERBOSE); | |||||
} | } | ||||
else | else | ||||
if (project.getProperty(name) == null) { | if (project.getProperty(name) == null) { | ||||
project.setProperty(name, value); | project.setProperty(name, value); | ||||
} else { | } 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) { | private void loadFile (String name) { | ||||
Properties props = new Properties(); | Properties props = new Properties(); | ||||
project.log("Loading " + name, project.MSG_VERBOSE); | |||||
log("Loading " + name, Project.MSG_VERBOSE); | |||||
try { | try { | ||||
if (new File(name).exists()) { | if (new File(name).exists()) { | ||||
props.load(new FileInputStream(name)); | props.load(new FileInputStream(name)); | ||||
@@ -141,7 +141,7 @@ public class Property extends Task { | |||||
private void loadResource( String name ) { | private void loadResource( String name ) { | ||||
Properties props = new Properties(); | Properties props = new Properties(); | ||||
project.log("Resource Loading " + name, project.MSG_VERBOSE); | |||||
log("Resource Loading " + name, Project.MSG_VERBOSE); | |||||
try { | try { | ||||
InputStream is = this.getClass().getResourceAsStream(name); | InputStream is = this.getClass().getResourceAsStream(name); | ||||
if (is != null) { | if (is != null) { | ||||
@@ -163,15 +163,15 @@ public class Property extends Task { | |||||
if (project.getUserProperty(name) == null) { | if (project.getUserProperty(name) == null) { | ||||
project.setUserProperty(name, v); | project.setUserProperty(name, v); | ||||
} else { | } else { | ||||
project.log("Override ignored for " + name, | |||||
project.MSG_VERBOSE); | |||||
log("Override ignored for " + name, | |||||
Project.MSG_VERBOSE); | |||||
} | } | ||||
else | else | ||||
if (project.getProperty(name) == null) { | if (project.getProperty(name) == null) { | ||||
project.setProperty(name, v); | project.setProperty(name, v); | ||||
} else { | } else { | ||||
project.log("Override ignored for " + name, | |||||
project.MSG_VERBOSE); | |||||
log("Override ignored for " + name, | |||||
Project.MSG_VERBOSE); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -85,7 +85,7 @@ public class Replace extends MatchingTask { | |||||
throw new BuildException("Either the file or the dir attribute must be specified"); | 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) { | if (src != null) { | ||||
processFile(src); | processFile(src); | ||||
@@ -98,9 +98,9 @@ public class Rmic extends MatchingTask { | |||||
} | } | ||||
public void setClass(String classname) { | 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; | this.classname = classname; | ||||
} | } | ||||
@@ -146,7 +146,7 @@ public class Rmic extends MatchingTask { | |||||
} | } | ||||
if (verify) { | if (verify) { | ||||
project.log("Verify has been turned on.", Project.MSG_INFO); | |||||
log("Verify has been turned on.", Project.MSG_INFO); | |||||
} | } | ||||
File sourceBaseFile = null; | File sourceBaseFile = null; | ||||
if (null != sourceBase) { | if (null != sourceBase) { | ||||
@@ -193,8 +193,8 @@ public class Rmic extends MatchingTask { | |||||
} | } | ||||
} else { | } else { | ||||
if (compileList.size() > 0) { | 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++) { | for (int j = 0; j < compileList.size(); j++) { | ||||
args[i++] = (String) compileList.elementAt(j); | args[i++] = (String) compileList.elementAt(j); | ||||
@@ -272,16 +272,16 @@ public class Rmic extends MatchingTask { | |||||
shouldAdd = false; | shouldAdd = false; | ||||
} | } | ||||
} catch (ClassNotFoundException e) { | } catch (ClassNotFoundException e) { | ||||
project.log("Unable to verify class " + classname + | |||||
log("Unable to verify class " + classname + | |||||
". It could not be found.", Project.MSG_WARN); | ". It could not be found.", Project.MSG_WARN); | ||||
} catch (NoClassDefFoundError e) { | } catch (NoClassDefFoundError e) { | ||||
project.log("Unable to verify class " + classname + | |||||
log("Unable to verify class " + classname + | |||||
". It is not defined.", Project.MSG_WARN); | ". It is not defined.", Project.MSG_WARN); | ||||
} | } | ||||
} | } | ||||
if (shouldAdd) { | if (shouldAdd) { | ||||
project.log("Adding: " + classname + " to compile list", | |||||
Project.MSG_VERBOSE); | |||||
log("Adding: " + classname + " to compile list", | |||||
Project.MSG_VERBOSE); | |||||
compileList.addElement(classname); | compileList.addElement(classname); | ||||
} | } | ||||
} | } | ||||
@@ -329,8 +329,8 @@ public class Rmic extends MatchingTask { | |||||
classFile.getAbsolutePath().indexOf(".class")) + "_Skel.class"); | classFile.getAbsolutePath().indexOf(".class")) + "_Skel.class"); | ||||
if (classFile.exists()) { | if (classFile.exists()) { | ||||
if (classFile.lastModified() > now) { | 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()) { | if (classFile.lastModified() > stubFile.lastModified()) { | ||||
@@ -399,8 +399,8 @@ public class Rmic extends MatchingTask { | |||||
target.append(File.pathSeparator); | target.append(File.pathSeparator); | ||||
target.append(f.getAbsolutePath()); | target.append(f.getAbsolutePath()); | ||||
} else { | } else { | ||||
project.log("Dropping from classpath: "+ | |||||
f.getAbsolutePath(), Project.MSG_VERBOSE); | |||||
log("Dropping from classpath: "+ | |||||
f.getAbsolutePath(), Project.MSG_VERBOSE); | |||||
} | } | ||||
} | } | ||||
@@ -84,7 +84,7 @@ public class Tar extends MatchingTask { | |||||
} | } | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
project.log("Building tar: "+ tarFile.getAbsolutePath()); | |||||
log("Building tar: "+ tarFile.getAbsolutePath()); | |||||
if (baseDir == null) { | if (baseDir == null) { | ||||
throw new BuildException("basedir attribute must be set!"); | throw new BuildException("basedir attribute must be set!"); | ||||
@@ -71,7 +71,7 @@ import java.io.*; | |||||
public class TaskOutputStream extends OutputStream { | public class TaskOutputStream extends OutputStream { | ||||
private Project project; | |||||
private Task task; | |||||
private StringBuffer line; | private StringBuffer line; | ||||
private int msgOutputLevel; | private int msgOutputLevel; | ||||
@@ -80,8 +80,8 @@ public class TaskOutputStream extends OutputStream { | |||||
* as the output source for messages. | * 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; | this.msgOutputLevel = msgOutputLevel; | ||||
line = new StringBuffer(); | line = new StringBuffer(); | ||||
@@ -111,7 +111,7 @@ public class TaskOutputStream extends OutputStream { | |||||
private void processLine() { | private void processLine() { | ||||
String s = line.toString(); | String s = line.toString(); | ||||
project.log(s, msgOutputLevel); | |||||
task.log(s, msgOutputLevel); | |||||
line = new StringBuffer(); | line = new StringBuffer(); | ||||
} | } | ||||
} | } | ||||
@@ -95,9 +95,9 @@ public class Taskdef extends Task { | |||||
} | } | ||||
public void setClass(String v) { | 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; | value = v; | ||||
} | } | ||||
@@ -112,9 +112,9 @@ public class Touch extends Task { | |||||
*/ | */ | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
if (file.exists() && project.getJavaVersion() == Project.JAVA_1_1) { | 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; | return; | ||||
} | } | ||||
@@ -130,9 +130,8 @@ public class Touch extends Task { | |||||
} | } | ||||
if (millis >= 0 && project.getJavaVersion() == Project.JAVA_1_1) { | 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(); | touch(); | ||||
@@ -143,7 +142,7 @@ public class Touch extends Task { | |||||
*/ | */ | ||||
void touch() throws BuildException { | void touch() throws BuildException { | ||||
if (!file.exists()) { | if (!file.exists()) { | ||||
project.log("Creating "+file, Project.MSG_INFO); | |||||
log("Creating "+file, Project.MSG_INFO); | |||||
try { | try { | ||||
FileOutputStream fos = new FileOutputStream(file); | FileOutputStream fos = new FileOutputStream(file); | ||||
fos.write(new byte[0]); | fos.write(new byte[0]); | ||||
@@ -181,8 +180,8 @@ public class Touch extends Task { | |||||
} | } | ||||
try { | try { | ||||
project.log("Setting modification time for "+file, | |||||
Project.MSG_VERBOSE); | |||||
log("Setting modification time for "+file, | |||||
Project.MSG_VERBOSE); | |||||
setLastModified.invoke(file, times); | setLastModified.invoke(file, times); | ||||
} catch (InvocationTargetException ite) { | } catch (InvocationTargetException ite) { | ||||
@@ -94,7 +94,7 @@ public class Untar extends Task { | |||||
} | } | ||||
File dir=project.resolveFile(dest); | 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 | // code from WarExpand | ||||
TarInputStream tis = new TarInputStream(new FileInputStream(srcF)); | TarInputStream tis = new TarInputStream(new FileInputStream(srcF)); | ||||
TarEntry te = null; | TarEntry te = null; | ||||
@@ -102,8 +102,7 @@ public class Untar extends Task { | |||||
while ((te = tis.getNextEntry()) != null) { | while ((te = tis.getNextEntry()) != null) { | ||||
try { | try { | ||||
File f = new File(dir, project.translatePath(te.getName())); | 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 | // create intermediary directories - sometimes tar don't add them | ||||
File dirF=new File(f.getParent()); | File dirF=new File(f.getParent()); | ||||
dirF.mkdirs(); | dirF.mkdirs(); | ||||
@@ -129,8 +128,8 @@ public class Untar extends Task { | |||||
} | } | ||||
} catch(FileNotFoundException ex) { | } catch(FileNotFoundException ex) { | ||||
project.log("FileNotFoundException: " + te.getName(), | |||||
Project.MSG_WARN); | |||||
log("FileNotFoundException: " + te.getName(), | |||||
Project.MSG_WARN); | |||||
} | } | ||||
} | } | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
@@ -120,7 +120,7 @@ public class XSLTProcess extends MatchingTask { | |||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
scanner = getDirectoryScanner(baseDir); | 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, | // if processor wasn't specified, default it to xslp or xalan, | ||||
// depending on which is in the classpath | // 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 { | try { | ||||
// Create a new XSL processor with the specified stylesheet | // Create a new XSL processor with the specified stylesheet | ||||
if (xslFile != null) { | if (xslFile != null) { | ||||
String file = new File(baseDir,xslFile.toString()).toString(); | 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 ); | liaison.setStylesheet( file ); | ||||
} | } | ||||
} catch (Exception ex) { | } 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); | throw new BuildException(ex); | ||||
} | } | ||||
@@ -296,7 +296,7 @@ public class XSLTProcess extends MatchingTask { | |||||
outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt); | outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt); | ||||
if (inFile.lastModified() > outFile.lastModified()) { | if (inFile.lastModified() > outFile.lastModified()) { | ||||
//-- command line status | //-- 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()); | liaison.transform(inFile.toString(), outFile.toString()); | ||||
} | } | ||||
@@ -304,7 +304,7 @@ public class XSLTProcess extends MatchingTask { | |||||
catch (Exception ex) { | catch (Exception ex) { | ||||
// If failed to process document, must delete target document, | // If failed to process document, must delete target document, | ||||
// or it will not attempt to process it the second time | // 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(); | outFile.delete(); | ||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
@@ -120,7 +120,7 @@ public class Zip extends MatchingTask { | |||||
upToDate = false; | upToDate = false; | ||||
if (upToDate) return; | if (upToDate) return; | ||||
project.log("Building "+ archiveType +": "+ zipFile.getAbsolutePath()); | |||||
log("Building "+ archiveType +": "+ zipFile.getAbsolutePath()); | |||||
try { | try { | ||||
ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(zipFile)); | ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(zipFile)); | ||||
@@ -442,7 +442,7 @@ public class NetRexxC extends MatchingTask { | |||||
// compile the source files | // compile the source files | ||||
if (compileList.size() > 0) { | if (compileList.size() > 0) { | ||||
project.log("Compiling " + compileList.size() + " source files to " + destDir); | |||||
log("Compiling " + compileList.size() + " source files to " + destDir); | |||||
doNetRexxCompile(); | doNetRexxCompile(); | ||||
} | } | ||||
} | } | ||||
@@ -479,7 +479,7 @@ public class NetRexxC extends MatchingTask { | |||||
*/ | */ | ||||
private void copyFilesToDestination() { | private void copyFilesToDestination() { | ||||
if (filecopyList.size() > 0) { | 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(); | Enumeration enum = filecopyList.keys(); | ||||
while (enum.hasMoreElements()) { | while (enum.hasMoreElements()) { | ||||
String fromFile = (String)enum.nextElement(); | String fromFile = (String)enum.nextElement(); | ||||
@@ -499,7 +499,7 @@ public class NetRexxC extends MatchingTask { | |||||
* Peforms a copmile using the NetRexx 1.1.x compiler | * Peforms a copmile using the NetRexx 1.1.x compiler | ||||
*/ | */ | ||||
private void doNetRexxCompile() throws BuildException { | private void doNetRexxCompile() throws BuildException { | ||||
project.log("Using NetRexx compiler", project.MSG_VERBOSE); | |||||
log("Using NetRexx compiler", Project.MSG_VERBOSE); | |||||
String classpath = getCompileClasspath(); | String classpath = getCompileClasspath(); | ||||
StringBuffer compileOptions = new StringBuffer(); | StringBuffer compileOptions = new StringBuffer(); | ||||
StringBuffer fileList = new StringBuffer(); | StringBuffer fileList = new StringBuffer(); | ||||
@@ -529,7 +529,7 @@ public class NetRexxC extends MatchingTask { | |||||
compileOptions.append(compileOptionsArray[i]); | compileOptions.append(compileOptionsArray[i]); | ||||
compileOptions.append(" "); | compileOptions.append(" "); | ||||
} | } | ||||
project.log(compileOptions.toString(), project.MSG_VERBOSE); | |||||
log(compileOptions.toString(), Project.MSG_VERBOSE); | |||||
String eol = System.getProperty("line.separator"); | String eol = System.getProperty("line.separator"); | ||||
StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" + eol); | StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" + eol); | ||||
@@ -540,7 +540,7 @@ public class NetRexxC extends MatchingTask { | |||||
niceSourceList.append(eol); | 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 | // need to set java.class.path property and restore it later | ||||
// since the NetRexx compiler has no option for the classpath | // 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)); | new Rexx(compileArgs), new PrintWriter(out)); | ||||
if (rc > 1) { // 1 is warnings from real NetRexxC | 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."; | String msg = "Compile failed, messages should have been provided."; | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
else if (rc == 1) { | else if (rc == 1) { | ||||
project.log(out.toString(), Project.MSG_WARN); | |||||
log(out.toString(), Project.MSG_WARN); | |||||
} | } | ||||
else { | else { | ||||
project.log(out.toString(), Project.MSG_INFO); | |||||
log(out.toString(), Project.MSG_INFO); | |||||
} | } | ||||
} finally { | } finally { | ||||
// need to reset java.class.path property | // need to reset java.class.path property | ||||
@@ -648,8 +648,8 @@ public class NetRexxC extends MatchingTask { | |||||
target.append(File.pathSeparator); | target.append(File.pathSeparator); | ||||
target.append(f.getAbsolutePath()); | target.append(f.getAbsolutePath()); | ||||
} else { | } else { | ||||
project.log("Dropping from classpath: "+ | |||||
f.getAbsolutePath(),project.MSG_VERBOSE); | |||||
log("Dropping from classpath: "+ | |||||
f.getAbsolutePath(), Project.MSG_VERBOSE); | |||||
} | } | ||||
} | } | ||||
@@ -151,10 +151,10 @@ public class RenameExtensions extends MatchingTask { | |||||
if (replace || !destFile.exists()) { | if (replace || !destFile.exists()) { | ||||
list.put(srcFile, destFile); | list.put(srcFile, destFile); | ||||
} else { | } 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 { | } 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; | return list; | ||||