52
52
import org .apache .maven .artifact .DependencyResolutionRequiredException ;
53
53
import org .apache .maven .model .Resource ;
54
54
import org .apache .maven .project .MavenProject ;
55
- import org .codehaus .plexus .logging .AbstractLogEnabled ;
56
55
import org .codehaus .plexus .resource .ResourceManager ;
57
56
import org .codehaus .plexus .resource .loader .FileResourceCreationException ;
58
57
import org .codehaus .plexus .resource .loader .FileResourceLoader ;
59
58
import org .codehaus .plexus .resource .loader .ResourceNotFoundException ;
60
59
import org .codehaus .plexus .util .FileUtils ;
61
60
import org .eclipse .sisu .Typed ;
61
+ import org .slf4j .Logger ;
62
+ import org .slf4j .LoggerFactory ;
62
63
63
64
/**
64
65
* @author Olivier Lamy
65
66
* @since 2.5
66
67
*/
67
68
@ Named
68
69
@ Typed (CheckstyleExecutor .class )
69
- public class DefaultCheckstyleExecutor extends AbstractLogEnabled implements CheckstyleExecutor {
70
+ public class DefaultCheckstyleExecutor implements CheckstyleExecutor {
71
+
72
+ private static final Logger logger = LoggerFactory .getLogger (DefaultCheckstyleExecutor .class );
73
+
70
74
private final ResourceManager locator ;
71
75
72
76
private final ResourceManager licenseLocator ;
@@ -81,8 +85,8 @@ public DefaultCheckstyleExecutor(
81
85
@ Override
82
86
public CheckstyleResults executeCheckstyle (CheckstyleExecutorRequest request )
83
87
throws CheckstyleExecutorException , CheckstyleException {
84
- if (getLogger () .isDebugEnabled ()) {
85
- getLogger () .debug ("executeCheckstyle start headerLocation : " + request .getHeaderLocation ());
88
+ if (logger .isDebugEnabled ()) {
89
+ logger .debug ("executeCheckstyle start headerLocation : " + request .getHeaderLocation ());
86
90
}
87
91
88
92
MavenProject project = request .getProject ();
@@ -220,7 +224,7 @@ public CheckstyleResults executeCheckstyle(CheckstyleExecutorRequest request)
220
224
// work regardless of config), but should record this information
221
225
throw new CheckstyleExecutorException (message .toString ());
222
226
} else {
223
- getLogger () .info (message .toString ());
227
+ logger .info (message .toString ());
224
228
}
225
229
}
226
230
@@ -255,8 +259,7 @@ protected void addSourceDirectory(
255
259
File resourcesDirectory = new File (resource .getDirectory ());
256
260
if (resourcesDirectory .exists () && resourcesDirectory .isDirectory ()) {
257
261
sinkListener .addSourceDirectory (resourcesDirectory );
258
- getLogger ()
259
- .debug ("Added '" + resourcesDirectory .getAbsolutePath () + "' as a source directory." );
262
+ logger .debug ("Added '" + resourcesDirectory .getAbsolutePath () + "' as a source directory." );
260
263
}
261
264
}
262
265
}
@@ -286,9 +289,8 @@ public Configuration getConfiguration(CheckstyleExecutorRequest request) throws
286
289
: System .getProperty ("file.encoding" , "UTF-8" );
287
290
288
291
if (StringUtils .isEmpty (request .getEncoding ())) {
289
- getLogger ()
290
- .warn ("File encoding has not been set, using platform encoding " + effectiveEncoding
291
- + ", i.e. build is platform dependent!" );
292
+ logger .warn ("File encoding has not been set, using platform encoding " + effectiveEncoding
293
+ + ", i.e. build is platform dependent!" );
292
294
}
293
295
294
296
if ("Checker" .equals (config .getName ())
@@ -298,7 +300,7 @@ public Configuration getConfiguration(CheckstyleExecutorRequest request) throws
298
300
addAttributeIfNotExists ((DefaultConfiguration ) config , "charset" , effectiveEncoding );
299
301
addAttributeIfNotExists ((DefaultConfiguration ) config , "cacheFile" , request .getCacheFile ());
300
302
} else {
301
- getLogger () .warn ("Failed to configure file encoding on module " + config );
303
+ logger .warn ("Failed to configure file encoding on module " + config );
302
304
}
303
305
}
304
306
return config ;
@@ -368,8 +370,8 @@ private Properties getOverridingProperties(CheckstyleExecutorRequest request) th
368
370
Properties p = new Properties ();
369
371
try {
370
372
if (request .getPropertiesLocation () != null ) {
371
- if (getLogger () .isDebugEnabled ()) {
372
- getLogger () .debug ("request.getPropertiesLocation() " + request .getPropertiesLocation ());
373
+ if (logger .isDebugEnabled ()) {
374
+ logger .debug ("request.getPropertiesLocation() " + request .getPropertiesLocation ());
373
375
}
374
376
375
377
File propertiesFile =
@@ -399,8 +401,8 @@ private Properties getOverridingProperties(CheckstyleExecutorRequest request) th
399
401
headerLocation = "config/maven-header.txt" ;
400
402
}
401
403
}
402
- if (getLogger () .isDebugEnabled ()) {
403
- getLogger () .debug ("headerLocation " + headerLocation );
404
+ if (logger .isDebugEnabled ()) {
405
+ logger .debug ("headerLocation " + headerLocation );
404
406
}
405
407
406
408
if (headerLocation != null && !headerLocation .isEmpty ()) {
@@ -411,8 +413,8 @@ private Properties getOverridingProperties(CheckstyleExecutorRequest request) th
411
413
p .setProperty ("checkstyle.header.file" , headerFile .getAbsolutePath ());
412
414
}
413
415
} catch (FileResourceCreationException | ResourceNotFoundException e ) {
414
- getLogger () .debug ("Unable to process header location: " + headerLocation );
415
- getLogger () .debug ("Checkstyle will throw exception if ${checkstyle.header.file} is used" );
416
+ logger .debug ("Unable to process header location: " + headerLocation );
417
+ logger .debug ("Checkstyle will throw exception if ${checkstyle.header.file} is used" );
416
418
}
417
419
}
418
420
@@ -486,7 +488,7 @@ private List<File> getFilesToProcess(CheckstyleExecutorRequest request) throws I
486
488
request .getTestSourceDirectories ());
487
489
}
488
490
489
- getLogger () .debug ("Added " + files .size () + " files to process." );
491
+ logger .debug ("Added " + files .size () + " files to process." );
490
492
491
493
return new ArrayList <>(files );
492
494
}
@@ -505,9 +507,8 @@ private void addFilesToProcess(
505
507
final List <File > sourceFiles =
506
508
FileUtils .getFiles (sourceDirectory , request .getIncludes (), request .getExcludes ());
507
509
files .addAll (sourceFiles );
508
- getLogger ()
509
- .debug ("Added " + sourceFiles .size () + " source files found in '"
510
- + sourceDirectory .getAbsolutePath () + "'." );
510
+ logger .debug ("Added " + sourceFiles .size () + " source files found in '"
511
+ + sourceDirectory .getAbsolutePath () + "'." );
511
512
}
512
513
}
513
514
}
@@ -519,23 +520,22 @@ private void addFilesToProcess(
519
520
FileUtils .getFiles (testSourceDirectory , request .getIncludes (), request .getExcludes ());
520
521
521
522
files .addAll (testSourceFiles );
522
- getLogger ()
523
- .debug ("Added " + testSourceFiles .size () + " test source files found in '"
524
- + testSourceDirectory .getAbsolutePath () + "'." );
523
+ logger .debug ("Added " + testSourceFiles .size () + " test source files found in '"
524
+ + testSourceDirectory .getAbsolutePath () + "'." );
525
525
}
526
526
}
527
527
}
528
528
529
529
if (resources != null && request .isIncludeResources ()) {
530
530
addResourceFilesToProcess (request , resources , files );
531
531
} else {
532
- getLogger () .debug ("No resources found in this project." );
532
+ logger .debug ("No resources found in this project." );
533
533
}
534
534
535
535
if (testResources != null && request .isIncludeTestResources ()) {
536
536
addResourceFilesToProcess (request , testResources , files );
537
537
} else {
538
- getLogger () .debug ("No test resources found in this project." );
538
+ logger .debug ("No test resources found in this project." );
539
539
}
540
540
}
541
541
@@ -569,13 +569,11 @@ private void addResourceFilesToProcess(
569
569
570
570
List <File > resourceFiles = FileUtils .getFiles (resourcesDirectory , includes , excludes );
571
571
files .addAll (resourceFiles );
572
- getLogger ()
573
- .debug ("Added " + resourceFiles .size () + " resource files found in '"
574
- + resourcesDirectory .getAbsolutePath () + "'." );
572
+ logger .debug ("Added " + resourceFiles .size () + " resource files found in '"
573
+ + resourcesDirectory .getAbsolutePath () + "'." );
575
574
} else {
576
- getLogger ()
577
- .debug ("The resources directory '" + resourcesDirectory .getAbsolutePath ()
578
- + "' does not exist or is not a directory." );
575
+ logger .debug ("The resources directory '" + resourcesDirectory .getAbsolutePath ()
576
+ + "' does not exist or is not a directory." );
579
577
}
580
578
}
581
579
}
@@ -613,8 +611,8 @@ private String getSuppressionsFilePath(final CheckstyleExecutorRequest request)
613
611
614
612
private String getConfigFile (CheckstyleExecutorRequest request ) throws CheckstyleExecutorException {
615
613
try {
616
- if (getLogger () .isDebugEnabled ()) {
617
- getLogger () .debug ("request.getConfigLocation() " + request .getConfigLocation ());
614
+ if (logger .isDebugEnabled ()) {
615
+ logger .debug ("request.getConfigLocation() " + request .getConfigLocation ());
618
616
}
619
617
620
618
File configFile = locator .getResourceAsFile (request .getConfigLocation (), "checkstyle-checker.xml" );
0 commit comments