diff --git a/pom.xml b/pom.xml
index 7eea48632..976763d8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -137,6 +137,11 @@
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ ${pluginPluginVersion}
+
org.apache.httpcomponents
httpclient
@@ -147,6 +152,11 @@
httpcore
${version.httpcomponents.httpcore}
+
+ org.slf4j
+ slf4j-api
+ 1.7.26
+
@@ -237,7 +247,6 @@
org.apache.maven.plugin-tools
maven-plugin-annotations
- ${pluginPluginVersion}
provided
@@ -301,10 +310,8 @@
- log4j
- log4j
- 1.2.17
- runtime
+ org.slf4j
+ slf4j-api
diff --git a/src/license/THIRD-PARTY.properties b/src/license/THIRD-PARTY.properties
index 7113f11f9..4478e968a 100644
--- a/src/license/THIRD-PARTY.properties
+++ b/src/license/THIRD-PARTY.properties
@@ -20,7 +20,7 @@
#Sat Feb 23 19:57:14 CET 2019
classworlds--classworlds--1.1=http\://classworlds.codehaus.org/license.html
commons-beanutils--commons-beanutils--1.7.0=The Apache Software License, Version 2.0
-dom4j--dom4j--1.1=BSD 4-Cluse JDOM
+dom4j--dom4j--1.1=BSD 4-Clause DOM4J
nekohtml--xercesMinimal--1.9.6.2=The Apache Software License, Version 2.0
org.codehaus.plexus--plexus-container-default--1.0-alpha-9-stable-1=The Apache Software License, Version 2.0
org.codehaus.plexus--plexus-i18n--1.0-beta-7=The Apache Software License, Version 2.0
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
index 484738979..b914ac704 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
@@ -29,7 +29,6 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
@@ -59,6 +58,8 @@
import org.codehaus.mojo.license.api.DependenciesToolException;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.transfer.ArtifactNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Abstract mojo for all third-party mojos.
@@ -69,6 +70,7 @@
public abstract class AbstractAddThirdPartyMojo
extends AbstractLicenseMojo
{
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractAddThirdPartyMojo.class );
// ----------------------------------------------------------------------
// Mojo Parameters
@@ -715,11 +717,8 @@ protected void init()
throws Exception
{
- Log log = getLog();
-
- if ( log.isDebugEnabled() )
+ if ( getLog().isDebugEnabled() )
{
-
// always be verbose in debug mode
setVerbose( true );
}
@@ -728,11 +727,8 @@ protected void init()
long buildTimestamp = getBuildTimestamp();
- if ( isVerbose() || getLog().isDebugEnabled() )
- {
- log.debug( "Build start at : " + buildTimestamp );
- log.debug( "third-party file : " + thirdPartyFile.lastModified() );
- }
+ LOG.debug( "Build start at: {}", buildTimestamp );
+ LOG.debug( "third-party file: {}", thirdPartyFile.lastModified() );
doGenerate = force || !thirdPartyFile.exists() || buildTimestamp > thirdPartyFile.lastModified();
@@ -741,10 +737,7 @@ protected void init()
File bundleFile = FileUtil.getFile( outputDirectory, bundleThirdPartyPath );
- if ( isVerbose() || getLog().isDebugEnabled() )
- {
- log.debug( "bundle third-party file : " + bundleFile.lastModified() );
- }
+ LOG.debug( "bundle third-party file: {}", bundleFile.lastModified() );
doGenerateBundle = force || !bundleFile.exists() || buildTimestamp > bundleFile.lastModified();
}
else
@@ -764,18 +757,18 @@ protected void init()
{
throw new MojoExecutionException( "You can't use both licenseMergesFile and licenseMergesUrl" );
}
- getLog().warn( "" );
- getLog().warn( "!!! licenseMergesFile is deprecated, use now licenseMergesUrl !!!" );
- getLog().warn( "" );
- getLog().warn( "licenseMerges will be overridden by licenseMergesFile." );
- getLog().warn( "" );
+ LOG.warn( "" );
+ LOG.warn( "!!! licenseMergesFile is deprecated, use now licenseMergesUrl !!!" );
+ LOG.warn( "" );
+ LOG.warn( "licenseMerges will be overridden by licenseMergesFile." );
+ LOG.warn( "" );
licenseMerges = FileUtils.readLines( new File( licenseMergesFile ), "utf-8" );
}
else if ( licenseMergesUrl != null )
{
- getLog().warn( "" );
- getLog().warn( "licenseMerges will be overridden by licenseMergesUrl." );
- getLog().warn( "" );
+ LOG.warn( "" );
+ LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." );
+ LOG.warn( "" );
if ( UrlRequester.isStringUrl( licenseMergesUrl ) )
{
licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ).split( "[\n\r]+" ) );
@@ -874,7 +867,7 @@ protected ThirdPartyHelper getHelper()
{
helper = new DefaultThirdPartyHelper( getProject(), getEncoding(), isVerbose(), dependenciesTool,
thirdPartyTool, getProject().getRemoteArtifactRepositories(),
- getProject().getRemoteProjectRepositories(), getLog() );
+ getProject().getRemoteProjectRepositories() );
}
return helper;
}
@@ -934,20 +927,19 @@ void checkUnsafeDependencies()
{
if ( CollectionUtils.isNotEmpty( unsafeDependencies ) )
{
- Log log = getLog();
- if ( log.isWarnEnabled() )
+ if ( LOG.isWarnEnabled() )
{
boolean plural = unsafeDependencies.size() > 1;
String message = String.format( "There %s %d %s with no license :",
plural ? "are" : "is",
unsafeDependencies.size(),
plural ? "dependencies" : "dependency" );
- log.warn( message );
+ LOG.warn( message );
for ( MavenProject dep : unsafeDependencies )
{
// no license found for the dependency
- log.warn( " - " + MojoHelper.getArtifactId( dep.getArtifact() ) );
+ LOG.warn( " - {}", MojoHelper.getArtifactId( dep.getArtifact() ) );
}
}
}
@@ -961,7 +953,7 @@ boolean checkForbiddenLicenses()
if ( CollectionUtils.isNotEmpty( blackLicenses ) )
{
Set licenses = licenseMap.keySet();
- getLog().info( "Excluded licenses (blacklist): " + blackLicenses );
+ LOG.info( "Excluded licenses (blacklist): {}", blackLicenses );
for ( String excludeLicense : blackLicenses )
{
@@ -977,20 +969,19 @@ boolean checkForbiddenLicenses()
if ( CollectionUtils.isNotEmpty( whiteLicenses ) )
{
Set dependencyLicenses = licenseMap.keySet();
- getLog().info( "Included licenses (whitelist): " + whiteLicenses );
+ LOG.info( "Included licenses (whitelist): {}", whiteLicenses );
for ( String dependencyLicense : dependencyLicenses )
{
- getLog().debug( "Testing license '" + dependencyLicense + "'" );
+ LOG.debug( "Testing license '{}'", dependencyLicense );
if ( !whiteLicenses.contains( dependencyLicense )
&& CollectionUtils.isNotEmpty( licenseMap.get( dependencyLicense ) ) )
{
- getLog().debug( "Testing dependency license '" + dependencyLicense
- + "' against all other licenses" );
+ LOG.debug( "Testing dependency license '{}' against all other licenses", dependencyLicense );
for ( MavenProject dependency : licenseMap.get( dependencyLicense ) )
{
- getLog().debug( " testing dependency " + dependency );
+ LOG.debug( "- testing dependency {}" + dependency );
boolean forbiddenLicenseUsed = true;
@@ -1012,8 +1003,10 @@ boolean checkForbiddenLicenses()
if ( licenseMap.get( otherLicense ).contains( dependency ) )
{
- getLog().info( "License: '" + dependencyLicense + "' for '" + dependency + "'is OK "
- + "since it is also licensed under '" + otherLicense + "'" );
+ LOG.info( "License: '{}' for '{}' is OK since it is also licensed under '{}'",
+ dependencyLicense,
+ dependency,
+ otherLicense );
// this dependency is licensed under another license from white list
forbiddenLicenseUsed = false;
break;
@@ -1035,8 +1028,7 @@ boolean checkForbiddenLicenses()
if ( !safe )
{
- Log log = getLog();
- log.warn( "There are " + unsafeLicenses.size() + " forbidden licenses used:" );
+ LOG.warn( "There are {} forbidden licenses used:", unsafeLicenses.size() );
for ( String unsafeLicense : unsafeLicenses )
{
@@ -1050,7 +1042,7 @@ boolean checkForbiddenLicenses()
{
sb.append( "\n -" ).append( MojoHelper.getArtifactName( dep ) );
}
- log.warn( sb.toString() );
+ LOG.warn( "{}", sb );
}
}
}
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
index 2041babb2..5939e7306 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java
@@ -64,6 +64,8 @@
import org.codehaus.mojo.license.spdx.SpdxLicenseList;
import org.codehaus.mojo.license.spdx.SpdxLicenseList.Attachments.ContentSanitizer;
import org.codehaus.mojo.license.utils.FileUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Created on 23/05/16.
@@ -74,6 +76,7 @@ public abstract class AbstractDownloadLicensesMojo
extends AbstractLicensesXmlMojo
implements MavenProjectDependenciesConfigurator
{
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractDownloadLicensesMojo.class );
// ----------------------------------------------------------------------
// Mojo Parameters
@@ -702,12 +705,12 @@ public void execute()
if ( isSkip() )
{
- getLog().info( "skip flag is on, will skip goal." );
+ LOG.info( "skip flag is on, will skip goal." );
return;
}
this.errorRemedy = getEffectiveErrorRemedy( this.quiet, this.errorRemedy );
- this.preferredFileNames = PreferredFileNames.build( licensesOutputDirectory, licenseUrlFileNames, getLog() );
+ this.preferredFileNames = PreferredFileNames.build( licensesOutputDirectory, licenseUrlFileNames );
this.cache = new Cache( licenseUrlFileNames != null && !licenseUrlFileNames.isEmpty() );
this.urlReplacements = urlReplacements();
@@ -761,7 +764,7 @@ public void execute()
{
for ( LicensedArtifact artifact : dependencies.values() )
{
- getLog().debug( "Checking licenses for project " + artifact );
+ LOG.debug( "Checking licenses for project " + artifact );
final ProjectLicenseInfo depProject = createDependencyProject( artifact );
matchers.replaceMatches( depProject );
@@ -782,7 +785,7 @@ public void execute()
{
downloadLicenses( licenseDownloader, depProject, true );
}
- getLog().debug( "Finished populating cache" );
+ LOG.debug( "Finished populating cache" );
/*
* Then attempt to download the rest of the URLs using the available cache entries to select local
* file names based on file content sha1
@@ -826,7 +829,7 @@ public void execute()
/* do nothing */
break;
case warn:
- getLog().warn( "There were " + downloadErrorCount + " download errors - check the warnings above" );
+ LOG.warn( "There were {} download errors - check the warnings above", downloadErrorCount );
break;
case xmlOutput:
if ( downloadErrorCount > 0 )
@@ -843,7 +846,7 @@ public void execute()
private UrlReplacements urlReplacements()
{
- UrlReplacements.Builder b = UrlReplacements.builder( getLog() ).useDefaults( useDefaultUrlReplacements );
+ UrlReplacements.Builder b = UrlReplacements.builder().useDefaults( useDefaultUrlReplacements );
if ( licenseUrlReplacements != null )
{
for ( LicenseUrlReplacement r : licenseUrlReplacements )
@@ -863,7 +866,7 @@ private Map contentSanitizers()
final Map defaultSanitizers =
SpdxLicenseList.getLatest().getAttachments().getContentSanitizers();
result.putAll( defaultSanitizers );
- if ( getLog().isDebugEnabled() && !defaultSanitizers.isEmpty() )
+ if ( LOG.isDebugEnabled() && !defaultSanitizers.isEmpty() )
{
final StringBuilder sb = new StringBuilder() //
.append( "Applied " ) //
@@ -888,7 +891,7 @@ private Map contentSanitizers()
}
sb.append( "" );
- getLog().debug( sb.toString() );
+ LOG.debug( sb.toString() );
}
}
if ( licenseContentSanitizers != null )
@@ -922,7 +925,7 @@ private void removeOrphanFiles( List deps )
final File file = new File( licensesOutputDirectory, fileName );
if ( file.exists() )
{
- getLog().info( "Removing orphan license file \"" + file + "\"" );
+ LOG.info( "Removing orphan license file \"{}\"", file );
file.delete();
}
}
@@ -1032,7 +1035,7 @@ private void initDirectories()
{
if ( cleanLicensesOutputDirectory )
{
- getLog().info( "Cleaning licensesOutputDirectory '" + licensesOutputDirectory + "'" );
+ LOG.info( "Cleaning licensesOutputDirectory '{}'", licensesOutputDirectory );
FileUtils.cleanDirectory( licensesOutputDirectory );
}
}
@@ -1191,7 +1194,7 @@ private void downloadLicenses( LicenseDownloader licenseDownloader, ProjectLicen
boolean matchingUrlsOnly )
throws MojoFailureException
{
- getLog().debug( "Downloading license(s) for project " + depProject );
+ LOG.debug( "Downloading license(s) for project {}", depProject );
List licenses = depProject.getLicenses();
@@ -1257,7 +1260,7 @@ else if ( license.getUrl() != null )
if ( !licenseOutputFile.exists() || forceDownload )
{
LicenseDownloadResult result =
- licenseDownloader.downloadLicense( licenseUrl, fileNameEntry, getLog() );
+ licenseDownloader.downloadLicense( licenseUrl, fileNameEntry );
if ( !organizeLicensesByDependencies && result.isSuccess() )
{
/* check if we can re-use an existing file that has the same content */
@@ -1267,9 +1270,12 @@ else if ( license.getUrl() != null )
final File oldFile = result.getFile();
if ( !oldFile.getName().equals( name ) )
{
- getLog().debug( "Found preferred name '" + name
- + "' by sha1 after downloading '" + licenseUrl + "'; renaming from '"
- + oldFile.getName() + "'" );
+ LOG.debug(
+ "Found preferred name '{}' by SHA1 after downloading '{}'; "
+ + "renaming from '{}'",
+ name,
+ licenseUrl,
+ oldFile.getName() );
final File newFile = new File( licensesOutputDirectory, name );
if ( newFile.exists() )
{
@@ -1300,21 +1306,24 @@ else if ( licenseOutputFile.exists() )
}
catch ( URISyntaxException e )
{
- handleError( depProject, "POM for dependency " + depProject.toGavString()
- + " has an invalid license URL: " + licenseUrl );
- getLog().debug( e );
+ String msg = "POM for dependency " + depProject.toGavString()
+ + " has an invalid license URL: " + licenseUrl;
+ handleError( depProject, msg );
+ LOG.debug( msg, e );
}
catch ( FileNotFoundException e )
{
- handleError( depProject, "POM for dependency " + depProject.toGavString()
- + " has a license URL that returns file not found: " + licenseUrl );
- getLog().debug( e );
+ String msg = "POM for dependency " + depProject.toGavString()
+ + " has a license URL that returns file not found: " + licenseUrl;
+ handleError( depProject, msg );
+ LOG.debug( msg, e );
}
catch ( IOException e )
{
- handleError( depProject, "Unable to retrieve license from URL '" + licenseUrl + "' for dependency '"
- + depProject.toGavString() + "': " + e.getMessage() );
- getLog().debug( e );
+ String msg = "Unable to retrieve license from URL '" + licenseUrl + "' for dependency '"
+ + depProject.toGavString() + "': " + e.getMessage();
+ handleError( depProject, msg );
+ LOG.debug( msg, e );
}
}
licenseIndex++;
@@ -1340,7 +1349,7 @@ private void handleError( ProjectLicenseInfo depProject, String msg ) throws Moj
{
if ( depProject.isApproved() )
{
- getLog().debug( "Supressing manually approved license issue: " + msg );
+ LOG.debug( "Supressing manually approved license issue: {}", msg );
}
else
{
@@ -1350,12 +1359,12 @@ private void handleError( ProjectLicenseInfo depProject, String msg ) throws Moj
/* do nothing */
break;
case warn:
- getLog().warn( msg );
+ LOG.warn( msg );
break;
case failFast:
throw new MojoFailureException( msg );
case xmlOutput:
- getLog().error( msg );
+ LOG.error( msg );
depProject.addDownloaderMessage( msg );
break;
default:
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractFileHeaderMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractFileHeaderMojo.java
index 1fdc04042..875b4ff73 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractFileHeaderMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractFileHeaderMojo.java
@@ -38,12 +38,13 @@
import org.codehaus.mojo.license.model.License;
import org.codehaus.mojo.license.utils.FileUtil;
import org.codehaus.mojo.license.utils.MojoHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
-import java.util.Arrays;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
@@ -61,6 +62,7 @@
*/
public abstract class AbstractFileHeaderMojo extends AbstractLicenseNameMojo
{
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractFileHeaderMojo.class );
// ----------------------------------------------------------------------
// Mojo Parameters
@@ -411,12 +413,12 @@ public void init() throws Exception
{
if ( isFailOnMissingHeader() )
{
- getLog().warn( "The failOnMissingHeader has no effect if the property dryRun is not set." );
+ LOG.warn( "The failOnMissingHeader has no effect if the property dryRun is not set." );
}
if ( isFailOnNotUptodateHeader() )
{
- getLog().warn( "The failOnNotUptodateHeader has no effect if the property dryRun is not set." );
+ LOG.warn( "The failOnNotUptodateHeader has no effect if the property dryRun is not set." );
}
}
@@ -432,7 +434,7 @@ public void init() throws Exception
String str = String.format( commentFormat, aTransformer.getName(), aTransformer.getDescription() );
buffer.append( str );
}
- getLog().info( buffer.toString() );
+ LOG.info( "{}", buffer );
}
// set timestamp used for temporary files
this.timestamp = System.nanoTime();
@@ -442,7 +444,7 @@ public void init() throws Exception
roots = DEFAULT_ROOTS;
if ( isVerbose() )
{
- getLog().info( "Will use default roots " + Arrays.toString( roots ) );
+ LOG.info( "Will use default roots {}", ( Object ) roots );
}
}
@@ -451,7 +453,7 @@ public void init() throws Exception
includes = DEFAULT_INCLUDES;
if ( isVerbose() )
{
- getLog().info( "Will use default includes " + Arrays.toString( includes ) );
+ LOG.info( "Will use default includes {}", ( Object ) includes );
}
}
@@ -460,7 +462,7 @@ public void init() throws Exception
excludes = DEFAULT_EXCLUDES;
if ( isVerbose() )
{
- getLog().info( "Will use default excludes" + Arrays.toString( excludes ) );
+ LOG.info( "Will use default excludes {}", ( Object ) excludes );
}
}
@@ -469,18 +471,18 @@ public void init() throws Exception
processStartTag = cleanHeaderConfiguration( processStartTag, FileHeaderTransformer.DEFAULT_PROCESS_START_TAG );
if ( isVerbose() )
{
- getLog().info( "Will use processStartTag: " + processStartTag );
+ LOG.info( "Will use processStartTag: {}", processStartTag );
}
processEndTag = cleanHeaderConfiguration( processEndTag, FileHeaderTransformer.DEFAULT_PROCESS_END_TAG );
if ( isVerbose() )
{
- getLog().info( "Will use processEndTag: " + processEndTag );
+ LOG.info( "Will use processEndTag: {}", processEndTag );
}
sectionDelimiter = cleanHeaderConfiguration( sectionDelimiter,
FileHeaderTransformer.DEFAULT_SECTION_DELIMITER );
if ( isVerbose() )
{
- getLog().info( "Will use sectionDelimiter: " + sectionDelimiter );
+ LOG.info( "Will use sectionDelimiter: {}", sectionDelimiter );
}
// add default extensions from header transformers
@@ -509,7 +511,7 @@ public void init() throws Exception
{
if ( isVerbose() )
{
- getLog().info( "Associate extension " + extension + " to comment style " + commentStyle );
+ LOG.info( "Associate extension '{}' to comment style '{}'", extension, commentStyle );
}
extensionToCommentStyle.put( extension, commentStyle );
}
@@ -524,15 +526,15 @@ public void init() throws Exception
if ( extensionToCommentStyle.containsKey( extension ) )
{
// override existing extension mapping
- getLog().warn( "The extension " + extension + " is already accepted for comment style "
- + extensionToCommentStyle.get( extension ) );
+ LOG.warn( "The extension '{}' is already accepted for comment style '{}'",
+ extension, extensionToCommentStyle.get( extension ) );
}
String commentStyle = entry.getValue();
// check transformer exists
getTransformer( transformers, commentStyle );
if ( isVerbose() )
{
- getLog().info( "Associate extension '" + extension + "' to comment style '" + commentStyle + "'" );
+ LOG.info( "Associate extension '{}' to comment style '{}'", extension, commentStyle );
}
extensionToCommentStyle.put( extension, commentStyle );
}
@@ -547,7 +549,7 @@ public void init() throws Exception
// build the description template
if ( isVerbose() )
{
- getLog().info( "Use description template : " + descriptionTemplate );
+ LOG.info( "Use description template: {}", descriptionTemplate );
}
descriptionTemplate0 = freeMarkerHelper.getTemplate( descriptionTemplate );
}
@@ -581,20 +583,20 @@ public void doAction() throws Exception
int nbFiles = processedFiles.size();
if ( nbFiles == 0 && !ignoreNoFileToScan )
{
- getLog().warn( "No file to scan." );
+ LOG.warn( "No file to scan." );
}
else
{
String delay = MojoHelper.convertTime( System.nanoTime() - t0 );
String message =
String.format( "Scan %s file%s header done in %s.", nbFiles, nbFiles > 1 ? "s" : "", delay );
- getLog().info( message );
+ LOG.info( message );
}
Set states = result.keySet();
if ( states.size() == 1 && states.contains( FileState.uptodate ) )
{
// all files where up to date
- getLog().info( "All files are up-to-date." );
+ LOG.info( "All files are up-to-date." );
}
else
{
@@ -606,7 +608,7 @@ public void doAction() throws Exception
reportType( result, state, buffer );
}
- getLog().info( buffer.toString() );
+ LOG.info( buffer.toString() );
}
}
@@ -672,8 +674,8 @@ private void processCommentStyle( String commentStyle, List filesToTreat )
if ( isVerbose() )
{
- getLog().info( "Process header '" + commentStyle + "'" );
- getLog().info( " - using " + license.getDescription() );
+ LOG.info( "Process header '{}'", commentStyle );
+ LOG.info( " - using {}", license.getDescription() );
}
// use header transformer according to comment style given in header
@@ -696,7 +698,7 @@ private FileHeaderProcessor getFileHeaderProcessor( License license, FileHeaderT
if ( inceptionYear == null )
{
- getLog().warn( "No inceptionYear defined (will use current year)" );
+ LOG.warn( "No inceptionYear defined (will use current year)" );
}
Copyright copyright = getCopyright( getCopyrightOwners() );
@@ -714,7 +716,6 @@ private FileHeaderProcessor getFileHeaderProcessor( License license, FileHeaderT
filter.setUpdateDescription( canUpdateDescription );
filter.setUpdateLicense( canUpdateLicense );
- filter.setLog( getLog() );
// update processor filter
return new FileHeaderProcessor( filter, header, transformer );
}
@@ -731,7 +732,7 @@ private void processFile( FileHeaderProcessor processor, File file ) throws IOEx
if ( processedFiles.contains( file ) )
{
- getLog().info( " - skip already processed file " + file );
+ LOG.info( " - skip already processed file {}", file );
return;
}
@@ -744,7 +745,7 @@ private void processFile( FileHeaderProcessor processor, File file ) throws IOEx
}
catch ( Exception e )
{
- getLog().warn( "skip failed file : " + e.getMessage()
+ LOG.warn( "skip failed file: " + e.getMessage()
+ ( e.getCause() == null ? "" : " Cause : " + e.getCause().getMessage() ), e );
FileState.fail.addFile( file, result );
doFinalize = false;
@@ -780,8 +781,8 @@ private boolean processFile( FileHeaderProcessor processor, File file, File proc
if ( getLog().isDebugEnabled() )
{
- getLog().debug( " - process file " + file );
- getLog().debug( " - will process into file " + processFile );
+ LOG.debug( " - process file {}", file );
+ LOG.debug( " - will process into file {}", processFile );
}
// update the file header description
@@ -793,15 +794,12 @@ private boolean processFile( FileHeaderProcessor processor, File file, File proc
descriptionParameters.put( "organizationName", organizationName );
descriptionParameters.put( "file", file );
- getLog().debug( "Description parameters:" + descriptionParameters );
+ LOG.debug( "Description parameters: {}", descriptionParameters );
String description = freeMarkerHelper.renderTemplate( descriptionTemplate0, descriptionParameters );
processor.updateDescription( description );
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "header description : " + processor.getFileHeaderDescription() );
- }
+ LOG.debug( "header description : " + processor.getFileHeaderDescription() );
String content;
@@ -823,7 +821,7 @@ private boolean processFile( FileHeaderProcessor processor, File file, File proc
//check that file is not marked to be ignored
if ( content.contains( ignoreTag ) )
{
- getLog().info( " - ignore file (detected " + ignoreTag + ") " + file );
+ LOG.info( " - ignore file (detected {}) {}", ignoreTag, file );
FileState.ignore.addFile( file, result );
@@ -856,7 +854,7 @@ private boolean processFile( FileHeaderProcessor processor, File file, File proc
if ( isVerbose() )
{
- getLog().info( " - header was updated for " + file );
+ LOG.info( " - header was updated for {}", file );
}
if ( processor.isModified() )
{
@@ -886,7 +884,7 @@ private boolean processFile( FileHeaderProcessor processor, File file, File proc
// no header at all, add a new header
if ( isVerbose() )
{
- getLog().info( " - adding license header on file " + file );
+ LOG.info( " - adding license header on file {}", file );
}
//FIXME tchemit 20100409 xml files must add header after a xml prolog line
@@ -924,11 +922,7 @@ private void finalizeFile( File file, File processFile ) throws IOException
FileUtil.deleteFile( backupFile );
}
- if ( isVerbose() )
- {
- getLog().debug( " - backup original file " + file );
- }
-
+ LOG.debug( " - backup original file {}", file );
Files.copy( file.toPath(), backupFile.toPath(), StandardCopyOption.COPY_ATTRIBUTES );
}
@@ -949,7 +943,7 @@ private void finalizeFile( File file, File processFile ) throws IOException
}
catch ( IOException e )
{
- getLog().warn( e.getMessage() );
+ LOG.warn( "Error updating {} -> {}", processFile, file, e );
}
}
}
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractLicenseMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractLicenseMojo.java
index 859366cb2..198fc1f43 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractLicenseMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractLicenseMojo.java
@@ -31,9 +31,10 @@
import org.apache.maven.project.MavenProject;
import org.codehaus.mojo.license.utils.MojoHelper;
import org.codehaus.plexus.util.ReaderFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
-import java.util.Arrays;
/**
* Abstract license mojo.
@@ -44,6 +45,7 @@
public abstract class AbstractLicenseMojo
extends AbstractMojo
{
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractLicenseMojo.class );
// ----------------------------------------------------------------------
// Mojo Parameters
@@ -147,7 +149,7 @@ public final void execute()
if ( mustSkip )
{
- getLog().info( "skip flag is on, will skip goal." );
+ LOG.info( "skip flag is on, will skip goal." );
return;
}
@@ -156,7 +158,7 @@ public final void execute()
boolean canContinue = checkPackaging();
if ( !canContinue )
{
- getLog().warn( "The goal is skip due to packaging '" + getProject().getPackaging() + "'" );
+ LOG.warn( "The goal is skip due to packaging '{}'", getProject().getPackaging() );
return;
}
@@ -190,7 +192,7 @@ public final void execute()
{
if ( isVerbose() )
{
- getLog().info( "Goal will not be executed." );
+ LOG.info( "Goal will not be executed." );
}
return;
}
@@ -388,12 +390,12 @@ protected void checkEncoding()
if ( isVerbose() )
{
- getLog().info( "Will check encoding : " + getEncoding() );
+ LOG.info( "Will check encoding: {}", getEncoding() );
}
if ( StringUtils.isEmpty( getEncoding() ) )
{
- getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
- + ", i.e. build is platform dependent!" );
+ LOG.warn( "File encoding has not been set, using platform encoding {}, i.e. build is platform dependent!",
+ ReaderFactory.FILE_ENCODING );
setEncoding( ReaderFactory.FILE_ENCODING );
}
}
@@ -410,7 +412,7 @@ protected void addResourceDir( File dir, String... includes )
boolean added = MojoHelper.addResourceDir( dir, getProject(), includes );
if ( added && isVerbose() )
{
- getLog().info( "add resource " + dir + " with includes " + Arrays.toString( includes ) );
+ LOG.info( "add resource {} with includes {}", dir, ( Object ) includes );
}
}
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java
index 32a1cc441..454dcc576 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java
@@ -31,6 +31,8 @@
import org.codehaus.mojo.license.model.LicenseStore;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -41,6 +43,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
/**
@@ -53,6 +56,7 @@
public abstract class AbstractLicenseNameMojo
extends AbstractLicenseMojo
{
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractLicenseNameMojo.class );
// ----------------------------------------------------------------------
// Constants
@@ -182,7 +186,7 @@ protected void init()
{
// init licenses store
- licenseStore = LicenseStore.createLicenseStore( getLog(), licenseResolver );
+ licenseStore = LicenseStore.createLicenseStore( licenseResolver );
// check licenseName exists
license = getLicense( licenseName, true );
@@ -296,10 +300,7 @@ void getFilesToTreatForRoots( String[] includes, String[] excludes, List
continue;
}
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "discovering source files in " + src );
- }
+ LOG.debug( "discovering source files in {}", src );
ds.setBasedir( f );
// scan
@@ -460,14 +461,14 @@ Map> obtainFilesToProcessByCommentStyle( Map
}
if ( f.exists() )
{
- getLog().info( "Will search files to update from root " + f );
+ LOG.info( "Will search files to update from root {}", f );
rootsList.add( f.getAbsolutePath() );
}
else
{
if ( isVerbose() )
{
- getLog().info( "Skip not found root " + f );
+ LOG.info( "Skip not found root {}", f );
}
}
}
@@ -525,7 +526,14 @@ private Set getFiles( EnumMap> result, FileState stat
// Private Methods
// ----------------------------------------------------------------------
- private void addPropertiesToContext( Map properties, String prefix, Map context )
+ private void addPropertiesToContext( Properties properties, String prefix, Map context )
+ {
+ @SuppressWarnings( { "rawtypes", "unchecked" } )
+ Map cast = (Map) properties;
+ addPropertiesToContext( cast, prefix, context );
+ }
+
+ private void addPropertiesToContext( Map properties, String prefix, Map context )
{
if ( properties != null )
{
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractLicensesXmlMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractLicensesXmlMojo.java
index e80af56d8..fe0780ea6 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractLicensesXmlMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractLicensesXmlMojo.java
@@ -40,6 +40,8 @@
import org.codehaus.mojo.license.download.LicenseSummaryWriter;
import org.codehaus.mojo.license.download.LicensedArtifactResolver;
import org.codehaus.mojo.license.download.ProjectLicenseInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A common parent for {@link LicensesXmlInsertVersionsMojo} and {@link AbstractDownloadLicensesMojo}.
@@ -50,6 +52,7 @@
public abstract class AbstractLicensesXmlMojo
extends AbstractMojo
{
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractLicensesXmlMojo.class );
/**
* The output file containing a mapping between each dependency and it's license information.
@@ -129,7 +132,7 @@ private void initEncoding()
if ( licensesOutputFileEncoding == null )
{
licensesOutputFileEncoding = System.getProperty( "file.encoding" );
- getLog().warn( "Using the default system encoding for reading or writing licenses.xml file."
+ LOG.warn( "Using the default system encoding for reading or writing licenses.xml file."
+ " This makes your build platform dependent. You should set either"
+ " project.build.sourceEncoding or licensesOutputFileEncoding" );
}
diff --git a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java
index 6e2251c08..dccdbcd0a 100644
--- a/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AbstractThirdPartyReportMojo.java
@@ -49,6 +49,8 @@
import org.codehaus.mojo.license.utils.MojoHelper;
import org.codehaus.mojo.license.utils.UrlRequester;
import org.codehaus.plexus.i18n.I18N;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -73,6 +75,7 @@
public abstract class AbstractThirdPartyReportMojo extends AbstractMavenReport
implements MavenProjectDependenciesConfigurator
{
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractThirdPartyReportMojo.class );
// ----------------------------------------------------------------------
// Mojo Parameters
@@ -390,9 +393,9 @@ protected void init()
{
if ( licenseMergesUrl != null )
{
- getLog().warn( "" );
- getLog().warn( "licenseMerges will be overridden by licenseMergesUrl." );
- getLog().warn( "" );
+ LOG.warn( "" );
+ LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." );
+ LOG.warn( "" );
if ( UrlRequester.isStringUrl( licenseMergesUrl ) )
{
licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ).split( "[\n\r]+" ) );
@@ -564,7 +567,7 @@ Collection createThirdPartyDetails( MavenProject project, boo
ThirdPartyHelper thirdPartyHelper =
new DefaultThirdPartyHelper( project, encoding, verbose,
dependenciesTool, thirdPartyTool,
- project.getRemoteArtifactRepositories(), project.getRemoteProjectRepositories(), getLog() );
+ project.getRemoteArtifactRepositories(), project.getRemoteProjectRepositories() );
// load dependencies of the project
SortedMap projectDependencies = thirdPartyHelper.loadDependencies( this,
loadedDependencies );
diff --git a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java
index 388f83d75..1e5bec0d5 100644
--- a/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java
+++ b/src/main/java/org/codehaus/mojo/license/AddThirdPartyMojo.java
@@ -34,7 +34,6 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@@ -49,6 +48,8 @@
import org.codehaus.mojo.license.model.LicenseMap;
import org.codehaus.mojo.license.utils.FileUtil;
import org.codehaus.mojo.license.utils.SortedProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
// CHECKSTYLE_OFF: LineLength
/**
@@ -69,6 +70,7 @@
defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
public class AddThirdPartyMojo extends AbstractAddThirdPartyMojo implements MavenProjectDependenciesConfigurator
{
+ private static final Logger LOG = LoggerFactory.getLogger( AddThirdPartyMojo.class );
// ----------------------------------------------------------------------
// Mojo Parameters
@@ -158,7 +160,7 @@ protected boolean checkSkip()
if ( !doGenerate && !doGenerateBundle && !doGenerateMissing )
{
- getLog().info( "All files are up to date, skip goal execution." );
+ LOG.info( "All files are up to date, skip goal execution." );
return false;
}
return true;
@@ -196,7 +198,7 @@ protected void doAction()
{
// there is no missing dependencies, but still a missing file, delete it
- getLog().info( "There is no dependency to put in missing file, delete it at " + missingFile );
+ LOG.info( "There is no dependency to put in missing file, delete it at {}", missingFile );
FileUtil.deleteFile( missingFile );
}
@@ -204,7 +206,7 @@ protected void doAction()
{
// can deploy missing file
- getLog().info( "Will attach third party file from " + missingFile );
+ LOG.info( "Will attach third party file from {}", missingFile );
getHelper().attachThirdPartyDescriptor( missingFile );
}
@@ -265,7 +267,7 @@ protected SortedProperties createUnsafeMapping()
resolveDependencyArtifacts().getAllDependencies() );
if ( isVerbose() )
{
- getLog().info( "found " + unsafeMappings.size() + " unsafe mappings" );
+ LOG.info( "found {} unsafe mappings", unsafeMappings.size() );
}
// compute if missing file should be (re)-generate
@@ -274,22 +276,22 @@ protected SortedProperties createUnsafeMapping()
if ( doGenerateMissing && isVerbose() )
{
StringBuilder sb = new StringBuilder();
- sb.append( "Will use from missing file " );
+ sb.append( "Will use " );
sb.append( unsafeMappings.size() );
- sb.append( " dependencies :" );
+ sb.append( " dependencies from missingFile:" );
for ( Map.Entry