Class: Buildr::FindBugs::FindBugsTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/buildr-findBugs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ FindBugsTask

:nodoc:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/buildr-findBugs.rb', line 28

def initialize(* args) #:nodoc:
  super
  enhance([:compile]) do
    mkpath File.dirname(report) #otherwise Findbugs can't create the file

    Buildr.ant('findBugs') do |ant|
      antClasspath = FindBugs.requires.join(File::PATH_SEPARATOR)
      excludeFilterFile = File.expand_path(excludeFilter)

      ant.taskdef :name=>'findBugs',
                  :classname=>'edu.umd.cs.findbugs.anttask.FindBugsTask',
                  :classpath => antClasspath
      ant.findBugs :output => "xml", :outputFile => report, :classpath => antClasspath, :pluginList => '', :jvmargs => jvmargs, :excludeFilter => excludeFilterFile do
        ant.sourcePath :path => sourcePath
        ant.auxAnalyzePath :path => auxAnalyzePath
        ant.auxClasspath { |aux| auxClasspath.each { |dep| aux.pathelement :location => dep } } unless auxClasspath.empty?
      end

    end

  end
end

Instance Attribute Details

#auxAnalyzePathObject



59
60
61
# File 'lib/buildr-findBugs.rb', line 59

def auxAnalyzePath
  @auxAnalyzePath || project.compile.target
end

#auxClasspathObject



63
64
65
# File 'lib/buildr-findBugs.rb', line 63

def auxClasspath
  @auxClasspath || project.compile.dependencies
end

#excludeFilterObject



71
72
73
# File 'lib/buildr-findBugs.rb', line 71

def excludeFilter
  @excludeFilter || project.path_to("exclude_filter.xml")
end

#jvmargsObject



67
68
69
# File 'lib/buildr-findBugs.rb', line 67

def jvmargs
  @jvmargs || "-Xmx512m"
end

#projectObject (readonly)

Returns the value of attribute project.



24
25
26
# File 'lib/buildr-findBugs.rb', line 24

def project
  @project
end

#reportObject



51
52
53
# File 'lib/buildr-findBugs.rb', line 51

def report
  @report || project.path_to(:reports, "findbugs.xml")
end

#sourcePathObject



55
56
57
# File 'lib/buildr-findBugs.rb', line 55

def sourcePath
  @sourcePath || project.compile.sources.select { |source| File.directory?(source.to_s) }.join(File::PATH_SEPARATOR)
end

Instance Method Details

#with(options) ⇒ Object

:call-seq:

with(options) => self

Passes options to the task and returns self.



80
81
82
83
84
85
86
87
88
89
# File 'lib/buildr-findBugs.rb', line 80

def with(options)
  options.each do |key, value|
    begin
      send "#{key}=", value
    rescue NoMethodError
      raise ArgumentError, "#{self.class.name} does not support the option #{key}"
    end
  end
  self
end