module Buildr::Findbugs

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

Public Class Methods

dependencies() click to toggle source

The specs for requirements

# File addon/buildr/findbugs.rb, line 24
def dependencies
  %w(
    com.google.code.findbugs:findbugs:jar:3.0.1
    com.google.code.findbugs:jFormatString:jar:3.0.0
    com.google.code.findbugs:bcel-findbugs:jar:6.0
    com.google.code.findbugs:annotations:jar:3.0.1
    org.ow2.asm:asm-debug-all:jar:5.0.2
    commons-lang:commons-lang:jar:2.6
    dom4j:dom4j:jar:1.6.1
    jaxen:jaxen:jar:1.1.6
  )
end
findbugs(output_file, source_paths, analyze_paths, options = {}) click to toggle source
# File addon/buildr/findbugs.rb, line 37
def findbugs(output_file, source_paths, analyze_paths, options = {})
  dependencies = (options[:dependencies] || []) + self.dependencies
  cp = Buildr.artifacts(dependencies).each { |a| a.invoke() if a.respond_to?(:invoke) }.map(&:to_s).join(File::PATH_SEPARATOR)

  args = {
    :output => options[:output] || 'xml',
    :outputFile => output_file,
    :effort => 'max',
    :pluginList => '',
    :classpath => cp,
    :reportLevel => options[:report_level] || 'medium',
    :timeout => '90000000',
    :debug => 'false'
  }
  args[:failOnError] = true if options[:fail_on_error]
  args[:excludeFilter] = options[:exclude_filter] if options[:exclude_filter]
  args[:jvmargs] = options[:java_args] if options[:java_args]

  mkdir_p File.dirname(output_file)

  Buildr.ant('findBugs') do |ant|
    ant.taskdef :name => 'findBugs',
                :classname => 'edu.umd.cs.findbugs.anttask.FindBugsTask',
                :classpath => cp
    ant.findBugs args do
      source_paths.each do |source_path|
        ant.sourcePath :path => source_path.to_s
      end
      Buildr.artifacts(analyze_paths).each(&:invoke).each do |analyze_path|
        ant.auxAnalyzePath :path => analyze_path.to_s
      end
      if options[:properties]
        options[:properties].each_pair do |k, v|
          ant.systemProperty :name => k, :value => v
        end
      end
      if options[:extra_dependencies]
        ant.auxClasspath do |aux|
          Buildr.artifacts(options[:extra_dependencies]).each { |a| a.invoke() if a.respond_to?(:invoke) }.each do |dep|
            aux.pathelement :location => dep.to_s
          end
        end
      end
    end
  end
end