diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
index b1f245fc6c..ebf86abaab 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
@@ -377,8 +377,6 @@ public class DefaultPluginManager
try
{
request = new PluginExecutionRequest( createParameters( mojoDescriptor, session ) );
-
- request.setLog( session.getLog() );
}
catch ( PluginConfigurationException e )
{
@@ -391,6 +389,8 @@ public class DefaultPluginManager
{
plugin = (Plugin) container.lookup( Plugin.ROLE, goalName );
+ plugin.setLog( session.getLog() );
+
// !! This is ripe for refactoring to an aspect.
// Event monitoring.
String event = MavenEvents.MOJO_EXECUTION;
diff --git a/maven-core/src/test/java/org/apache/maven/plugin/GoalDecorationAndResolutionTestPlugin.java b/maven-core/src/test/java/org/apache/maven/plugin/GoalDecorationAndResolutionTestPlugin.java
index 587c77f29a..225106c266 100644
--- a/maven-core/src/test/java/org/apache/maven/plugin/GoalDecorationAndResolutionTestPlugin.java
+++ b/maven-core/src/test/java/org/apache/maven/plugin/GoalDecorationAndResolutionTestPlugin.java
@@ -1,6 +1,23 @@
-/* Created on Jul 18, 2004 */
package org.apache.maven.plugin;
+/*
+ * Copyright 2001-2005 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.monitor.logging.Log;
+
/**
* @author jdcasey
*/
@@ -9,10 +26,17 @@ public class GoalDecorationAndResolutionTestPlugin implements Plugin
private boolean executed = false;
+ private Log log;
+
public void execute(PluginExecutionRequest request) throws PluginExecutionException {
this.executed = true;
}
-
+
+ public void setLog( Log log )
+ {
+ this.log = log;
+ }
+
public boolean executed() {
return executed;
}
diff --git a/maven-core/src/test/java/org/apache/maven/plugin/IntegratedPlugin.java b/maven-core/src/test/java/org/apache/maven/plugin/IntegratedPlugin.java
index cabc7377be..c312ca34f9 100644
--- a/maven-core/src/test/java/org/apache/maven/plugin/IntegratedPlugin.java
+++ b/maven-core/src/test/java/org/apache/maven/plugin/IntegratedPlugin.java
@@ -16,6 +16,8 @@ package org.apache.maven.plugin;
* limitations under the License.
*/
+import org.apache.maven.monitor.logging.Log;
+
/**
*
*
@@ -27,6 +29,8 @@ public class IntegratedPlugin
extends AbstractTestPlugin
implements Plugin
{
+ private Log log;
+
public void execute( PluginExecutionRequest request )
throws PluginExecutionException
{
@@ -38,4 +42,9 @@ public class IntegratedPlugin
executed = true;
}
+
+ public void setLog( Log log )
+ {
+ this.log = log;
+ }
}
diff --git a/maven-plugin/src/main/java/org/apache/maven/plugin/AbstractPlugin.java b/maven-plugin/src/main/java/org/apache/maven/plugin/AbstractPlugin.java
index 66e1cfe95c..509b4b942d 100644
--- a/maven-plugin/src/main/java/org/apache/maven/plugin/AbstractPlugin.java
+++ b/maven-plugin/src/main/java/org/apache/maven/plugin/AbstractPlugin.java
@@ -16,11 +16,20 @@ package org.apache.maven.plugin;
* limitations under the License.
*/
+import org.apache.maven.monitor.logging.Log;
+import org.apache.maven.monitor.logging.SystemStreamLog;
+
+/**
+ * @version $Id$
+ */
public abstract class AbstractPlugin
implements Plugin
{
+ private Log log;
+
/**
* Default behaviour to mimic old behaviour.
+ * @deprecated
*/
public void execute( PluginExecutionRequest request )
throws PluginExecutionException
@@ -48,4 +57,21 @@ public abstract class AbstractPlugin
public abstract void execute( PluginExecutionRequest request, PluginExecutionResponse response )
throws Exception;
+ public void setLog( Log log )
+ {
+ this.log = log;
+ }
+
+ public Log getLog()
+ {
+ synchronized(this)
+ {
+ if(log == null)
+ {
+ log = new SystemStreamLog();
+ }
+ }
+
+ return log;
+ }
}
diff --git a/maven-plugin/src/main/java/org/apache/maven/plugin/Plugin.java b/maven-plugin/src/main/java/org/apache/maven/plugin/Plugin.java
index ac76ebc210..693ab51a36 100644
--- a/maven-plugin/src/main/java/org/apache/maven/plugin/Plugin.java
+++ b/maven-plugin/src/main/java/org/apache/maven/plugin/Plugin.java
@@ -16,6 +16,8 @@ package org.apache.maven.plugin;
* limitations under the License.
*/
+import org.apache.maven.monitor.logging.Log;
+
/**
* @author Jason van Zyl
* @version $Id$
@@ -24,7 +26,9 @@ public interface Plugin
{
String ROLE = Plugin.class.getName();
- // TODO: make this throw PluginExecutionException instead of generic exception
void execute( PluginExecutionRequest request )
throws PluginExecutionException;
+
+ // TODO: not sure about this here, and may want a getLog on here as well/instead
+ void setLog( Log log );
}
diff --git a/maven-plugin/src/main/java/org/apache/maven/plugin/PluginExecutionRequest.java b/maven-plugin/src/main/java/org/apache/maven/plugin/PluginExecutionRequest.java
index 8db71f44d5..9189af83de 100644
--- a/maven-plugin/src/main/java/org/apache/maven/plugin/PluginExecutionRequest.java
+++ b/maven-plugin/src/main/java/org/apache/maven/plugin/PluginExecutionRequest.java
@@ -16,13 +16,11 @@ package org.apache.maven.plugin;
* limitations under the License.
*/
-import org.apache.maven.monitor.logging.Log;
-import org.apache.maven.monitor.logging.SystemStreamLog;
-
import java.util.HashMap;
import java.util.Map;
/**
+ * @deprecated
* @author Jason van Zyl
* @version $Id$
*/
@@ -32,8 +30,6 @@ public class PluginExecutionRequest
private Map context;
- private Log log;
-
public PluginExecutionRequest( Map parameters )
{
context = new HashMap();
@@ -65,22 +61,4 @@ public class PluginExecutionRequest
{
return context.get( key );
}
-
- public void setLog( Log log )
- {
- this.log = log;
- }
-
- public Log getLog()
- {
- synchronized(this)
- {
- if(log == null)
- {
- log = new SystemStreamLog();
- }
- }
-
- return log;
- }
}
diff --git a/maven-plugin/src/test/java/org/apache/maven/plugin/TestPlugin.java b/maven-plugin/src/test/java/org/apache/maven/plugin/TestPlugin.java
index 8d9576afd9..7aafb0128b 100644
--- a/maven-plugin/src/test/java/org/apache/maven/plugin/TestPlugin.java
+++ b/maven-plugin/src/test/java/org/apache/maven/plugin/TestPlugin.java
@@ -16,6 +16,8 @@ package org.apache.maven.plugin;
* limitations under the License.
*/
+import org.apache.maven.monitor.logging.Log;
+
/**
*
*
@@ -34,6 +36,8 @@ public class TestPlugin
protected String foo;
+ private Log log;
+
public boolean hasExecuted()
{
return executed;
@@ -65,4 +69,9 @@ public class TestPlugin
executed = true;
}
+
+ public void setLog( Log log )
+ {
+ this.log = log;
+ }
}
diff --git a/maven-plugins/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanPlugin.java b/maven-plugins/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanPlugin.java
index 36469507d6..d1b8e39542 100644
--- a/maven-plugins/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanPlugin.java
+++ b/maven-plugins/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanPlugin.java
@@ -16,7 +16,6 @@ package org.apache.maven.plugin.clean;
* limitations under the License.
*/
-import org.apache.maven.monitor.logging.Log;
import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
@@ -48,8 +47,6 @@ public class CleanPlugin
private boolean failOnError;
- private Log log;
-
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
throws Exception
{
@@ -59,15 +56,13 @@ public class CleanPlugin
failOnError = Boolean.valueOf( (String) request.getParameter( "failedOnError" ) ).booleanValue();
- log = request.getLog();
-
if ( outputDirectory != null )
{
File dir = new File( outputDirectory );
if ( dir.exists() && dir.isDirectory() )
{
- log( "Deleting directory " + dir.getAbsolutePath() );
+ getLog().info( "Deleting directory " + dir.getAbsolutePath() );
removeDir( dir );
}
}
@@ -77,7 +72,6 @@ public class CleanPlugin
// clean up state.
failOnError = false;
outputDirectory = null;
- log = null;
}
}
@@ -140,7 +134,7 @@ public class CleanPlugin
}
else
{
- log( message );
+ getLog().info( message );
}
}
}
@@ -156,13 +150,9 @@ public class CleanPlugin
}
else
{
- log( message );
+ getLog().info( message );
}
}
}
- private void log( String message )
- {
- log.info( message );
- }
}
diff --git a/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java b/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
index f296fa09bd..93799405ce 100644
--- a/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
+++ b/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
@@ -88,7 +88,7 @@ public class CompilerMojo
compileSourceRoots = removeEmptyCompileSourceRoots( compileSourceRoots );
if ( compileSourceRoots.isEmpty() )
{
- request.getLog().info( "No sources to compile" );
+ getLog().info( "No sources to compile" );
return;
}
@@ -140,7 +140,7 @@ public class CompilerMojo
message = "Warning! not present in repository!";
}
- request.getLog().debug( "classpathElements[ " + i + " ] = " + classpathElement + ": " + message );
+ getLog().debug( "classpathElements[ " + i + " ] = " + classpathElement + ": " + message );
}
}
diff --git a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
index fb81c97b3c..f40a336c0d 100644
--- a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
+++ b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
@@ -105,7 +105,7 @@ public abstract class AbstractDeployMojo
if(deploymentRepository.getAuthenticationInfo() == null)
{
- request.getLog().warn("Deployment repository {id: \'" + repository.getId() + "\'} has no associated authentication info!");
+ getLog().warn("Deployment repository {id: \'" + repository.getId() + "\'} has no associated authentication info!");
}
// Deploy the POM
diff --git a/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java b/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
index fd4d725960..e9001a794c 100644
--- a/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
+++ b/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
@@ -132,7 +132,7 @@ public class EjbMojo
//
// ----------------------------------------------------------------------
- request.getLog().info( "Building ejb " + jarName );
+ getLog().info( "Building ejb " + jarName );
File jarFile = new File( basedir, jarName + ".jar" );
@@ -152,7 +152,7 @@ public class EjbMojo
if ( generateClient )
{
- request.getLog().info( "Building ejb client " + jarName + "-client" );
+ getLog().info( "Building ejb client " + jarName + "-client" );
File clientJarFile = new File( basedir, jarName + "-client.jar" );
diff --git a/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java b/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java
index b21cbeb889..00a86a4822 100644
--- a/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java
+++ b/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java
@@ -92,7 +92,7 @@ public class PomDeployMojo
if ( deploymentRepository.getAuthenticationInfo() == null )
{
- request.getLog().warn(
+ getLog().warn(
"Deployment repository {id: \'" + repository.getId() + "\'} has no associated authentication info!" );
}
diff --git a/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java b/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
index 90773b37d5..975a5fbe5b 100644
--- a/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
+++ b/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
@@ -174,7 +174,7 @@ public class WarMojo
{
if ( sourceDirectory != webappDirectory )
{
- request.getLog().info( "Copy webapp resources to " + webappDirectory.getAbsolutePath() );
+ getLog().info( "Copy webapp resources to " + webappDirectory.getAbsolutePath() );
if ( warSourceDirectory.exists() )
{
@@ -195,8 +195,7 @@ public class WarMojo
public void buildWebapp( MavenProject project )
throws IOException
{
- request.getLog().info(
- "Assembling webapp " + project.getArtifactId() + " in " + webappDirectory.getAbsolutePath() );
+ getLog().info( "Assembling webapp " + project.getArtifactId() + " in " + webappDirectory.getAbsolutePath() );
File libDirectory = new File( webappDirectory, WEB_INF + "/lib" );
@@ -272,7 +271,7 @@ public class WarMojo
if ( !"exploded".equals( mode ) )
{
//generate war file
- request.getLog().info( "Generating war " + warFile.getAbsolutePath() );
+ getLog().info( "Generating war " + warFile.getAbsolutePath() );
MavenArchiver archiver = new MavenArchiver();