From 9a988bb81b7a36090bd5e0538e147f858418f244 Mon Sep 17 00:00:00 2001 From: Jacobus Martinus Kruithof Date: Thu, 2 Feb 2006 20:08:32 +0000 Subject: [PATCH] 38458 removed log implementation of Task to allow logging from tasks outside a project. The base class has the logging behaviour we need. This does not guarantee that (all) tasks are working outside an project, but at least will not break just because of logging. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@374482 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ .../org/apache/tools/ant/ProjectComponent.java | 6 +++--- src/main/org/apache/tools/ant/Task.java | 14 +------------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 9f5212f26..a8bb68085 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -4,6 +4,9 @@ Changes from current Ant 1.6.5 version to current RCS version Changes that could break older environments: -------------------------------------------- +* Task will now log correctly even if no project is set. + Bugzilla report 38458. + * Use alternative names for the command line arguments in javac. Bugzilla Report 37546. diff --git a/src/main/org/apache/tools/ant/ProjectComponent.java b/src/main/org/apache/tools/ant/ProjectComponent.java index ba5a3c9b2..71f192e18 100644 --- a/src/main/org/apache/tools/ant/ProjectComponent.java +++ b/src/main/org/apache/tools/ant/ProjectComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation + * Copyright 2001-2004,2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,8 +75,8 @@ public abstract class ProjectComponent { * to be logged. */ public void log(String msg, int msgLevel) { - if (project != null) { - project.log(msg, msgLevel); + if (getProject() != null) { + getProject().log(msg, msgLevel); } else { // 'reasonable' default, if the component is used without // a Project ( for example as a standalone Bean ). diff --git a/src/main/org/apache/tools/ant/Task.java b/src/main/org/apache/tools/ant/Task.java index f275d0b64..8105c26df 100644 --- a/src/main/org/apache/tools/ant/Task.java +++ b/src/main/org/apache/tools/ant/Task.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 The Apache Software Foundation + * Copyright 2000-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -335,18 +335,6 @@ public abstract class Task extends ProjectComponent { log(msg, Project.MSG_INFO); } - /** - * Logs a message with the given priority. This delegates - * the actual logging to the project. - * - * @param msg The message to be logged. Should not be null. - * @param msgLevel The message priority at which this message is to - * be logged. - */ - public void log(String msg, int msgLevel) { - getProject().log(this, msg, msgLevel); - } - /** * Performs this task if it's still valid, or gets a replacement * version and performs that otherwise.