move log to AbstractPlugin, out of request. Request now contains only parameters (will move to fields) and marmalade context (can move to marmalade mojo wrapper)

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-21 00:07:39 +00:00
parent a593e7df88
commit 8e9ec9c892
13 changed files with 90 additions and 51 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -16,6 +16,8 @@ package org.apache.maven.plugin;
* limitations under the License.
*/
import org.apache.maven.monitor.logging.Log;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @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 );
}

View File

@ -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 <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @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;
}
}

View File

@ -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;
}
}

View File

@ -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 );
}
}

View File

@ -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 );
}
}

View File

@ -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

View File

@ -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" );

View File

@ -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!" );
}

View File

@ -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();