Repository: buildr Updated Branches: refs/heads/master 7fd0445cb -> 12ccc0f5a
Add checkstyle.additional_project_names configuration to Checkstyle addon to ease merging in the source paths from multiple projects into one Checkstyle task. Project: http://git-wip-us.apache.org/repos/asf/buildr/repo Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/12ccc0f5 Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/12ccc0f5 Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/12ccc0f5 Branch: refs/heads/master Commit: 12ccc0f5aa068b45219c793a6faccc2d7fff4864 Parents: 7fd0445 Author: Peter Donald <[email protected]> Authored: Tue Mar 1 10:52:43 2016 +1100 Committer: Peter Donald <[email protected]> Committed: Tue Mar 1 10:52:43 2016 +1100 ---------------------------------------------------------------------- CHANGELOG | 2 ++ addon/buildr/checkstyle.rb | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/buildr/blob/12ccc0f5/CHANGELOG ---------------------------------------------------------------------- diff --git a/CHANGELOG b/CHANGELOG index 6c9ba3e..76135b1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ 1.4.24 (Pending) +* Added: Add checkstyle.additional_project_names configuration to Checkstyle addon to + ease merging in the source paths from multiple projects into one Checkstyle task. * Added: Add pmd.additional_project_names configuration to PMD addon to ease merging in the source paths from multiple projects into one PMD task. * Fixed: In the PMD addon, check that the source directory exists before adding to http://git-wip-us.apache.org/repos/asf/buildr/blob/12ccc0f5/addon/buildr/checkstyle.rb ---------------------------------------------------------------------- diff --git a/addon/buildr/checkstyle.rb b/addon/buildr/checkstyle.rb index 7135dbd..e9ba2e9 100644 --- a/addon/buildr/checkstyle.rb +++ b/addon/buildr/checkstyle.rb @@ -176,6 +176,35 @@ module Buildr @extra_dependencies ||= [self.project.compile.dependencies, self.project.test.compile.dependencies].flatten end + # An array of additional projects to scan for main and test sources + attr_writer :additional_project_names + + def additional_project_names + @additional_project_names ||= [] + end + + def complete_source_paths + paths = self.source_paths.dup + + self.additional_project_names.each do |project_name| + p = self.project.project(project_name) + paths << [p.compile.sources, p.test.compile.sources].flatten.compact + end + + paths.flatten.compact + end + + def complete_extra_dependencies + deps = self.extra_dependencies.dup + + self.additional_project_names.each do |project_name| + p = self.project.project(project_name) + deps << [p.compile.dependencies, p.test.compile.dependencies].flatten.compact + end + + deps.flatten.compact + end + protected def initialize(project) @@ -202,10 +231,10 @@ module Buildr Buildr::Checkstyle.checkstyle(project.checkstyle.configuration_file, project.checkstyle.format, project.checkstyle.xml_output_file, - project.checkstyle.source_paths.flatten.compact, + project.checkstyle.complete_source_paths, :properties => project.checkstyle.properties, :fail_on_error => project.checkstyle.fail_on_error?, - :dependencies => project.checkstyle.extra_dependencies) + :dependencies => project.checkstyle.complete_extra_dependencies) end if project.checkstyle.html_enabled?
