buildr 1.4.6 → 1.4.7.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/CHANGELOG +59 -0
  2. data/Rakefile +1 -1
  3. data/addon/buildr/antlr.rb +0 -4
  4. data/addon/buildr/bnd.rb +3 -1
  5. data/addon/buildr/checkstyle.rake +201 -0
  6. data/addon/buildr/cobertura.rb +0 -1
  7. data/addon/buildr/drb.rb +0 -2
  8. data/addon/buildr/emma.rb +0 -1
  9. data/addon/buildr/findbugs.rake +227 -0
  10. data/addon/buildr/hibernate.rb +0 -4
  11. data/addon/buildr/javacc.rb +0 -4
  12. data/addon/buildr/javancss.rake +155 -0
  13. data/addon/buildr/jdepend.rb +138 -24
  14. data/addon/buildr/jetty.rb +0 -5
  15. data/addon/buildr/jibx.rb +85 -86
  16. data/addon/buildr/openjpa.rb +0 -4
  17. data/addon/buildr/pmd.rake +164 -0
  18. data/addon/buildr/protobuf.rb +0 -1
  19. data/addon/buildr/xmlbeans.rb +0 -5
  20. data/buildr.gemspec +19 -8
  21. data/doc/_layouts/default.html +1 -0
  22. data/doc/contributing.textile +11 -2
  23. data/doc/download.textile +17 -5
  24. data/doc/index.textile +21 -46
  25. data/doc/installing.textile +18 -8
  26. data/doc/languages.textile +0 -38
  27. data/doc/more_stuff.textile +168 -12
  28. data/doc/packaging.textile +10 -0
  29. data/doc/settings_profiles.textile +2 -2
  30. data/lib/buildr.rb +67 -4
  31. data/lib/buildr/clojure.rb +0 -2
  32. data/lib/buildr/core/application.rb +23 -32
  33. data/lib/buildr/core/build.rb +0 -7
  34. data/lib/buildr/core/cc.rb +0 -5
  35. data/lib/buildr/core/checks.rb +0 -4
  36. data/lib/buildr/core/common.rb +0 -5
  37. data/lib/buildr/core/compile.rb +5 -10
  38. data/lib/buildr/core/environment.rb +0 -1
  39. data/lib/buildr/core/filter.rb +0 -5
  40. data/lib/buildr/core/generate.rb +0 -4
  41. data/lib/buildr/core/help.rb +1 -6
  42. data/lib/buildr/core/linux.rb +0 -1
  43. data/lib/buildr/core/osx.rb +0 -1
  44. data/lib/buildr/core/project.rb +0 -4
  45. data/lib/buildr/core/run.rb +0 -4
  46. data/lib/buildr/core/shell.rb +0 -5
  47. data/lib/buildr/core/test.rb +0 -6
  48. data/lib/buildr/core/transports.rb +4 -6
  49. data/lib/buildr/core/util.rb +0 -63
  50. data/lib/buildr/groovy/doc.rb +0 -3
  51. data/lib/buildr/groovy/shell.rb +0 -2
  52. data/lib/buildr/ide/eclipse.rb +0 -9
  53. data/lib/buildr/ide/eclipse/java.rb +0 -4
  54. data/lib/buildr/ide/eclipse/plugin.rb +0 -4
  55. data/lib/buildr/ide/eclipse/scala.rb +0 -4
  56. data/lib/buildr/ide/idea.rb +100 -51
  57. data/lib/buildr/java/ant.rb +0 -3
  58. data/lib/buildr/java/bdd.rb +1 -119
  59. data/lib/buildr/java/cobertura.rb +16 -10
  60. data/lib/buildr/java/commands.rb +33 -7
  61. data/lib/buildr/java/compiler.rb +0 -7
  62. data/lib/buildr/java/deprecated.rb +0 -4
  63. data/lib/buildr/java/doc.rb +0 -2
  64. data/lib/buildr/java/emma.rb +0 -4
  65. data/lib/buildr/java/jruby.rb +0 -2
  66. data/lib/buildr/java/packaging.rb +0 -4
  67. data/lib/buildr/java/pom.rb +19 -12
  68. data/lib/buildr/java/test_result.rb +0 -5
  69. data/lib/buildr/java/tests.rb +68 -6
  70. data/lib/buildr/packaging/archive.rb +0 -1
  71. data/lib/buildr/packaging/artifact.rb +19 -16
  72. data/lib/buildr/packaging/artifact_namespace.rb +51 -24
  73. data/lib/buildr/packaging/artifact_search.rb +1 -2
  74. data/lib/buildr/packaging/gems.rb +1 -13
  75. data/lib/buildr/packaging/package.rb +0 -6
  76. data/lib/buildr/packaging/tar.rb +2 -4
  77. data/lib/buildr/packaging/zip.rb +0 -1
  78. data/lib/buildr/packaging/ziptask.rb +0 -4
  79. data/lib/buildr/run.rb +0 -1
  80. data/lib/buildr/scala/bdd.rb +129 -11
  81. data/lib/buildr/scala/compiler.rb +53 -6
  82. data/lib/buildr/scala/doc.rb +6 -4
  83. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +38 -0
  84. data/lib/buildr/scala/shell.rb +0 -4
  85. data/lib/buildr/scala/tests.rb +15 -6
  86. data/lib/buildr/shell.rb +0 -1
  87. data/lib/buildr/version.rb +1 -1
  88. data/rakelib/all-in-one.rake +20 -11
  89. data/rakelib/checks.rake +0 -31
  90. data/rakelib/doc.rake +86 -100
  91. data/rakelib/release.rake +1 -1
  92. data/rakelib/rspec.rake +1 -3
  93. data/rakelib/stage.rake +2 -9
  94. data/spec/addon/bnd_spec.rb +2 -2
  95. data/spec/addon/jaxb_xjc_spec.rb +5 -0
  96. data/spec/core/application_spec.rb +10 -63
  97. data/spec/core/cc_spec.rb +0 -1
  98. data/spec/core/compile_spec.rb +11 -0
  99. data/spec/ide/idea_spec.rb +60 -0
  100. data/spec/java/bdd_spec.rb +8 -218
  101. data/spec/java/compiler_spec.rb +11 -8
  102. data/spec/java/tests_spec.rb +185 -0
  103. data/spec/packaging/artifact_namespace_spec.rb +15 -0
  104. data/spec/packaging/artifact_spec.rb +25 -0
  105. data/spec/sandbox.rb +3 -1
  106. data/spec/scala/bdd_spec.rb +111 -8
  107. data/spec/scala/tests_spec.rb +5 -1
  108. data/spec/spec_helpers.rb +3 -3
  109. metadata +377 -465
  110. data/lib/buildr/core.rb +0 -34
  111. data/lib/buildr/ide.rb +0 -19
  112. data/lib/buildr/java.rb +0 -25
  113. data/lib/buildr/java/jtestr_result.rb +0 -331
  114. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  115. data/lib/buildr/packaging.rb +0 -25
  116. data/rakelib/setup.rake +0 -68
