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