+51
-5
lines changedFilter options
+51
-5
lines changed Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ under the License.
86
86
<javaVersion>1.7</javaVersion>
87
87
<maven.compiler.source>${javaVersion}</maven.compiler.source>
88
88
<maven.compiler.target>${javaVersion}</maven.compiler.target>
89
-
<pmdVersion>5.5.6</pmdVersion>
89
+
<pmdVersion>5.6.0</pmdVersion>
90
90
<sitePluginVersion>3.4</sitePluginVersion>
91
91
<projectInfoReportsPluginVersion>2.8</projectInfoReportsPluginVersion>
92
92
</properties>
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public interface ExcludeFromFile<D>
33
33
* @param excludeFromFailureFile the path to the properties file
34
34
* @throws MojoExecutionException if the properties file couldn't be loaded
35
35
*/
36
-
void loadExcludeFromFailuresData( final String excludeFromFailureFile ) throws MojoExecutionException;
36
+
void loadExcludeFromFailuresData( String excludeFromFailureFile ) throws MojoExecutionException;
37
37
38
38
/**
39
39
* Determines how many exclusions are considered.
@@ -48,6 +48,6 @@ public interface ExcludeFromFile<D>
48
48
* @param errorDetail the violation to check
49
49
* @return <code>true</code> if the violation should be excluded, <code>false</code> otherwise.
50
50
*/
51
-
boolean isExcludedFromFailure( final D errorDetail );
51
+
boolean isExcludedFromFailure( D errorDetail );
52
52
53
53
}
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@
26
26
import java.io.OutputStreamWriter;
27
27
import java.io.PrintStream;
28
28
import java.io.Writer;
29
+
import java.lang.reflect.Constructor;
30
+
import java.lang.reflect.Method;
29
31
import java.util.ArrayList;
30
32
import java.util.Arrays;
31
33
import java.util.Iterator;
@@ -445,8 +447,7 @@ private void removeExcludedViolations( List<RuleViolation> violations )
445
447
private void processFilesWithPMD( PMDConfiguration pmdConfiguration, List<DataSource> dataSources )
446
448
throws MavenReportException
447
449
{
448
-
RuleSetFactory ruleSetFactory = new RuleSetFactory();
449
-
ruleSetFactory.setMinimumPriority( RulePriority.valueOf( this.minimumPriority ) );
450
+
RuleSetFactory ruleSetFactory = createRuleSetFactory();
450
451
RuleContext ruleContext = new RuleContext();
451
452
452
453
try
@@ -471,6 +472,51 @@ private void processFilesWithPMD( PMDConfiguration pmdConfiguration, List<DataSo
471
472
}
472
473
}
473
474
475
+
/**
476
+
* Creates a new ruleset factory for use with PMD using the configured minimum priority.
477
+
* <p>
478
+
* This take the API change from PMD 5.5.x -> 5.6.0 into account,
479
+
* allowing to fall back to PMD 5.5.x.
480
+
* </p>
481
+
* <p>
482
+
* Once we decide to not need to be backwards compatible anymore,
483
+
* we can remove this reflection based solution.
484
+
* </p>
485
+
*
486
+
* @return the created ruleset factory
487
+
*/
488
+
private RuleSetFactory createRuleSetFactory()
489
+
{
490
+
RuleSetFactory ruleSetFactory = new RuleSetFactory();
491
+
try
492
+
{
493
+
// in pmd 5.5.x, the method setMinimumPriority exists
494
+
Method m = RuleSetFactory.class.getMethod( "setMinimumPriority", RulePriority.class );
495
+
m.invoke( ruleSetFactory, RulePriority.valueOf( this.minimumPriority ) );
496
+
}
497
+
catch ( NoSuchMethodException e )
498
+
{
499
+
// in pmd 5.6.x, the method no longer exists, but a special constructor
500
+
Constructor<RuleSetFactory> c;
501
+
try
502
+
{
503
+
c = RuleSetFactory.class.getConstructor( ClassLoader.class, RulePriority.class, Boolean.TYPE,
504
+
Boolean.TYPE );
505
+
ruleSetFactory = c.newInstance( RuleSetFactory.class.getClassLoader(),
506
+
RulePriority.valueOf( this.minimumPriority ), false, true );
507
+
}
508
+
catch ( Exception e1 )
509
+
{
510
+
getLog().warn( "Couldn't set minimumPriority for PMD's ruleset. Using default priority.", e1 );
511
+
}
512
+
}
513
+
catch ( Exception e )
514
+
{
515
+
getLog().warn( "Couldn't set minimumPriority for PMD's ruleset Using default priority.", e );
516
+
}
517
+
return ruleSetFactory;
518
+
}
519
+
474
520
private Report generateReport( Locale locale )
475
521
throws MavenReportException
476
522
{
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4