data/CHANGELOG CHANGED
@@ -1,3 +1,62 @@
1
+ 1.4.7 (Pending)
2
+ * Added: Add a Findbugs extension.
3
+ * Added: Add a Checkstyle extension.
4
+ * Added: Add a JavaNCSS extension.
5
+ * Added: Add a PMD extension.
6
+ * Added: MultiTest framework that allows combining multiple test frameworks
7
+ for a single project.
8
+ * Added: Scala Specs2 framework support.
9
+ * Added: Buildr.transitive() now accepts hash with :scopes, :optional and
10
+ :scopes_transitive parameters
11
+ * Added: Improved scala file change detection
12
+ (to avoid recompiling unnecessarily)
13
+ * Added: ScalaTest now automatically loads the Mockito library
14
+ * Added: Enhance the Intellij IDEA extension to support the addition of "artifacts"
15
+ and "configurations" to the generated project file.
16
+ * Added: BUILDR-598 TestNG support for :groups and :excludegroups (Christopher Coco)
17
+ * Added: BUILDR-616 Buildr development - If using rvm a default .rvmrc file would be helpful (Russell Teabeault)
18
+ * Change: Scala Specs upgraded to 1.6.9 if using Scala 2.9.1
19
+ * Change: Scala 2.9.1 is now default
20
+ * Change: Make it possible to parameterize the JDepend extension and control the
21
+ projects that are included in the analysis and to enable support for
22
+ loading a per project jdepend.properties.
23
+ * Change: Parameterize the the directory where the top level cobertura tasks will generate
24
+ reports. Specify using Buildr::Cobertura.report_dir = '....'
25
+ * Change: Stop pretty printing the Intellij IDEA project files to avoid IDEA breaking
26
+ in the presence of non-normalized whitespace content.
27
+ * Change: Change the Intellij IDEA extension to always rebuild the project files.
28
+ * Change: Upgrade to require atoulme-Antwrap 0.7.2
29
+ * Change: Changed the default output directory for Intellij IDEA extension to be
30
+ _(:target, :main, :idea, :classes) from _(:target, :main, :java) and the
31
+ default test output directory to be _(:target, :test, :idea, :classes)
32
+ from _(:target, :test, :java)
33
+ * Change: Upgrade to highline 1.6.2
34
+ * Change: Upgrade to jekyll 0.11.0, jekylltask 1.1.0, RedCloth 4.2.7, rdoc 3.8 for
35
+ generating documentation
36
+ * Change: Upgrade to require rubygems > 1.8.6
37
+ * Change: BUILDR-603 Remove install/uninstall actions from :gem packaging type
38
+ * Change: BUILDR-602 Fail the build when gem dependencies are missing rather than
39
+ attempting to install the dependencies
40
+ * Change: BUILDR-601 Remove Buildr::Util::Gems
41
+ * Change: BUILDR-600 Centralize the common ad internal requires into one location.
42
+ * Change: Upgrade to JRuby 1.6.2
43
+ * Change: Move to Bundler to manage the project dependencies
44
+ * Change: BUILDR-548 Remove support for JTestR as it is no longer maintained (Antoine Toulme)
45
+ * Change: BUILDR-614 Buildr development - Using rvm, bundler and OSX installs the wrong rjb (Russell Teabeault)
46
+ * Change: Upgrade to RJB 1.3.7
47
+ * Fixed: ArtifactNamespace fails when using artifacts with classfier.
48
+ * Fixed: Buildr.artifacts() should handle any object with :to_spec method
49
+ (i.e., any object that ActsAsArtifact)
50
+ * Fixed: Handle HTTP Unauthorized (501) result code when downloading artifacts.
51
+ * Fixed: BUILDR-611 Buildr should not unnecessarily recompile Java files
52
+ explicitly added to compile.from
53
+ * Fixed: scaladoc generation with scala 2.9.x
54
+ * Fixed: Bnd Plugin: Add each artifact individually as a prerequisite to
55
+ bundle / package task when passed to classpath_element method
56
+ * Fixed: BUILDR-439 "The command line is too long" when running TestNG tests (Tammo Van Lessen)
57
+ * Fixed: BUILDR-595 Add option to specifiy location of ca cert
58
+ * Fixed: BUILDR-596 Update installation notes to talk about the all-in-one bundle
59
+
1
60
  1.4.6 (2011-06-21)
