Add `exclude_paths` setting to pmd addon to allow paths to be explicitly excluded.
authorPeter Donald <peter@realityforge.org>
Thu, 3 Mar 2016 01:49:54 +0000 (12:49 +1100)
committerPeter Donald <peter@realityforge.org>
Thu, 3 Mar 2016 01:49:54 +0000 (12:49 +1100)
CHANGELOG
addon/buildr/pmd.rb

index 237f4ee..f2d1b87 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,5 @@
 1.4.24 (Pending)
+* Added:  Add `exclude_paths` setting to pmd addon to allow paths to be explicitly excluded.
 * Fixed:  Update jDepend addon to ensure target directories are invoked prior to attempting
           to analyze directories.
 * Added:  Add jdepend.additional_project_names configuration to jDepend addon to
index 7d08144..4dc4519 100644 (file)
@@ -89,7 +89,7 @@ module Buildr
       attr_writer :rule_set_files
 
       def rule_set_files
-        @rule_set_files ||= (self.rule_set_artifacts.empty? ? ['rulesets/java/basic.xml', 'rulesets/java/imports.xml', 'rulesets/java/unusedcode.xml', 'rulesets/java/finalizers.xml', 'rulesets/java/braces.xml'] : [])
+        @rule_set_files ||= (self.rule_set_artifacts.empty? ? %w(rulesets/java/basic.xml rulesets/java/imports.xml rulesets/java/unusedcode.xml rulesets/java/finalizers.xml rulesets/java/braces.xml) : [])
       end
 
       # Support specification of rule sets that are distributed as part of a maven repository
@@ -125,6 +125,11 @@ module Buildr
         @source_paths ||= [self.project.compile.sources, self.project.test.compile.sources].flatten.compact
       end
 
+      # An array of paths that should be excluded no matter how they are added to pmd
+      def exclude_paths
+        @source_paths ||= []
+      end
+
       # An array of additional projects to scan for main and test sources
       attr_writer :additional_project_names
 
@@ -140,7 +145,7 @@ module Buildr
           paths << [p.compile.sources, p.test.compile.sources].flatten.compact
         end
 
-        paths.flatten.compact
+        paths.flatten.select{|p|!self.exclude_paths.include?(p)}.compact
       end
 
       protected