mirror of https://github.com/apache/maven.git
parent
0bffc8a932
commit
59bd396e6e
|
@ -99,10 +99,6 @@ under the License.
|
|||
<groupId>org.eclipse.sisu</groupId>
|
||||
<artifactId>org.eclipse.sisu.plexus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.sonatype.plexus</groupId>
|
||||
<artifactId>plexus-sec-dispatcher</artifactId>
|
||||
|
@ -174,10 +170,6 @@ under the License.
|
|||
<groupId>org.eclipse.sisu</groupId>
|
||||
<artifactId>sisu-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-metadata</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.modello</groupId>
|
||||
<artifactId>modello-maven-plugin</artifactId>
|
||||
|
|
|
@ -146,7 +146,7 @@ public final class CLIReportingUtils
|
|||
|
||||
for ( Throwable cause = e.getCause(); cause != null; cause = cause.getCause() )
|
||||
{
|
||||
logger.error( "Caused by: " + cause.getMessage() );
|
||||
logger.error( "Caused by: {}", cause.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -569,7 +569,7 @@ public class MavenCli
|
|||
|
||||
if ( slf4jLogger.isDebugEnabled() )
|
||||
{
|
||||
slf4jLogger.debug( "Message scheme: " + ( MessageUtils.isColorEnabled() ? "color" : "plain" ) );
|
||||
slf4jLogger.debug( "Message scheme: {}", ( MessageUtils.isColorEnabled() ? "color" : "plain" ) );
|
||||
if ( MessageUtils.isColorEnabled() )
|
||||
{
|
||||
MessageBuilder buff = MessageUtils.buffer();
|
||||
|
@ -767,7 +767,7 @@ public class MavenCli
|
|||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
slf4jLogger.warn( "Failed to read extensions descriptor " + extensionsFile + ": " + e.getMessage() );
|
||||
slf4jLogger.warn( "Failed to read extensions descriptor {}: {}", extensionsFile, e.getMessage() );
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -795,11 +795,11 @@ public class MavenCli
|
|||
|
||||
extRealm.setParentRealm( coreRealm );
|
||||
|
||||
slf4jLogger.debug( "Populating class realm " + extRealm.getId() );
|
||||
slf4jLogger.debug( "Populating class realm {}", extRealm.getId() );
|
||||
|
||||
for ( File file : extClassPath )
|
||||
{
|
||||
slf4jLogger.debug( " Included " + file );
|
||||
slf4jLogger.debug( " Included {}", file );
|
||||
|
||||
extRealm.addURL( file.toURI().toURL() );
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ public class MavenCli
|
|||
{
|
||||
File file = resolveFile( new File( jar ), cliRequest.workingDirectory );
|
||||
|
||||
slf4jLogger.debug( " Included " + file );
|
||||
slf4jLogger.debug( " Included {}", file );
|
||||
|
||||
jars.add( file );
|
||||
}
|
||||
|
@ -983,13 +983,13 @@ public class MavenCli
|
|||
|
||||
if ( !cliRequest.showErrors )
|
||||
{
|
||||
slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the "
|
||||
+ buffer().strong( "-e" ) + " switch." );
|
||||
slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the {} switch.",
|
||||
buffer().strong( "-e" ) );
|
||||
}
|
||||
if ( !slf4jLogger.isDebugEnabled() )
|
||||
{
|
||||
slf4jLogger.error( "Re-run Maven using the " + buffer().strong( "-X" )
|
||||
+ " switch to enable full debug logging." );
|
||||
slf4jLogger.error( "Re-run Maven using the {} switch to enable full debug logging.",
|
||||
buffer().strong( "-X" ) );
|
||||
}
|
||||
|
||||
if ( !references.isEmpty() )
|
||||
|
@ -1000,7 +1000,7 @@ public class MavenCli
|
|||
|
||||
for ( Map.Entry<String, String> entry : references.entrySet() )
|
||||
{
|
||||
slf4jLogger.error( buffer().strong( entry.getValue() ) + " " + entry.getKey() );
|
||||
slf4jLogger.error( "{} {}", buffer().strong( entry.getValue() ), entry.getKey() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1257,11 +1257,10 @@ public class MavenCli
|
|||
|
||||
eventSpyDispatcher.onEvent( toolchainsRequest );
|
||||
|
||||
slf4jLogger.debug(
|
||||
"Reading global toolchains from " + getLocation( toolchainsRequest.getGlobalToolchainsSource(),
|
||||
globalToolchainsFile ) );
|
||||
slf4jLogger.debug( "Reading user toolchains from " + getLocation( toolchainsRequest.getUserToolchainsSource(),
|
||||
userToolchainsFile ) );
|
||||
slf4jLogger.debug( "Reading global toolchains from {}",
|
||||
getLocation( toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile ) );
|
||||
slf4jLogger.debug( "Reading user toolchains from {}",
|
||||
getLocation( toolchainsRequest.getUserToolchainsSource(), userToolchainsFile ) );
|
||||
|
||||
ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest );
|
||||
|
||||
|
@ -1277,7 +1276,7 @@ public class MavenCli
|
|||
|
||||
for ( Problem problem : toolchainsResult.getProblems() )
|
||||
{
|
||||
slf4jLogger.warn( problem.getMessage() + " @ " + problem.getLocation() );
|
||||
slf4jLogger.warn( "{} @ {}", problem.getMessage(), problem.getLocation() );
|
||||
}
|
||||
|
||||
slf4jLogger.warn( "" );
|
||||
|
@ -1311,8 +1310,8 @@ public class MavenCli
|
|||
{
|
||||
if ( commandLine.hasOption( deprecatedOption ) )
|
||||
{
|
||||
slf4jLogger.warn( "Command line option -" + deprecatedOption
|
||||
+ " is deprecated and will be removed in future Maven versions." );
|
||||
slf4jLogger.warn( "Command line option -{} is deprecated and will be removed in future Maven versions.",
|
||||
deprecatedOption );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.bridge.MavenRepositorySystem;
|
||||
|
@ -43,14 +47,14 @@ import org.apache.maven.settings.building.SettingsBuildingRequest;
|
|||
import org.apache.maven.settings.building.SettingsBuildingResult;
|
||||
import org.apache.maven.settings.building.SettingsProblem;
|
||||
import org.apache.maven.settings.crypto.SettingsDecrypter;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* SettingsXmlConfigurationProcessor
|
||||
*/
|
||||
@Component( role = ConfigurationProcessor.class, hint = SettingsXmlConfigurationProcessor.HINT )
|
||||
@Named ( SettingsXmlConfigurationProcessor.HINT )
|
||||
@Singleton
|
||||
public class SettingsXmlConfigurationProcessor
|
||||
implements ConfigurationProcessor
|
||||
{
|
||||
|
@ -65,13 +69,12 @@ public class SettingsXmlConfigurationProcessor
|
|||
public static final File DEFAULT_GLOBAL_SETTINGS_FILE =
|
||||
new File( System.getProperty( "maven.conf" ), "settings.xml" );
|
||||
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
private final Logger logger = LoggerFactory.getLogger( SettingsXmlConfigurationProcessor.class );
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private SettingsBuilder settingsBuilder;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private SettingsDecrypter settingsDecrypter;
|
||||
|
||||
@Override
|
||||
|
@ -132,10 +135,10 @@ public class SettingsXmlConfigurationProcessor
|
|||
request.getEventSpyDispatcher().onEvent( settingsRequest );
|
||||
}
|
||||
|
||||
logger.debug( "Reading global settings from "
|
||||
+ getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
|
||||
logger.debug( "Reading user settings from "
|
||||
+ getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
|
||||
logger.debug( "Reading global settings from {}",
|
||||
getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
|
||||
logger.debug( "Reading user settings from {}",
|
||||
getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
|
||||
|
||||
SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
|
||||
|
||||
|
@ -153,7 +156,7 @@ public class SettingsXmlConfigurationProcessor
|
|||
|
||||
for ( SettingsProblem problem : settingsResult.getProblems() )
|
||||
{
|
||||
logger.warn( problem.getMessage() + " @ " + problem.getLocation() );
|
||||
logger.warn( "{} @ {}", problem.getMessage(), problem.getLocation() );
|
||||
}
|
||||
logger.warn( "" );
|
||||
}
|
||||
|
|
|
@ -115,8 +115,8 @@ public class ExecutionEventLogger
|
|||
for ( MavenProject project : projects )
|
||||
{
|
||||
int len = LINE_LENGTH - project.getName().length() - project.getPackaging().length() - 2;
|
||||
logger.info( project.getName() + chars( ' ', ( len > 0 ) ? len : 1 ) + '[' + project.getPackaging()
|
||||
+ ']' );
|
||||
logger.info( "{}{}[{}]",
|
||||
project.getName(), chars( ' ', ( len > 0 ) ? len : 1 ), project.getPackaging() );
|
||||
}
|
||||
|
||||
totalProjects = projects.size();
|
||||
|
@ -267,9 +267,9 @@ public class ExecutionEventLogger
|
|||
|
||||
String wallClock = session.getRequest().getDegreeOfConcurrency() > 1 ? " (Wall Clock)" : "";
|
||||
|
||||
logger.info( "Total time: " + formatDuration( time ) + wallClock );
|
||||
logger.info( "Total time: {}{}", formatDuration( time ), wallClock );
|
||||
|
||||
logger.info( "Finished at: " + formatTimestamp( finish ) );
|
||||
logger.info( "Finished at: {}", formatTimestamp( finish ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -345,8 +345,8 @@ public class ExecutionEventLogger
|
|||
{
|
||||
if ( logger.isWarnEnabled() )
|
||||
{
|
||||
logger.warn( "Goal " + event.getMojoExecution().getGoal()
|
||||
+ " requires online mode for execution but Maven is currently offline, skipping" );
|
||||
logger.warn( "Goal {} requires online mode for execution but Maven is currently offline, skipping",
|
||||
event.getMojoExecution().getGoal() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class UnsupportedSlf4jBindingConfiguration
|
|||
@Override
|
||||
public void activate()
|
||||
{
|
||||
logger.warn( "The SLF4J binding actually used is not supported by Maven: " + slf4jBinding );
|
||||
logger.warn( "The SLF4J binding actually used is not supported by Maven: {}", slf4jBinding );
|
||||
logger.warn( "Maven supported bindings are:" );
|
||||
|
||||
String ls = System.getProperty( "line.separator" );
|
||||
|
|
|
@ -69,8 +69,8 @@ public class Slf4jMavenTransferListener
|
|||
throws TransferCancelledException
|
||||
{
|
||||
TransferResource resource = event.getResource();
|
||||
out.warn( event.getException().getMessage() + " from " + resource.getRepositoryId() + " for "
|
||||
+ resource.getRepositoryUrl() + resource.getResourceName() );
|
||||
out.warn( "{} from {} for {}{}", event.getException().getMessage(), resource.getRepositoryId(),
|
||||
resource.getRepositoryUrl(), resource.getResourceName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,28 +64,8 @@ Maven Logging
|
|||
|
||||
* Getting Logger Instance
|
||||
|
||||
Plexus Logger and LoggerManager can be injected in Plexus component using Plexus annotations
|
||||
|
||||
+------+
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
@Component( role = MyComponent.class )
|
||||
public class DefaultMyComponent
|
||||
implements MyComponent
|
||||
{
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
|
||||
@Requirement
|
||||
private LoggerManager loggerManager;
|
||||
}
|
||||
+------+
|
||||
|
||||
Starting with Maven 3.1.0, SLF4J Logger can be used directly too, without Plexus. Of course, this will only work when run under
|
||||
Maven 3.1.0, then this technique can be used safely only in Maven core components or in plugins/component not requiring
|
||||
compatibility with previous Maven versions.
|
||||
Starting with Maven 3.1.0, SLF4J Logger can be used directly. This technique can be used safely in Maven core
|
||||
components or in plugins/component not requiring compatibility with previous Maven versions.
|
||||
|
||||
+-----+
|
||||
import org.slf4j.Logger;
|
||||
|
|
Loading…
Reference in New Issue