2
61
  * Added: BUILDR-592 Allow Users to Specify SSH Options for Deployment (Marc-André Laverdière)
3
62
  * Fixed: BUILDR-591 Sort modules in iml files generated by idea task to ensure
data/Rakefile CHANGED
@@ -16,7 +16,7 @@
16
16
  # We need JAVA_HOME for most things (setup, spec, etc).
17
17
  unless ENV['JAVA_HOME']
18
18
  if RUBY_PLATFORM[/java/]
19
- ENV['JAVA_HOME'] = java.lang.System.getProperty('java.home')
19
+ ENV['JAVA_HOME'] = Java.java.lang.System.getProperty('java.home')
20
20
  elsif RUBY_PLATFORM[/darwin/]
21
21
  ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.framework/Home'
22
22
  else
@@ -13,10 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/java'
18
-
19
-
20
16
  module Buildr
21
17
  # Provides ANTLR grammar generation tasks. Require explicitly using <code>require "buildr/antlr"</code>.
22
18
  module ANTLR
@@ -46,7 +46,9 @@ module Buildr
46
46
 
47
47
  def classpath_element(dependencies)
48
48
  artifacts = Buildr.artifacts([dependencies])
49
- self.prerequisites << artifacts
49
+ artifacts.each do |artifact|
50
+ self.prerequisites << artifact
51
+ end
50
52
  artifacts.each do |dependency|
