[MNG-7278] Clean up core logging (#562)

We had all kind of Loggers in Core, some Plexus
injected, some acquired using SLF4J LoggerFactory,
some static, some final, etc.

This PR aligns all those uses to SLF4J finals.

Notices:
* maven-core does NOT use Plexus Logger anymore
* did not touch maven-compat
This commit is contained in:
Tamas Cservenak 2021-10-02 20:33:55 +02:00 committed by GitHub
parent af9c64f80d
commit c3962c1a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 200 additions and 320 deletions

View File

@ -22,7 +22,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.bridge.MavenRepositorySystem;
import org.apache.maven.model.building.ModelBuilder;
import org.apache.maven.model.building.ModelProcessor;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.impl.RemoteRepositoryManager;
@ -37,12 +36,12 @@ public class TestProjectBuilder
{
@Inject
public TestProjectBuilder(
Logger logger, ModelBuilder modelBuilder, ModelProcessor modelProcessor,
ModelBuilder modelBuilder, ModelProcessor modelProcessor,
ProjectBuildingHelper projectBuildingHelper, MavenRepositorySystem repositorySystem,
RepositorySystem repoSystem, RemoteRepositoryManager repositoryManager,
ProjectDependenciesResolver dependencyResolver )
{
super( logger, modelBuilder, modelProcessor, projectBuildingHelper, repositorySystem, repoSystem,
super( modelBuilder, modelProcessor, projectBuildingHelper, repositorySystem, repoSystem,
repositoryManager, dependencyResolver );
}

View File

@ -48,11 +48,12 @@ import org.apache.maven.repository.LocalRepositoryNotAccessibleException;
import org.apache.maven.session.scope.internal.SessionScope;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
@ -82,8 +83,7 @@ import static java.util.stream.Collectors.toSet;
public class DefaultMaven
implements Maven
{
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
protected ProjectBuilder projectBuilder;
@ -109,7 +109,6 @@ public class DefaultMaven
@Inject
public DefaultMaven(
Logger logger,
ProjectBuilder projectBuilder,
LifecycleStarter lifecycleStarter,
PlexusContainer container,
@ -122,7 +121,6 @@ public class DefaultMaven
BuildResumptionDataRepository buildResumptionDataRepository,
SuperPomProvider superPomProvider )
{
this.logger = logger;
this.projectBuilder = projectBuilder;
this.lifecycleStarter = lifecycleStarter;
this.container = container;

View File

@ -45,9 +45,10 @@ import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.artifact.Artifact;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Manages the class realms used by Maven. <strong>Warning:</strong> This is an internal utility class that is only
@ -73,7 +74,7 @@ public class DefaultClassRealmManager
*/
private static final ClassLoader PARENT_CLASSLOADER = ClassWorld.class.getClassLoader();
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final ClassWorld world;
@ -91,10 +92,10 @@ public class DefaultClassRealmManager
private final Set<String> providedArtifacts;
@Inject
public DefaultClassRealmManager( Logger logger, PlexusContainer container,
List<ClassRealmManagerDelegate> delegates, CoreExportsProvider exports )
public DefaultClassRealmManager( PlexusContainer container,
List<ClassRealmManagerDelegate> delegates,
CoreExportsProvider exports )
{
this.logger = logger;
this.world = ( (MutablePlexusContainer) container ).getClassWorld();
this.containerRealm = container.getContainerRealm();
this.delegates = delegates;

View File

@ -28,8 +28,9 @@ import javax.inject.Singleton;
import org.apache.maven.eventspy.EventSpy;
import org.apache.maven.execution.ExecutionListener;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.RepositoryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Dispatches callbacks to all registered eventspies.
@ -39,15 +40,13 @@ import org.eclipse.aether.RepositoryListener;
@Singleton
public class EventSpyDispatcher
{
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final List<EventSpy> eventSpies;
@Inject
public EventSpyDispatcher( Logger logger, List<EventSpy> eventSpies )
public EventSpyDispatcher( List<EventSpy> eventSpies )
{
this.logger = logger;
// make copy to get rid of needless overhead for dynamic lookups
this.eventSpies = new ArrayList<>( eventSpies );
}

View File

@ -36,7 +36,6 @@ import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.eclipse.aether.ConfigurationProperties;
import org.eclipse.aether.DefaultRepositorySystemSession;
@ -57,6 +56,8 @@ import org.eclipse.aether.util.repository.DefaultMirrorSelector;
import org.eclipse.aether.util.repository.DefaultProxySelector;
import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy;
import org.eclipse.sisu.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
@ -77,7 +78,7 @@ import java.util.Properties;
@Named
public class DefaultRepositorySystemSessionFactory
{
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final ArtifactHandlerManager artifactHandlerManager;
@ -95,7 +96,6 @@ public class DefaultRepositorySystemSessionFactory
@Inject
public DefaultRepositorySystemSessionFactory(
Logger logger,
ArtifactHandlerManager artifactHandlerManager,
RepositorySystem repoSystem,
@Nullable @Named( "simple" ) LocalRepositoryManagerFactory simpleLocalRepoMgrFactory,
@ -104,7 +104,6 @@ public class DefaultRepositorySystemSessionFactory
EventSpyDispatcher eventSpyDispatcher,
MavenRepositorySystem mavenRepositorySystem )
{
this.logger = logger;
this.artifactHandlerManager = artifactHandlerManager;
this.repoSystem = repoSystem;
this.simpleLocalRepoMgrFactory = simpleLocalRepoMgrFactory;

View File

@ -21,10 +21,10 @@ package org.apache.maven.internal.aether;
import java.io.FileNotFoundException;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.AbstractRepositoryListener;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.transfer.MetadataNotFoundException;
import org.slf4j.Logger;
/**
* @author Benjamin Bentmann

View File

@ -19,8 +19,6 @@ package org.apache.maven.lifecycle;
* under the License.
*/
import org.codehaus.plexus.logging.Logger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
@ -33,6 +31,9 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @since 3.0
* @author Jason van Zyl
@ -46,26 +47,24 @@ public class DefaultLifecycles
{
public static final String[] STANDARD_LIFECYCLES = { "default", "clean", "site", "wrapper" };
private final Logger logger = LoggerFactory.getLogger( getClass() );
// @Configuration(source="org/apache/maven/lifecycle/lifecycles.xml")
private final Map<String, Lifecycle> lifecyclesMap;
private final Logger logger;
public DefaultLifecycles()
{
this.lifecyclesMap = null;
this.logger = null;
}
@Inject
public DefaultLifecycles( Map<String, Lifecycle> lifecyclesMap, Logger logger )
public DefaultLifecycles( Map<String, Lifecycle> lifecyclesMap )
{
// Must keep the lifecyclesMap as is.
// During initialization it only contains the default lifecycles.
// However, extensions might add custom lifecycles later on.
this.lifecyclesMap = lifecyclesMap;
this.logger = logger;
}
/**

View File

@ -40,9 +40,10 @@ import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
@ -67,20 +68,18 @@ public class DefaultLifecyclePluginAnalyzer
public static final String DEFAULTLIFECYCLEBINDINGS_MODELID = "org.apache.maven:maven-core:"
+ DefaultLifecyclePluginAnalyzer.class.getPackage().getImplementationVersion() + ":default-lifecycle-bindings";
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final PlexusContainer plexusContainer;
private final DefaultLifecycles defaultLifeCycles;
private final Logger logger;
@Inject
public DefaultLifecyclePluginAnalyzer( final PlexusContainer plexusContainer,
final DefaultLifecycles defaultLifeCycles,
final Logger logger )
final DefaultLifecycles defaultLifeCycles )
{
this.plexusContainer = requireNonNull( plexusContainer );
this.defaultLifeCycles = requireNonNull( defaultLifeCycles );
this.logger = requireNonNull( logger );
}
// These methods deal with construction intact Plugin object that look like they come from a standard

View File

@ -25,7 +25,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
@ -34,8 +33,9 @@ import org.apache.maven.lifecycle.internal.builder.BuilderCommon;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>
@ -52,13 +52,7 @@ import org.codehaus.plexus.util.StringUtils;
@Singleton
public class LifecycleDebugLogger
{
private final Logger logger;
@Inject
public LifecycleDebugLogger( Logger logger )
{
this.logger = logger;
}
private final Logger logger = LoggerFactory.getLogger( getClass() );
public void debug( String s )
{

View File

@ -46,12 +46,13 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectDependenciesResolver;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.artifact.ProjectArtifactsCache;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.graph.DependencyFilter;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.util.filter.AndDependencyFilter;
import org.eclipse.aether.util.filter.ScopeDependencyFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>
@ -66,11 +67,10 @@ import org.eclipse.aether.util.filter.ScopeDependencyFilter;
@Named
public class LifecycleDependencyResolver
{
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final ProjectDependenciesResolver dependenciesResolver;
private final Logger logger;
private final ProjectArtifactFactory artifactFactory;
private final EventSpyDispatcher eventSpyDispatcher;
@ -80,13 +80,11 @@ public class LifecycleDependencyResolver
@Inject
public LifecycleDependencyResolver(
ProjectDependenciesResolver dependenciesResolver,
Logger logger,
ProjectArtifactFactory artifactFactory,
EventSpyDispatcher eventSpyDispatcher,
ProjectArtifactsCache projectArtifactsCache )
{
this.dependenciesResolver = dependenciesResolver;
this.logger = logger;
this.artifactFactory = artifactFactory;
this.eventSpyDispatcher = eventSpyDispatcher;
this.projectArtifactsCache = projectArtifactsCache;

View File

@ -35,7 +35,8 @@ import org.apache.maven.lifecycle.NoGoalSpecifiedException;
import org.apache.maven.lifecycle.internal.builder.Builder;
import org.apache.maven.lifecycle.internal.builder.BuilderNotFoundException;
import org.apache.maven.session.scope.internal.SessionScope;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Starts the build life cycle
@ -48,12 +49,12 @@ import org.codehaus.plexus.logging.Logger;
@Singleton
public class LifecycleStarter
{
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final ExecutionEventCatapult eventCatapult;
private final DefaultLifecycles defaultLifeCycles;
private final Logger logger;
private final BuildListCalculator buildListCalculator;
private final LifecycleDebugLogger lifecycleDebugLogger;
@ -68,7 +69,6 @@ public class LifecycleStarter
public LifecycleStarter(
ExecutionEventCatapult eventCatapult,
DefaultLifecycles defaultLifeCycles,
Logger logger,
BuildListCalculator buildListCalculator,
LifecycleDebugLogger lifecycleDebugLogger,
LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator,
@ -77,7 +77,6 @@ public class LifecycleStarter
{
this.eventCatapult = eventCatapult;
this.defaultLifeCycles = defaultLifeCycles;
this.logger = logger;
this.buildListCalculator = buildListCalculator;
this.lifecycleDebugLogger = lifecycleDebugLogger;
this.lifecycleTaskSegmentCalculator = lifecycleTaskSegmentCalculator;

View File

@ -47,8 +47,9 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.plugin.version.PluginVersionResolver;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>
@ -66,8 +67,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
@Singleton
public class MojoDescriptorCreator
{
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final PluginVersionResolver pluginVersionResolver;
private final BuildPluginManager pluginManager;
private final PluginPrefixResolver pluginPrefixResolver;
@ -75,13 +75,11 @@ public class MojoDescriptorCreator
@Inject
public MojoDescriptorCreator(
Logger logger,
PluginVersionResolver pluginVersionResolver,
BuildPluginManager pluginManager,
PluginPrefixResolver pluginPrefixResolver,
LifecyclePluginResolver lifecyclePluginResolver )
{
this.logger = logger;
this.pluginVersionResolver = pluginVersionResolver;
this.pluginManager = pluginManager;
this.pluginPrefixResolver = pluginPrefixResolver;

View File

@ -57,7 +57,8 @@ import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Common code that is shared by the LifecycleModuleBuilder and the LifeCycleWeaveBuilder
@ -78,17 +79,31 @@ public class BuilderCommon
@Inject
public BuilderCommon(
Logger logger,
LifecycleDebugLogger lifecycleDebugLogger,
LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator,
ExecutionEventCatapult eventCatapult )
{
this.logger = logger;
this.logger = LoggerFactory.getLogger( getClass() );
this.lifecycleDebugLogger = lifecycleDebugLogger;
this.lifeCycleExecutionPlanCalculator = lifeCycleExecutionPlanCalculator;
this.eventCatapult = eventCatapult;
}
/**
* Ctor needed for UT.
*/
BuilderCommon(
LifecycleDebugLogger lifecycleDebugLogger,
LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator,
ExecutionEventCatapult eventCatapult,
Logger logger )
{
this.lifecycleDebugLogger = lifecycleDebugLogger;
this.lifeCycleExecutionPlanCalculator = lifeCycleExecutionPlanCalculator;
this.eventCatapult = eventCatapult;
this.logger = logger;
}
public MavenExecutionPlan resolveBuildPlan( MavenSession session, MavenProject project, TaskSegment taskSegment,
Set<Artifact> projectArtifacts )
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,

View File

@ -43,7 +43,8 @@ import org.apache.maven.lifecycle.internal.ReactorContext;
import org.apache.maven.lifecycle.internal.TaskSegment;
import org.apache.maven.lifecycle.internal.builder.Builder;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Builds the full lifecycle in weave-mode (phase by phase as opposed to project-by-project).
@ -64,14 +65,13 @@ import org.codehaus.plexus.logging.Logger;
public class MultiThreadedBuilder
implements Builder
{
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final Logger logger;
private final LifecycleModuleBuilder lifecycleModuleBuilder;
@Inject
public MultiThreadedBuilder( Logger logger, LifecycleModuleBuilder lifecycleModuleBuilder )
public MultiThreadedBuilder( LifecycleModuleBuilder lifecycleModuleBuilder )
{
this.logger = logger;
this.lifecycleModuleBuilder = lifecycleModuleBuilder;
}

View File

@ -22,7 +22,7 @@ package org.apache.maven.plugin;
import java.lang.reflect.Array;
import org.codehaus.plexus.component.configurator.ConfigurationListener;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
/**
* Log at debug level the mojo configuration.
@ -33,7 +33,7 @@ import org.codehaus.plexus.logging.Logger;
public class DebugConfigurationListener
implements ConfigurationListener
{
private Logger logger;
private final Logger logger;
public DebugConfigurationListener( Logger logger )
{

View File

@ -29,7 +29,6 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.path.PathTranslator;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
/**
@ -85,9 +84,9 @@ public class PluginParameterExpressionEvaluator
private Properties properties;
@Deprecated //TODO used by the Enforcer plugin
@Deprecated //TODO used by the Enforcer plugin (cstamas: not anymore, since 3.0.0)
public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution,
PathTranslator pathTranslator, Logger logger, MavenProject project,
PathTranslator pathTranslator, MavenProject project,
Properties properties )
{
this( session, mojoExecution );

View File

@ -25,7 +25,6 @@ import org.apache.maven.classrealm.ClassRealmManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.scope.internal.MojoExecutionScopeModule;
import org.apache.maven.model.Plugin;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.ContextEnabled;
import org.apache.maven.plugin.DebugConfigurationListener;
import org.apache.maven.plugin.ExtensionRealmCache;
@ -73,8 +72,6 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.LoggerManager;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@ -84,6 +81,8 @@ import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.filter.AndDependencyFilter;
import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
@ -132,8 +131,8 @@ public class DefaultMavenPluginManager
*/
public static final String KEY_EXTENSIONS_REALMS = DefaultMavenPluginManager.class.getName() + "/extensionsRealms";
private Logger logger;
private LoggerManager loggerManager;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private PlexusContainer container;
private ClassRealmManager classRealmManager;
private PluginDescriptorCache pluginDescriptorCache;
@ -150,8 +149,6 @@ public class DefaultMavenPluginManager
@Inject
public DefaultMavenPluginManager(
Logger logger,
LoggerManager loggerManager,
PlexusContainer container,
ClassRealmManager classRealmManager,
PluginDescriptorCache pluginDescriptorCache,
@ -163,8 +160,6 @@ public class DefaultMavenPluginManager
PluginArtifactsCache pluginArtifactsCache,
MavenPluginValidator pluginValidator )
{
this.logger = logger;
this.loggerManager = loggerManager;
this.container = container;
this.classRealmManager = classRealmManager;
this.pluginDescriptorCache = pluginDescriptorCache;
@ -576,8 +571,8 @@ public class DefaultMavenPluginManager
if ( mojo instanceof Mojo )
{
Logger mojoLogger = loggerManager.getLoggerForComponent( mojoDescriptor.getImplementation() );
( (Mojo) mojo ).setLog( new DefaultLog( mojoLogger ) );
Logger mojoLogger = LoggerFactory.getLogger( mojoDescriptor.getImplementation() );
( (Mojo) mojo ).setLog( new MojoLogWrapper( mojoLogger ) );
}
Xpp3Dom dom = mojoExecution.getConfiguration();

View File

@ -33,7 +33,6 @@ import org.apache.maven.RepositoryUtils;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.PluginResolutionException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
@ -61,6 +60,8 @@ import org.eclipse.aether.util.filter.ScopeDependencyFilter;
import org.eclipse.aether.util.graph.manager.DependencyManagerUtils;
import org.eclipse.aether.util.graph.selector.AndDependencySelector;
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Assists in resolving the dependencies of a plugin. <strong>Warning:</strong> This is an internal utility class that
@ -75,16 +76,15 @@ import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
public class DefaultPluginDependenciesResolver
implements PluginDependenciesResolver
{
private static final String REPOSITORY_CONTEXT = "plugin";
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final RepositorySystem repoSystem;
@Inject
public DefaultPluginDependenciesResolver( Logger logger, RepositorySystem repoSystem )
public DefaultPluginDependenciesResolver( RepositorySystem repoSystem )
{
this.logger = logger;
this.repoSystem = repoSystem;
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.monitor.logging;
package org.apache.maven.plugin.internal;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -20,23 +20,21 @@ package org.apache.maven.monitor.logging;
*/
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
import static java.util.Objects.requireNonNull;
/**
* @author jdcasey
*
* @deprecated Use SLF4J directly
*/
@Deprecated
public class DefaultLog
public class MojoLogWrapper
implements Log
{
private final Logger logger;
public DefaultLog( Logger logger )
public MojoLogWrapper( Logger logger )
{
this.logger = logger;
this.logger = requireNonNull( logger );
}
public void debug( CharSequence content )
@ -56,79 +54,93 @@ public class DefaultLog
}
}
@Override
public void debug( CharSequence content, Throwable error )
{
logger.debug( toString( content ), error );
}
@Override
public void debug( Throwable error )
{
logger.debug( "", error );
}
@Override
public void info( CharSequence content )
{
logger.info( toString( content ) );
}
@Override
public void info( CharSequence content, Throwable error )
{
logger.info( toString( content ), error );
}
@Override
public void info( Throwable error )
{
logger.info( "", error );
}
@Override
public void warn( CharSequence content )
{
logger.warn( toString( content ) );
}
@Override
public void warn( CharSequence content, Throwable error )
{
logger.warn( toString( content ), error );
}
@Override
public void warn( Throwable error )
{
logger.warn( "", error );
}
@Override
public void error( CharSequence content )
{
logger.error( toString( content ) );
}
@Override
public void error( CharSequence content, Throwable error )
{
logger.error( toString( content ), error );
}
@Override
public void error( Throwable error )
{
logger.error( "", error );
}
@Override
public boolean isDebugEnabled()
{
return logger.isDebugEnabled();
}
@Override
public boolean isInfoEnabled()
{
return logger.isInfoEnabled();
}
@Override
public boolean isWarnEnabled()
{
return logger.isWarnEnabled();
}
@Override
public boolean isErrorEnabled()
{
return logger.isErrorEnabled();
}
}

View File

@ -39,7 +39,6 @@ import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
import org.apache.maven.plugin.prefix.PluginPrefixRequest;
import org.apache.maven.plugin.prefix.PluginPrefixResolver;
import org.apache.maven.plugin.prefix.PluginPrefixResult;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
@ -53,6 +52,8 @@ import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.resolution.MetadataRequest;
import org.eclipse.aether.resolution.MetadataResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Resolves a plugin prefix.
@ -65,22 +66,19 @@ import org.eclipse.aether.resolution.MetadataResult;
public class DefaultPluginPrefixResolver
implements PluginPrefixResolver
{
private static final String REPOSITORY_CONTEXT = "plugin";
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final BuildPluginManager pluginManager;
private final RepositorySystem repositorySystem;
private final MetadataReader metadataReader;
@Inject
public DefaultPluginPrefixResolver(
Logger logger,
BuildPluginManager pluginManager,
RepositorySystem repositorySystem,
MetadataReader metadataReader )
{
this.logger = logger;
this.pluginManager = pluginManager;
this.repositorySystem = repositorySystem;
this.metadataReader = metadataReader;

View File

@ -46,7 +46,6 @@ import org.apache.maven.plugin.version.PluginVersionRequest;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.plugin.version.PluginVersionResolver;
import org.apache.maven.plugin.version.PluginVersionResult;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
@ -64,6 +63,8 @@ import org.eclipse.aether.util.version.GenericVersionScheme;
import org.eclipse.aether.version.InvalidVersionSpecificationException;
import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionScheme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Resolves a version for a plugin.
@ -76,24 +77,21 @@ import org.eclipse.aether.version.VersionScheme;
public class DefaultPluginVersionResolver
implements PluginVersionResolver
{
private static final String REPOSITORY_CONTEXT = "plugin";
private static final Object CACHE_KEY = new Object();
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final RepositorySystem repositorySystem;
private final MetadataReader metadataReader;
private final MavenPluginManager pluginManager;
@Inject
public DefaultPluginVersionResolver(
Logger logger,
RepositorySystem repositorySystem,
MetadataReader metadataReader,
MavenPluginManager pluginManager )
{
this.logger = logger;
this.repositorySystem = repositorySystem;
this.metadataReader = metadataReader;
this.pluginManager = pluginManager;

View File

@ -72,7 +72,6 @@ import org.apache.maven.model.building.TransformerContext;
import org.apache.maven.model.resolution.ModelResolver;
import org.apache.maven.repository.internal.ArtifactDescriptorUtils;
import org.apache.maven.repository.internal.DefaultModelCache;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositorySystem;
@ -84,6 +83,8 @@ import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.WorkspaceRepository;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* DefaultProjectBuilder
@ -93,8 +94,7 @@ import org.eclipse.aether.resolution.ArtifactResult;
public class DefaultProjectBuilder
implements ProjectBuilder
{
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final ModelBuilder modelBuilder;
private final ModelProcessor modelProcessor;
private final ProjectBuildingHelper projectBuildingHelper;
@ -105,7 +105,6 @@ public class DefaultProjectBuilder
@Inject
public DefaultProjectBuilder(
Logger logger,
ModelBuilder modelBuilder,
ModelProcessor modelProcessor,
ProjectBuildingHelper projectBuildingHelper,
@ -114,7 +113,6 @@ public class DefaultProjectBuilder
RemoteRepositoryManager repositoryManager,
ProjectDependenciesResolver dependencyResolver )
{
this.logger = logger;
this.modelBuilder = modelBuilder;
this.modelProcessor = modelProcessor;
this.projectBuildingHelper = projectBuildingHelper;

View File

@ -51,9 +51,10 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.graph.DependencyFilter;
import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Assists the project builder. <strong>Warning:</strong> This is an internal utility class that is only public for
@ -67,9 +68,8 @@ import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
public class DefaultProjectBuildingHelper
implements ProjectBuildingHelper
{
private final Logger logger;
private final PlexusContainer container;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final PlexusContainer container; // TODO not used? Then remove
private final ClassRealmManager classRealmManager;
private final ProjectRealmCache projectRealmCache;
private final RepositorySystem repositorySystem;
@ -77,14 +77,12 @@ public class DefaultProjectBuildingHelper
@Inject
public DefaultProjectBuildingHelper(
Logger logger,
PlexusContainer container,
ClassRealmManager classRealmManager,
ProjectRealmCache projectRealmCache,
RepositorySystem repositorySystem,
MavenPluginManager pluginManager )
{
this.logger = logger;
this.container = container;
this.classRealmManager = classRealmManager;
this.projectRealmCache = projectRealmCache;

View File

@ -34,7 +34,6 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Exclusion;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
@ -52,6 +51,8 @@ import org.eclipse.aether.resolution.DependencyRequest;
import org.eclipse.aether.util.artifact.ArtifactIdUtils;
import org.eclipse.aether.util.artifact.JavaScopes;
import org.eclipse.aether.util.graph.manager.DependencyManagerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Benjamin Bentmann
@ -61,18 +62,15 @@ import org.eclipse.aether.util.graph.manager.DependencyManagerUtils;
public class DefaultProjectDependenciesResolver
implements ProjectDependenciesResolver
{
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final RepositorySystem repoSystem;
private final List<RepositorySessionDecorator> decorators;
@Inject
public DefaultProjectDependenciesResolver(
Logger logger,
RepositorySystem repoSystem,
List<RepositorySessionDecorator> decorators )
{
this.logger = logger;
this.repoSystem = repoSystem;
this.decorators = decorators;
}

View File

@ -27,7 +27,6 @@ import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.project.ProjectBuilder;
import org.codehaus.plexus.logging.Logger;
/**
* This realizes the metadata source via the default hint to provide backward-compat with Maven 2.x whose Plexus version
@ -43,9 +42,9 @@ public class DefaultMetadataSource
{
@Inject
public DefaultMetadataSource(
Logger logger, RepositoryMetadataManager repositoryMetadataManager, ArtifactFactory repositorySystem,
RepositoryMetadataManager repositoryMetadataManager, ArtifactFactory repositorySystem,
ProjectBuilder projectBuilder, MavenMetadataCache cache, LegacySupport legacySupport )
{
super( logger, repositoryMetadataManager, repositorySystem, projectBuilder, cache, legacySupport );
super( repositoryMetadataManager, repositorySystem, projectBuilder, cache, legacySupport );
}
}

View File

@ -78,11 +78,12 @@ import org.apache.maven.properties.internal.SystemProperties;
import org.apache.maven.repository.internal.MavenWorkspaceReader;
import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.transfer.ArtifactNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Jason van Zyl
@ -92,24 +93,21 @@ import org.eclipse.aether.transfer.ArtifactNotFoundException;
public class MavenMetadataSource
implements ArtifactMetadataSource
{
private Logger logger;
private RepositoryMetadataManager repositoryMetadataManager;
private ArtifactFactory repositorySystem;
private ProjectBuilder projectBuilder;
private MavenMetadataCache cache;
private LegacySupport legacySupport;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private final RepositoryMetadataManager repositoryMetadataManager;
private final ArtifactFactory repositorySystem;
private final ProjectBuilder projectBuilder;
private final MavenMetadataCache cache;
private final LegacySupport legacySupport;
@Inject
public MavenMetadataSource(
Logger logger,
RepositoryMetadataManager repositoryMetadataManager,
ArtifactFactory repositorySystem,
ProjectBuilder projectBuilder,
MavenMetadataCache cache,
LegacySupport legacySupport )
{
this.logger = logger;
this.repositoryMetadataManager = repositoryMetadataManager;
this.repositorySystem = repositorySystem;
this.projectBuilder = projectBuilder;

View File

@ -22,18 +22,18 @@ package org.apache.maven.rtinfo.internal;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.util.version.GenericVersionScheme;
import org.eclipse.aether.version.InvalidVersionSpecificationException;
import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionConstraint;
import org.eclipse.aether.version.VersionScheme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
@ -45,17 +45,10 @@ import javax.inject.Singleton;
public class DefaultRuntimeInformation
implements RuntimeInformation
{
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger( getClass() );
private String mavenVersion;
@Inject
public DefaultRuntimeInformation( Logger logger )
{
this.logger = logger;
}
public String getMavenVersion()
{
if ( mavenVersion == null )

View File

@ -26,7 +26,7 @@ import java.util.Properties;
import java.util.Objects;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
/**
* Default abstract toolchain implementation, to be used as base class for any toolchain implementation
@ -38,6 +38,7 @@ import org.codehaus.plexus.logging.Logger;
public abstract class DefaultToolchain // should have been AbstractToolchain...
implements Toolchain, ToolchainPrivate
{
private final Logger logger;
private String type;
@ -47,8 +48,6 @@ public abstract class DefaultToolchain // should have been AbstractToolchain...
private ToolchainModel model;
private Logger logger;
/**
*
* @param model the model, must not be {@code null}
@ -57,7 +56,6 @@ public abstract class DefaultToolchain // should have been AbstractToolchain...
protected DefaultToolchain( ToolchainModel model, Logger logger )
{
this.model = model;
this.logger = logger;
}

View File

@ -33,7 +33,10 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.requireNonNull;
/**
* @author mkleint
@ -43,14 +46,24 @@ import org.codehaus.plexus.logging.Logger;
public class DefaultToolchainManager
implements ToolchainManager
{
final Logger logger;
protected final Logger logger; // TODO this class is extended, needs refactoring
final Map<String, ToolchainFactory> factories;
@Inject
public DefaultToolchainManager( Logger logger, Map<String, ToolchainFactory> factories )
public DefaultToolchainManager( Map<String, ToolchainFactory> factories )
{
this.logger = logger;
this.factories = factories;
this.logger = LoggerFactory.getLogger( DefaultToolchainManager.class );
}
/**
* Ctor needed for UT.
*/
DefaultToolchainManager( Map<String, ToolchainFactory> factories, Logger logger )
{
this.factories = factories;
this.logger = requireNonNull( logger );
}
@Override

View File

@ -29,9 +29,11 @@ import javax.inject.Singleton;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
/**
* TODO: refactor this, component extending component is bad practice.
*
* @author mkleint
* @author Robert Scholte
*/
@ -41,11 +43,18 @@ public class DefaultToolchainManagerPrivate
extends DefaultToolchainManager
implements ToolchainManagerPrivate
{
@Inject
public DefaultToolchainManagerPrivate( Logger logger, Map<String, ToolchainFactory> factories )
public DefaultToolchainManagerPrivate( Map<String, ToolchainFactory> factories )
{
super( logger, factories );
super( factories );
}
/**
* Ctor needed for UT.
*/
DefaultToolchainManagerPrivate( Map<String, ToolchainFactory> factories, Logger logger )
{
super( factories, logger );
}
@Override

View File

@ -21,13 +21,13 @@ package org.apache.maven.toolchain;
import org.apache.maven.toolchain.model.PersistedToolchains;
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.ReaderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.Reader;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
@ -41,14 +41,7 @@ import javax.inject.Singleton;
public class DefaultToolchainsBuilder
implements ToolchainsBuilder
{
private final Logger logger;
@Inject
public DefaultToolchainsBuilder( Logger logger )
{
this.logger = logger;
}
private final Logger logger = LoggerFactory.getLogger( getClass() );
public PersistedToolchains build( File userToolchainsFile )
throws MisconfiguredToolchainException

View File

@ -54,8 +54,8 @@ public class DefaultToolchainsBuilder
implements ToolchainsBuilder
{
private final MavenToolchainMerger toolchainsMerger = new MavenToolchainMerger();
private ToolchainsWriter toolchainsWriter;
private ToolchainsReader toolchainsReader;
private final ToolchainsWriter toolchainsWriter;
private final ToolchainsReader toolchainsReader;
@Inject
public DefaultToolchainsBuilder(

View File

@ -20,7 +20,7 @@ package org.apache.maven.toolchain.java;
*/
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.slf4j.Logger;
/**
* Provides backwards compatibility with Maven 3.2.3 and earlier. Clients that do not require compatibility with Maven

View File

@ -23,7 +23,6 @@ import java.io.File;
import java.util.Map.Entry;
import java.util.Properties;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
@ -33,9 +32,10 @@ import org.apache.maven.toolchain.RequirementMatcherFactory;
import org.apache.maven.toolchain.ToolchainFactory;
import org.apache.maven.toolchain.ToolchainPrivate;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* JDK toolchain factory.
@ -50,14 +50,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
public class JavaToolchainFactory
implements ToolchainFactory
{
private Logger logger;
@Inject
public JavaToolchainFactory( Logger logger )
{
this.logger = logger;
}
private final Logger logger = LoggerFactory.getLogger( getClass() );
public ToolchainPrivate createToolchain( ToolchainModel model )
throws MisconfiguredToolchainException

View File

@ -23,9 +23,9 @@ import java.io.File;
import org.apache.maven.toolchain.DefaultToolchain;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.Os;
import org.slf4j.Logger;
/**
* JDK toolchain implementation.

View File

@ -91,8 +91,7 @@ public class DefaultLifecyclesTest
myLifecycles.addAll( defaultLifeCycles.getLifeCycles() );
DefaultLifecycles dl = new DefaultLifecycles( myLifecycles.stream()
.collect( Collectors.toMap( l -> l.getId(), l -> l ) ),
null );
.collect( Collectors.toMap( l -> l.getId(), l -> l ) ) );
assertThat( dl.getLifeCycles().get( 0 ).getId(), is( "default" ) );
assertThat( dl.getLifeCycles().get( 1 ).getId(), is( "clean" ) );

View File

@ -72,7 +72,7 @@ public class LifecycleExecutionPlanCalculatorTest
public static MojoDescriptorCreator createMojoDescriptorCreator()
{
return new MojoDescriptorCreator( null, new PluginVersionResolverStub(), new BuildPluginManagerStub(),
return new MojoDescriptorCreator( new PluginVersionResolverStub(), new BuildPluginManagerStub(),
new PluginPrefixResolverStub(),
new LifecyclePluginResolver( new PluginVersionResolverStub() ) );
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.lifecycle.internal;
package org.apache.maven.lifecycle.internal.builder;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
@ -19,11 +19,13 @@ import java.util.HashSet;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.lifecycle.internal.builder.BuilderCommon;
import org.apache.maven.lifecycle.internal.ExecutionEventCatapult;
import org.apache.maven.lifecycle.internal.LifecycleDebugLogger;
import org.apache.maven.lifecycle.internal.TaskSegment;
import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub;
import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
import org.codehaus.plexus.logging.Logger;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
@ -46,7 +48,7 @@ public class BuilderCommonTest
final MavenSession session1 = original.clone();
session1.setCurrentProject( ProjectDependencyGraphStub.A );
final BuilderCommon builderCommon = getBuilderCommon();
final BuilderCommon builderCommon = getBuilderCommon( logger );
final MavenExecutionPlan plan =
builderCommon.resolveBuildPlan( session1, ProjectDependencyGraphStub.A, taskSegment1,
new HashSet<>() );
@ -63,7 +65,7 @@ public class BuilderCommonTest
final MavenSession session1 = original.clone();
session1.setCurrentProject( ProjectDependencyGraphStub.A );
getBuilderCommon().resolveBuildPlan( session1, ProjectDependencyGraphStub.A, taskSegment1, new HashSet<>() );
getBuilderCommon( logger ).resolveBuildPlan( session1, ProjectDependencyGraphStub.A, taskSegment1, new HashSet<>() );
verify( logger ).warn("Version not locked for default bindings plugins ["
+ "stub-plugin-initialize, "
@ -95,10 +97,11 @@ public class BuilderCommonTest
{
}
public BuilderCommon getBuilderCommon()
public BuilderCommon getBuilderCommon( Logger logger )
{
final LifecycleDebugLogger debugLogger = new LifecycleDebugLogger( logger );
return new BuilderCommon( logger, debugLogger, new LifecycleExecutionPlanCalculatorStub(), null );
final LifecycleDebugLogger debugLogger = new LifecycleDebugLogger();
return new BuilderCommon( debugLogger, new LifecycleExecutionPlanCalculatorStub(), mock(
ExecutionEventCatapult.class ), logger );
}
}

View File

@ -58,7 +58,7 @@ public class DefaultLifecyclesStub
lifeCycles.put( s, lifecycle );
}
return new DefaultLifecycles( lifeCycles, new LoggerStub() );
return new DefaultLifecycles( lifeCycles );
}
}

View File

@ -1,110 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you 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.
*/
package org.apache.maven.lifecycle.internal.stub;
import org.codehaus.plexus.logging.Logger;
/**
* @author Kristian Rosenvold
*/
public class LoggerStub
implements Logger
{
public void debug( String s )
{
}
public void debug( String s, Throwable throwable )
{
}
public boolean isDebugEnabled()
{
return true;
}
public void info( String s )
{
}
public void info( String s, Throwable throwable )
{
}
public boolean isInfoEnabled()
{
return true;
}
public void warn( String s )
{
}
public void warn( String s, Throwable throwable )
{
}
public boolean isWarnEnabled()
{
return true;
}
public void error( String s )
{
}
public void error( String s, Throwable throwable )
{
}
public boolean isErrorEnabled()
{
return true;
}
public void fatalError( String s )
{
}
public void fatalError( String s, Throwable throwable )
{
}
public boolean isFatalErrorEnabled()
{
return true;
}
public Logger getChildLogger( String s )
{
return null;
}
public int getThreshold()
{
return 0;
}
public void setThreshold( int i )
{
}
public String getName()
{
return "StubLogger";
}
}

View File

@ -33,7 +33,6 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.project.artifact.MavenMetadataCache;
import org.apache.maven.project.artifact.MavenMetadataSource;
import org.codehaus.plexus.logging.Logger;
@SuppressWarnings( "deprecation" )
@Named( "classpath" )
@ -42,8 +41,8 @@ public class TestMetadataSource
extends MavenMetadataSource
{
public TestMetadataSource( Logger logger, RepositoryMetadataManager repositoryMetadataManager, ArtifactFactory repositorySystem, ProjectBuilder projectBuilder, MavenMetadataCache cache, LegacySupport legacySupport) {
super( logger, repositoryMetadataManager, repositorySystem, projectBuilder, cache, legacySupport );
public TestMetadataSource( RepositoryMetadataManager repositoryMetadataManager, ArtifactFactory repositorySystem, ProjectBuilder projectBuilder, MavenMetadataCache cache, LegacySupport legacySupport) {
super( repositoryMetadataManager, repositorySystem, projectBuilder, cache, legacySupport );
}
@Override

View File

@ -35,12 +35,12 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
public class DefaultToolchainManagerPrivateTest
{
@ -66,7 +66,7 @@ public class DefaultToolchainManagerPrivateTest
Map<String, ToolchainFactory> factories = new HashMap<>();
factories.put( "basic", toolchainFactory_basicType );
factories.put( "rare", toolchainFactory_rareType );
toolchainManager = new DefaultToolchainManagerPrivate( logger, factories );
toolchainManager = new DefaultToolchainManagerPrivate( factories, logger );
}
@Test

View File

@ -35,13 +35,13 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.logging.Logger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
public class DefaultToolchainManagerTest
{
@ -66,7 +66,7 @@ public class DefaultToolchainManagerTest
Map<String, ToolchainFactory> factories = new HashMap<>();
factories.put( "basic", toolchainFactory_basicType );
factories.put( "rare", toolchainFactory_rareType );
toolchainManager = new DefaultToolchainManager( logger, factories );
toolchainManager = new DefaultToolchainManager( factories, logger );
}
@Test

View File

@ -22,6 +22,7 @@ package org.apache.maven.toolchain;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import java.io.InputStream;
@ -31,16 +32,14 @@ import org.apache.maven.toolchain.java.DefaultJavaToolChain;
import org.apache.maven.toolchain.model.PersistedToolchains;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
import org.codehaus.plexus.logging.Logger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
public class DefaultToolchainTest
{
@Mock
private Logger logger;
private final Logger logger = mock( Logger.class );
private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader();

View File

@ -40,7 +40,6 @@ import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.graph.DependencyFilter;
@ -48,6 +47,8 @@ import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* BootstrapCoreExtensionManager
@ -55,7 +56,7 @@ import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;
@Named
public class BootstrapCoreExtensionManager
{
private final Logger log;
private final Logger log = LoggerFactory.getLogger( getClass() );
private final DefaultPluginDependenciesResolver pluginDependenciesResolver;
@ -66,11 +67,10 @@ public class BootstrapCoreExtensionManager
private final ClassRealm parentRealm;
@Inject
public BootstrapCoreExtensionManager( Logger log, DefaultPluginDependenciesResolver pluginDependenciesResolver,
public BootstrapCoreExtensionManager( DefaultPluginDependenciesResolver pluginDependenciesResolver,
DefaultRepositorySystemSessionFactory repositorySystemSessionFactory,
PlexusContainer container )
{
this.log = log;
this.pluginDependenciesResolver = pluginDependenciesResolver;
this.repositorySystemSessionFactory = repositorySystemSessionFactory;
this.classWorld = ( (DefaultPlexusContainer) container ).getClassWorld();