module Buildr::Checkstyle

Provides the checkstyle:html and checkstyle:xml tasks. Require explicitly using require "buildr/checkstyle".

Public Class Methods

checkstyle(configuration_file, format, output_file, source_paths, options = {}) click to toggle source
# File addon/buildr/checkstyle.rb, line 31
def checkstyle(configuration_file, format, output_file, source_paths, options = {})
  dependencies = self.dependencies + (options[:dependencies] || [])
  cp = Buildr.artifacts(dependencies).each { |a| a.invoke if a.respond_to?(:invoke) }.map(&:to_s)

  args = []
  if options[:properties_file]
    args << '-p'
    args << options[:properties_file]
  end
  args << '-c'
  args << configuration_file
  args << '-f'
  args << format
  args << '-o'
  args << output_file
  args += source_paths.select { |p| File.exist?(p) }

  begin
    Java::Commands.java 'com.puppycrawl.tools.checkstyle.Main', *(args + [{:classpath => cp, :properties => options[:properties], :java_args => options[:java_args]}])
  rescue Exception => e
    raise e if options[:fail_on_error]
  end
end
dependencies() click to toggle source

The specs for requirements

# File addon/buildr/checkstyle.rb, line 24
def dependencies
  version = '8.40'
  spec = "com.puppycrawl.tools:checkstyle-all:jar:#{version}"
  Buildr.download(Buildr.artifact(spec) => "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-#{version}/checkstyle-#{version}-all.jar")
  [spec]
end