51
53
  self.classpath << dependency.to_s
52
54
  end
@@ -0,0 +1,201 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ module Buildr
17
+ # Provides the <code>checkstyle:html</code> and <code>checkstyle:xml</code> tasks.
18
+ # Require explicitly using <code>require "buildr/checkstyle"</code>.
19
+ module Checkstyle
20
+
21
+ class << self
22
+
23
+ # The specs for requirements
24
+ def dependencies
25
+ [
26
+ 'com.puppycrawl.tools:checkstyle:jar:5.4',
27
+ 'commons-cli:commons-cli:jar:1.2',
28
+ 'antlr:antlr:jar:2.7.7',
29
+ 'com.google.collections:google-collections:jar:1.0',
30
+ 'commons-beanutils:commons-beanutils-core:jar:1.8.3',
31
+ 'commons-logging:commons-logging:jar:1.1.1'
32
+ ]
33
+ end
34
+
35
+ def checkstyle(configuration_file, format, output_file, source_paths, options = {})
36
+ dependencies = (options[:dependencies] || []) + self.dependencies
37
+ cp = Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s)
38
+
39
+ args = []
40
+ if options[:properties_file]
41
+ args << "-p"
42
+ args << options[:properties_file]
43
+ end
44
+ args << "-c"
45
+ args << configuration_file
46
+ args << "-f"
47
+ args << format
48
+ args << "-o"
49
+ args << output_file
50
+ source_paths.each do |source_path|
51
+ args << "-r"
52
+ args << source_path
53
+ end
54
+
55
+ begin
56
+ Java::Commands.java 'com.puppycrawl.tools.checkstyle.Main', *(args + [{:classpath => cp, :properties => options[:properties], :java_args => options[:java_args]}])
57
+ rescue => e
58
+ raise e if options[:fail_on_error]
59
+ end
60
+ end
61
+ end
62
+
63
+ class Config
64
+ def enabled?
65
+ File.exist?(self.configuration_file)
66
+ end
67
+
68
+ def html_enabled?
69
+ File.exist?(self.style_file)
70
+ end
71
+
72
+ attr_writer :config_directory
73
+
74
+ def config_directory
75
+ @config_directory || project._(:source, :main, :etc, :checkstyle)
76
+ end
77
+
78
+ attr_writer :report_dir
79
+
80
+ def report_dir
81
+ @report_dir || project._(:reports, :checkstyle)
82
+ end
83
+
84
+ attr_writer :configuration_file
85
+
86
+ def configuration_file
87
+ @configuration_file || "#{self.config_directory}/checks.xml"
88
+ end
89
+
90
+ attr_writer :fail_on_error
91
+
92
+ def fail_on_error?
93
+ @fail_on_error.nil? ? false : @fail_on_error
94
+ end
95
+
96
+ attr_writer :format
97
+
98
+ def format
99
+ @format || 'xml'
100
+ end
101
+
102
+ attr_writer :xml_output_file
103
+
104
+ def xml_output_file
105
+ @xml_output_file || "#{self.report_dir}/checkstyle.xml"
106
+ end
107
+
108
+ attr_writer :html_output_file
109
+
110
+ def html_output_file
111
+ @html_output_file || "#{self.report_dir}/checkstyle.html"
112
+ end
113
+
114
+ attr_writer :style_file
115
+
116
+ def style_file
117
+ @style_file || "#{self.config_directory}/checkstyle-report.xsl"
118
+ end
119
+
120
+ attr_writer :suppressions_file
121
+
122
+ def suppressions_file
123
+ @suppressions_file || "#{self.config_directory}/suppressions.xml"
124
+ end
125
+
126
+ attr_writer :import_control_file
127
+
128
+ def import_control_file
129
+ @import_control_file || "#{self.config_directory}/import-control.xml"
130
+ end
131
+
132
+ def properties
133
+ properties = {:basedir => self.project.base_dir}
134
+ properties['checkstyle.suppressions.file'] = self.suppressions_file if File.exist?(self.suppressions_file)
135
+ properties['checkstyle.import-control.file'] = self.import_control_file if File.exist?(self.import_control_file)
136
+ properties
137
+ end
138
+
139
+ def source_paths
140
+ @source_paths ||= [self.project.compile.sources, self.project.test.compile.sources]
141
+ end
142
+
143
+ def extra_dependencies
144
+ @extra_dependencies ||= [self.project.compile.dependencies, self.project.test.compile.dependencies]
145
+ end
146
+
147
+ protected
148
+
149
+ def initialize(project)
150
+ @project = project
151
+ end
152
+
153
+ attr_reader :project
154
+
155
+ end
156
+
157
+ module ProjectExtension
158
+ include Extension
159
+
160
+ def checkstyle
161
+ @checkstyle ||= Buildr::Checkstyle::Config.new(project)
162
+ end
163
+
164
+ after_define do |project|
165
+ if project.checkstyle.enabled?
166
+ desc "Generate checkstyle xml report."
167
+ project.task("checkstyle:xml") do
168
+ puts "Checkstyle: Analyzing source code..."
169
+ mkdir_p File.dirname(project.checkstyle.xml_output_file)
170
+ Buildr::Checkstyle.checkstyle(project.checkstyle.configuration_file,
171
+ project.checkstyle.format,
172
+ project.checkstyle.xml_output_file,
173
+ project.checkstyle.source_paths.flatten.compact,
174
+ :properties => project.checkstyle.properties,
175
+ :fail_on_error => project.checkstyle.fail_on_error?,
176
+ :dependencies => project.checkstyle.extra_dependencies)
177
+ end
178
+
179
+ if project.checkstyle.html_enabled?
180
+ xml_task = project.task("checkstyle:xml")
181
+ desc "Generate checkstyle html report."
182
+ project.task("checkstyle:html" => xml_task) do
183
+ puts "Checkstyle: Generating report"
184
+ mkdir_p File.dirname(project.checkstyle.html_output_file)
185
+ Buildr.ant "checkstyle" do |ant|
186
+ ant.xslt :in => project.checkstyle.xml_output_file,
187
+ :out => project.checkstyle.html_output_file,
188
+ :style => project.checkstyle.style_file
189
+ end
190
+ end
191
+
192
+ end
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end
198
+
199
+ class Buildr::Project
200
+ include Buildr::Checkstyle::ProjectExtension
201
+ end
@@ -13,7 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
16
  if Buildr::VERSION < '1.5'
18
17
  Buildr.application.deprecated "'buildr/cobertura', use 'buildr/java/cobertura' instead"
19
18
  require 'buildr/java/cobertura'
@@ -13,11 +13,9 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
16
  require 'delegate'
18
17
  require 'drb/drb'
19
18
 
20
-
21
19
  module Buildr
22
20
 
23
21
  # This addon allows you start a DRb server hosting a buildfile, so that
@@ -13,7 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
16
  if Buildr::VERSION < '1.5'
18
17
  Buildr.application.deprecated "'buildr/emma', use 'buildr/java/emma' instead"
19
18
  require 'buildr/java/emma'
@@ -0,0 +1,227 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ module Buildr
17
+ # Provides the <code>findbugs:html</code> and <code>findbugs:xml</code> tasks.
18
+ # Require explicitly using <code>require "buildr/findbugs"</code>.
19
+ module Findbugs
20
+
21
+ class << self
22
+
23
+ # The specs for requirements
24
+ def dependencies
25
+ [
26
+ 'com.google.code.findbugs:findbugs-ant:jar:1.3.9',
27
+ 'com.google.code.findbugs:findbugs:jar:1.3.9',
28
+ 'com.google.code.findbugs:bcel:jar:1.3.9',
29
+ 'com.google.code.findbugs:jsr305:jar:1.3.9',
30
+ 'com.google.code.findbugs:jFormatString:jar:1.3.9',
31
+ 'com.google.code.findbugs:annotations:jar:1.3.9',
32
+ 'dom4j:dom4j:jar:1.6.1',
33
+ 'jaxen:jaxen:jar:1.1.1',
34
+ 'jdom:jdom:jar:1.0',
35
+ 'xom:xom:jar:1.0',
36
+ 'com.ibm.icu:icu4j:jar:2.6.1',
37
+ 'asm:asm:jar:3.1',
38
+ 'asm:asm-analysis:jar:3.1',
39
+ 'asm:asm-tree:jar:3.1',
40
+ 'asm:asm-commons:jar:3.1',
41
+ 'asm:asm-util:jar:3.1',
42
+ 'asm:asm-xml:jar:3.1',
43
+ 'commons-lang:commons-lang:jar:2.4'
44
+ ]
45
+ end
46
+
47
+ def findbugs(output_file, source_paths, analyze_paths, options = { })
48
+ dependencies = (options[:dependencies] || []) + self.dependencies
49
+ cp = Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
50
+
51
+ args = {
52
+ :output => "xml:withMessages",
53
+ :outputFile => output_file,
54
+ :effort => 'max',
55
+ :pluginList => '',
56
+ :classpath => cp,
57
+ :timeout => "90000000",
58
+ :debug => "false"
59
+ }
60
+ args[:failOnError] = true if options[:fail_on_error]
61
+ args[:excludeFilter] = options[:exclude_filter] if options[:exclude_filter]
62
+ args[:jvmargs] = options[:java_args] if options[:java_args]
63
+
64
+ Buildr.ant('findBugs') do |ant|
65
+ ant.taskdef :name =>'findBugs',
66
+ :classname =>'edu.umd.cs.findbugs.anttask.FindBugsTask',
67
+ :classpath => cp
68
+ ant.findBugs args do
69
+ source_paths.each do |source_path|
70
+ ant.sourcePath :path => source_path.to_s
71
+ end
72
+ Buildr.artifacts(analyze_paths).each(&:invoke).each do |analyze_path|
73
+ ant.auxAnalyzePath :path => analyze_path.to_s
74
+ end
75
+ if options[:properties]
76
+ options[:properties].each_pair do |k, v|
77
+ ant.systemProperty :name => k, :value => v
78
+ end
79
+ end
80
+ if options[:extra_dependencies]
81
+ ant.auxClasspath do |aux|
82
+ Buildr.artifacts(options[:extra_dependencies]).each(&:invoke).each do |dep|
83
+ aux.pathelement :location => dep.to_s
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ class Config
93
+
94
+ attr_accessor :enabled
95
+
96
+ def enabled?
97
+ !!@enabled
98
+ end
99
+
100
+ def html_enabled?
101
+ File.exist?(self.style_file)
102
+ end
103
+
104
+ attr_writer :config_directory
105
+
106
+ def config_directory
107
+ @config_directory || project._(:source, :main, :etc, :findbugs)
108
+ end
109
+
110
+ attr_writer :report_dir
111
+
112
+ def report_dir
113
+ @report_dir || project._(:reports, :findbugs)
114
+ end
115
+
116
+ attr_writer :fail_on_error
117
+
118
+ def fail_on_error?
119
+ @fail_on_error.nil? ? false : @fail_on_error
120
+ end
121
+
122
+ attr_writer :xml_output_file
123
+
124
+ def xml_output_file
125
+ @xml_output_file || "#{self.report_dir}/findbugs.xml"
126
+ end
127
+
128
+ attr_writer :html_output_file
129
+
130
+ def html_output_file
131
+ @html_output_file || "#{self.report_dir}/findbugs.html"
132
+ end
133
+
134
+ attr_writer :style_file
135
+
136
+ def style_file
137
+ @style_file || "#{self.config_directory}/findbugs-report.xsl"
138
+ end
139
+
140
+ attr_writer :filter_file
141
+
142
+ def filter_file
143
+ @filter_file || "#{self.config_directory}/filter.xml"
144
+ end
145
+
146
+ def properties
147
+ @properties ||= { }
148
+ end
149
+
150
+ attr_writer :java_args
151
+
152
+ def java_args
153
+ @java_args || "-server -Xss1m -Xmx800m -Duser.language=en -Duser.region=EN "
154
+ end
155
+
156
+ def source_paths
157
+ @source_paths ||= [self.project.compile.sources, self.project.test.compile.sources]
158
+ end
159
+
160
+ def analyze_paths
161
+ @analyze_path ||= [self.project.compile.target]
162
+ end
163
+
164
+ def extra_dependencies
165
+ @extra_dependencies ||= [self.project.compile.dependencies, self.project.test.compile.dependencies]
166
+ end
167
+
168
+ protected
169
+
170
+ def initialize(project)
171
+ @project = project
172
+ end
173
+
174
+ attr_reader :project
175
+
176
+ end
177
+
178
+ module ProjectExtension
179
+ include Extension
180
+
181
+ def findbugs
182
+ @findbugs ||= Buildr::Findbugs::Config.new(project)
183
+ end
184
+
185
+ after_define do |project|
186
+ if project.findbugs.enabled?
187
+ desc "Generate findbugs xml report."
188
+ project.task("findbugs:xml") do
189
+ puts "Findbugs: Analyzing source code..."
190
+ mkdir_p File.dirname(project.findbugs.xml_output_file)
191
+
192
+ options =
193
+ {
194
+ :properties => project.findbugs.properties,
195
+ :fail_on_error => project.findbugs.fail_on_error?,
196
+ :extra_dependencies => project.findbugs.extra_dependencies
197
+ }
198
+ options[:exclude_filter] = project.findbugs.filter_file if File.exist?(project.findbugs.filter_file)
199
+
200
+ Buildr::Findbugs.findbugs(project.findbugs.xml_output_file,
201
+ project.findbugs.source_paths.flatten.compact,
202
+ project.findbugs.analyze_paths.flatten.compact,
203
+ options)
204
+ end
205
+
206
+ if project.findbugs.html_enabled?
207
+ xml_task = project.task("findbugs:xml")
208
+ desc "Generate findbugs html report."
209
+ project.task("findbugs:html" => xml_task) do
210
+ puts "Findbugs: Generating report"
211
+ mkdir_p File.dirname(project.findbugs.html_output_file)
212
+ Buildr.ant "findbugs" do |ant|
213
+ ant.style :in => project.findbugs.xml_output_file,
214
+ :out => project.findbugs.html_output_file,
215
+ :style => project.findbugs.style_file
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
224
+
225
+ class Buildr::Project
226
+ include Buildr::Findbugs::ProjectExtension
227
+ end