buildr 1.4.6-x86-mswin32 → 1.4.7-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/CHANGELOG +81 -0
  2. data/Rakefile +5 -2
  3. data/addon/buildr/antlr.rb +0 -4
  4. data/addon/buildr/bnd.rb +3 -1
  5. data/addon/buildr/checkstyle.rb +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.rb +227 -0
  10. data/addon/buildr/gwt.rake +82 -0
  11. data/addon/buildr/hibernate.rb +0 -4
  12. data/addon/buildr/javacc.rb +0 -4
  13. data/addon/buildr/javancss.rb +155 -0
  14. data/addon/buildr/jdepend.rb +138 -24
  15. data/addon/buildr/jdepend.rb.orig +178 -0
  16. data/addon/buildr/jetty.rb +0 -5
  17. data/addon/buildr/jibx.rb +85 -86
  18. data/addon/buildr/nailgun.rb +2 -2
  19. data/addon/buildr/openjpa.rb +0 -4
  20. data/addon/buildr/pmd.rb +166 -0
  21. data/addon/buildr/protobuf.rb +0 -1
  22. data/addon/buildr/sonar.rb +142 -0
  23. data/addon/buildr/xmlbeans.rb +0 -5
  24. data/buildr.gemspec +36 -21
  25. data/doc/_layouts/default.html +1 -0
  26. data/doc/contributing.textile +11 -2
  27. data/doc/download.textile +17 -5
  28. data/doc/index.textile +21 -46
  29. data/doc/installing.textile +18 -8
  30. data/doc/installing.textile.orig +282 -0
  31. data/doc/languages.textile +0 -38
  32. data/doc/more_stuff.textile +199 -12
  33. data/doc/more_stuff.textile.orig +1004 -0
  34. data/doc/packaging.textile +10 -0
  35. data/doc/settings_profiles.textile +2 -2
  36. data/etc/KEYS +44 -0
  37. data/lib/buildr.rb +67 -4
  38. data/lib/buildr/clojure.rb +0 -2
  39. data/lib/buildr/core/application.rb +23 -32
  40. data/lib/buildr/core/build.rb +0 -7
  41. data/lib/buildr/core/cc.rb +0 -5
  42. data/lib/buildr/core/checks.rb +0 -4
  43. data/lib/buildr/core/common.rb +0 -5
  44. data/lib/buildr/core/compile.rb +5 -10
  45. data/lib/buildr/core/doc.rb +9 -3
  46. data/lib/buildr/core/environment.rb +0 -1
  47. data/lib/buildr/core/filter.rb +0 -5
  48. data/lib/buildr/core/generate.rb +2 -6
  49. data/lib/buildr/core/help.rb +1 -6
  50. data/lib/buildr/core/linux.rb +0 -1
  51. data/lib/buildr/core/osx.rb +0 -1
  52. data/lib/buildr/core/project.rb +0 -4
  53. data/lib/buildr/core/run.rb +1 -5
  54. data/lib/buildr/core/shell.rb +1 -6
  55. data/lib/buildr/core/test.rb +1 -7
  56. data/lib/buildr/core/transports.rb +4 -6
  57. data/lib/buildr/core/util.rb +2 -65
  58. data/lib/buildr/groovy/doc.rb +0 -3
  59. data/lib/buildr/groovy/shell.rb +0 -2
  60. data/lib/buildr/ide/eclipse.rb +4 -13
  61. data/lib/buildr/ide/eclipse/java.rb +0 -4
  62. data/lib/buildr/ide/eclipse/plugin.rb +0 -4
  63. data/lib/buildr/ide/eclipse/scala.rb +0 -4
  64. data/lib/buildr/ide/idea.rb +284 -52
  65. data/lib/buildr/java/ant.rb +2 -6
  66. data/lib/buildr/java/bdd.rb +5 -123
  67. data/lib/buildr/java/cobertura.rb +16 -10
  68. data/lib/buildr/java/commands.rb +33 -7
  69. data/lib/buildr/java/compiler.rb +0 -7
  70. data/lib/buildr/java/deprecated.rb +0 -4
  71. data/lib/buildr/java/doc.rb +0 -2
  72. data/lib/buildr/java/emma.rb +0 -4
  73. data/lib/buildr/java/jruby.rb +0 -2
  74. data/lib/buildr/java/packaging.rb +0 -4
  75. data/lib/buildr/java/pom.rb +24 -16
  76. data/lib/buildr/java/rjb.rb +1 -1
  77. data/lib/buildr/java/test_result.rb +1 -2
  78. data/lib/buildr/java/tests.rb +68 -6
  79. data/lib/buildr/packaging/archive.rb +0 -1
  80. data/lib/buildr/packaging/artifact.rb +19 -16
  81. data/lib/buildr/packaging/artifact_namespace.rb +51 -24
  82. data/lib/buildr/packaging/artifact_search.rb +1 -2
  83. data/lib/buildr/packaging/gems.rb +1 -13
  84. data/lib/buildr/packaging/package.rb +0 -6
  85. data/lib/buildr/packaging/tar.rb +2 -4
  86. data/lib/buildr/packaging/version_requirement.rb +1 -1
  87. data/lib/buildr/packaging/zip.rb +1 -2
  88. data/lib/buildr/packaging/ziptask.rb +0 -4
  89. data/lib/buildr/run.rb +3 -3
  90. data/lib/buildr/scala/bdd.rb +129 -11
  91. data/lib/buildr/scala/compiler.rb +53 -6
  92. data/lib/buildr/scala/doc.rb +6 -4
  93. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
  94. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +38 -0
  95. data/lib/buildr/scala/shell.rb +0 -4
  96. data/lib/buildr/scala/tests.rb +15 -6
  97. data/lib/buildr/shell.rb +0 -1
  98. data/lib/buildr/version.rb +1 -1
  99. data/rakelib/all-in-one.rake +20 -11
  100. data/rakelib/checks.rake +0 -31
  101. data/rakelib/doc.rake +86 -100
  102. data/rakelib/package.rake +3 -3
  103. data/rakelib/release.rake +1 -1
  104. data/rakelib/rspec.rake +23 -7
  105. data/rakelib/stage.rake +18 -21
  106. data/spec/addon/bnd_spec.rb +2 -2
  107. data/spec/addon/jaxb_xjc_spec.rb +5 -0
  108. data/spec/core/application_spec.rb +11 -64
  109. data/spec/core/cc_spec.rb +12 -5
  110. data/spec/core/compile_spec.rb +11 -0
  111. data/spec/core/doc_spec.rb +1 -1
  112. data/spec/core/run_spec.rb +17 -4
  113. data/spec/core/test_spec.rb +5 -3
  114. data/spec/ide/idea_spec.rb +60 -0
  115. data/spec/java/bdd_spec.rb +8 -218
  116. data/spec/java/cobertura_spec.rb +4 -0
  117. data/spec/java/compiler_spec.rb +11 -8
  118. data/spec/java/emma_spec.rb +4 -1
  119. data/spec/java/java_spec.rb +1 -1
  120. data/spec/java/pom_spec.rb +125 -0
  121. data/spec/java/tests_spec.rb +185 -0
  122. data/spec/packaging/archive_spec.rb +1 -1
  123. data/spec/packaging/artifact_namespace_spec.rb +15 -0
  124. data/spec/packaging/artifact_spec.rb +26 -1
  125. data/spec/sandbox.rb +7 -1
  126. data/spec/scala/bdd_spec.rb +111 -8
  127. data/spec/scala/tests_spec.rb +5 -1
  128. data/spec/spec_helpers.rb +9 -4
  129. data/spec/version_requirement_spec.rb +2 -0
  130. metadata +570 -505
  131. data/lib/buildr/core.rb +0 -34
  132. data/lib/buildr/ide.rb +0 -19
  133. data/lib/buildr/java.rb +0 -25
  134. data/lib/buildr/java/jtestr_result.rb +0 -331
  135. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  136. data/lib/buildr/packaging.rb +0 -25
  137. data/rakelib/setup.rake +0 -68
@@ -17,15 +17,12 @@
17
17
  gem 'atoulme-Antwrap'
18
18
  autoload :Antwrap, 'antwrap'
19
19
  autoload :Logger, 'logger'
20
- require 'buildr/core/project'
21
- require 'buildr/core/help'
22
-
23
20
 
24
21
  module Buildr
25
22
  module Ant
26
23
 
27
24
  # Which version of Ant we're using by default.
28
- VERSION = '1.8.0'
25
+ VERSION = '1.8.3'
29
26
 
30
27
  class << self
31
28
  # Current version of Ant being used.
@@ -37,8 +34,7 @@ module Buildr
37
34
  def dependencies
38
35
  # Ant-Trax required for running the JUnitReport task, and there's no other place
39
36
  # to put it but the root classpath.
40
- @dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}",
41
- "org.apache.ant:ant-trax:jar:#{version}"]
37
+ @dependencies ||= ["org.apache.ant:ant:jar:#{version}", "org.apache.ant:ant-launcher:jar:#{version}"]
42
38
  end
43
39
 
44
40
  private
@@ -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/tests'
18
- require 'buildr/java/test_result'
19
-
20
16
  module Buildr
21
17
 
22
18
  # Mixin for test frameworks using src/spec/{lang}
@@ -47,7 +43,7 @@ module Buildr
47
43
  module TestFramework::JRubyBased
48
44
  extend self
49
45
 
50
- VERSION = '1.5.4' # Note: JtestR 0.6.0 only works up to 1.5.4
46
+ VERSION = '1.6.2'
51
47
 
52
48
  class << self
53
49
  def version
@@ -119,7 +115,7 @@ module Buildr
119
115
  end
120
116
 
121
117
  def jruby_home
122
- @jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] :
118
+ @jruby_home ||= RUBY_PLATFORM =~ /java/ ? RbConfig::CONFIG['prefix'] :
123
119
  ( ENV['JRUBY_HOME'] || File.expand_path('~/.jruby') )
124
120
  end
125
121
 
@@ -170,7 +166,7 @@ module Buildr
170
166
  require 'jruby'
171
167
  def JRuby.gem(name, version = '>0', *args)
172
168
  require 'rbconfig'
173
- jruby_home = Config::CONFIG['prefix']
169
+ jruby_home = RbConfig::CONFIG['prefix']
174
170
  expected_version = '#{TestFramework::JRubyBased.version}'
175
171
  unless JRUBY_VERSION >= expected_version
176
172
  fail "Expected JRuby version \#{expected_version} installed at \#{jruby_home} but got \#{JRUBY_VERSION}"
@@ -198,7 +194,7 @@ module Buildr
198
194
  runner.requires ||= []
199
195
  runner.requires.unshift File.join(File.dirname(__FILE__), 'test_result')
200
196
  runner.gems ||= {}
201
- runner.rspec ||= ['--format', 'progress', '--format', "html:#{runner.html_report}"]
197
+ runner.rspec ||= ['--format', 'progress', '--format', 'documentation']
202
198
  runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
203
199
  runner.rspec.push '--format', "Buildr::TestFramework::TestResult::YamlFormatter"
204
200
  runner.rspec.push '-o', runner.result
@@ -244,7 +240,7 @@ module Buildr
244
240
 
245
241
  def runner_config
246
242
  runner = super
247
- runner.gems.update 'rspec' => '~> 2.1.0'
243
+ runner.gems.update 'rspec' => '~> 2.9.0'
248
244
  runner.requires.unshift 'rspec'
249
245
  runner
250
246
  end
@@ -276,119 +272,6 @@ module Buildr
276
272
 
277
273
  end
278
274
 
279
- # <a href="http://jtestr.codehaus.org/">JtestR</a> is a framework for BDD and TDD using JRuby and ruby tools.
280
- # To test your project with JtestR use:
281
- # test.using :jtestr
282
- #
283
- #
284
- # Support the following options:
285
- # * :config -- path to JtestR config file. defaults to @spec/ruby/jtestr_config.rb@
286
- # * :gems -- A hash of gems to install before running the tests.
287
- # The keys of this hash are the gem name, the value must be the required version.
288
- # * :requires -- A list of ruby files to require before running the specs
289
- # Mainly used if an rspec format needs to require some file.
290
- # * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
291
- # * :output -- File path to output dump. @false@ to supress output
292
- # * :fork -- Create a new JavaVM to run the tests on
293
- # * :properties -- Hash of properties passed to the test suite.
294
- # * :java_args -- Arguments passed to the JVM.
295
- class JtestR < TestFramework::JavaBDD
296
- @lang = :ruby
297
- @bdd_dir = :spec
298
-
299
- include TestFramework::JRubyBased
300
-
301
- VERSION = '0.6'
302
-
303
- # pattern for rspec stories
304
- STORY_PATTERN = /_(steps|story)\.rb$/
305
- # pattern for test_unit files
306
- TESTUNIT_PATTERN = /(_test|Test)\.rb$|(tc|ts)[^\\\/]+\.rb$/
307
- # pattern for test files using http://expectations.rubyforge.org/
308
- EXPECT_PATTERN = /_expect\.rb$/
309
-
310
- TESTS_PATTERN = [STORY_PATTERN, TESTUNIT_PATTERN, EXPECT_PATTERN] + RSpec::TESTS_PATTERN
311
-
312
- class << self
313
-
314
- def version
315
- Buildr.settings.build['jtestr'] || VERSION
316
- end
317
-
318
- def dependencies
319
- unless @dependencies
320
- super
321
- @dependencies |= ["org.jtestr:jtestr:jar:#{version}"] +
322
- JUnit.dependencies + TestNG.dependencies
323
- end
324
- @dependencies
325
- end
326
-
327
- def applies_to?(project) #:nodoc:
328
- File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) ||
329
- Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } ||
330
- JUnit.applies_to?(project) || TestNG.applies_to?(project)
331
- end
332
-
333
- private
334
- def const_missing(const)
335
- return super unless const == :REQUIRES # TODO: remove in 1.5
336
- Buildr.application.deprecated 'Please use JtestR.dependencies/.version instead of JtestR::REQUIRES/VERSION'
337
- dependencies
338
- end
339
-
340
- end
341
-
342
- def initialize(task, options) #:nodoc:
343
- super
344
- [:test, :spec].each do |usage|
345
- java_tests = task.project.path_to(:source, usage, :java)
346
- task.compile.from java_tests if File.directory?(java_tests)
347
- resources = task.project.path_to(:source, usage, :resources)
348
- task.resources.from resources if File.directory?(resources)
349
- end
350
- end
351
-
352
- def user_config
353
- options[:config] || task.project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')
354
- end
355
-
356
- def tests(dependencies) #:nodoc:
357
- dependencies |= [task.compile.target.to_s]
358
- types = { :story => STORY_PATTERN, :rspec => RSpec::TESTS_PATTERN,
359
- :testunit => TESTUNIT_PATTERN, :expect => EXPECT_PATTERN }
360
- tests = types.keys.inject({}) { |h, k| h[k] = []; h }
361
- tests[:junit] = JUnit.new(task, {}).tests(dependencies)
362
- tests[:testng] = TestNG.new(task, {}).tests(dependencies)
363
- Dir[task.project.path_to(:source, bdd_dir, lang, '**/*.rb')].each do |rb|
364
- type = types.find { |k, v| Array(v).any? { |r| r === rb } }
365
- tests[type.first] << rb if type
366
- end
367
- @jtestr_tests = tests
368
- tests.values.flatten
369
- end
370
-
371
- def runner_config
372
- runner = super
373
- # JtestR 0.6.0 comes with rspec 1.3.0 (and any other jtestr dependency) included,
374
- # so the rspec version used depends on the jtestr jar.
375
- runner.gems.update 'rspec' => '=1.3.0'
376
- runner.requires.clear
377
- runner.requires.unshift 'jtestr'
378
- runner.requires.unshift 'spec'
379
- runner.requires.unshift File.join(File.dirname(__FILE__), 'jtestr_result')
380
- runner.rspec = ['--format', 'progress', '--format', "html:#{runner.html_report}"]
381
- runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
382
- runner.rspec.push '--format', "Buildr::JtestR::YamlFormatter:#{runner.result}"
383
- runner
384
- end
385
-
386
- def runner_content(binding)
387
- runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
388
- Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
389
- end
390
- end
391
-
392
275
  # JBehave is a Java BDD framework. To use in your project:
393
276
  # test.using :jbehave
394
277
  #
@@ -458,6 +341,5 @@ module Buildr
458
341
  end
459
342
 
460
343
  Buildr::TestFramework << Buildr::RSpec
461
- Buildr::TestFramework << Buildr::JtestR
462
344
  Buildr::TestFramework << Buildr::JBehave
463
345
 
@@ -13,14 +13,10 @@
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
 
22
18
  # Provides the <code>cobertura:html</code>, <code>cobertura:xml</code> and <code>cobertura:check</code> tasks.
23
- # Require explicitly using <code>require "buildr/cobertura"</code>.
19
+ # Require explicitly using <code>require "buildr/java/cobertura"</code>.
24
20
  #
25
21
  # You can generate cobertura reports for a single project
26
22
  # using the project name as prefix:
@@ -38,6 +34,10 @@ module Buildr
38
34
  # cobertura.exclude /*.Const(ants)?/i
39
35
  # end
40
36
  #
37
+ # You can also specify the top level directory to which the top level cobertura tasks
38
+ # will generate reports by setting the value of the <code>Buildr::Cobertura.report_dir</code>
39
+ # configuration parameter.
40
+ #
41
41
  module Cobertura
42
42
 
43
43
  VERSION = '1.9.4.1'
@@ -65,12 +65,18 @@ module Buildr
65
65
  REQUIRES.artifacts
66
66
  end
67
67
 
68
+ attr_writer :report_dir
69
+
70
+ def report_dir
71
+ @report_dir || "reports/cobertura"
72
+ end
73
+
68
74
  def report_to(file = nil)
69
- File.expand_path(File.join(*["reports/cobertura", file.to_s].compact))
75
+ File.expand_path(File.join(*[report_dir, file.to_s].compact))
70
76
  end
71
77
 
72
- def data_file()
73
- File.expand_path("reports/cobertura.ser")
78
+ def data_file
79
+ File.expand_path("#{report_dir}.ser")
74
80
  end
75
81
 
76
82
  end
@@ -266,9 +272,9 @@ module Buildr
266
272
  end
267
273
 
268
274
  [:xml, :html].each do |format|
269
- report_target = report_to(format)
270
- desc "Run the test cases and produce code coverage reports in #{report_target}"
275
+ desc "Run the test cases and produce code coverage reports"
271
276
  task format => ["instrument", "test"] do
277
+ report_target = report_to(format)
272
278
  if Buildr.projects.detect { |project| !project.compile.sources.empty? }
273
279
  info "Creating test coverage reports in #{report_target}"
274
280
  Buildr.ant "cobertura" do |ant|
@@ -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
  # Base module for all things Java.
18
17
  module Java
19
18
 
@@ -56,12 +55,39 @@ module Java
56
55
  options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]
57
56
  cmd_args += (options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split).flatten
58
57
  cmd_args += args.flatten.compact
59
- unless Buildr.application.options.dryrun
60
- info "Running #{name}" if name && options[:verbose]
61
- block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
62
- cmd_args = cmd_args.map(&:inspect).join(' ') if Util.win_os?
63
- sh(*cmd_args) do |ok, ps|
64
- block.call ok, ps
58
+
59
+ tmp = nil
60
+ begin
61
+ # Windows can't handle cmd lines greater than 2048/8192 chars.
62
+ # If our cmd line is longer, we create a batch file and execute it instead.
63
+ if Util.win_os? && cmd_args.map(&:inspect).join(' ').size > 2048
64
+ # remove '-classpath' and the classpath itself from the cmd line.
65
+ cp_i = cmd_args.index{|x| x.starts_with('-classpath')}
66
+ 2.times do
67
+ cmd_args.delete_at cp_i unless cp_i.nil?
68
+ end
69
+ # create tmp batch file.
70
+ tmp = Tempfile.new(['starter', '.bat'])
71
+ tmp.write "@echo off\n"
72
+ tmp.write "SET CLASSPATH=#{cp.join(File::PATH_SEPARATOR).gsub(%r{/}, '\\')}\n"
73
+ tmp.write cmd_args.map(&:inspect).join(' ')
74
+ tmp.close
75
+ # set new cmd line.
76
+ cmd_args = [tmp.path]
77
+ end
78
+
79
+ unless Buildr.application.options.dryrun
80
+ info "Running #{name}" if name && options[:verbose]
81
+ block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
82
+ cmd_args = cmd_args.map(&:inspect).join(' ') if Util.win_os?
83
+ sh(*cmd_args) do |ok, ps|
84
+ block.call ok, ps
85
+ end
86
+ end
87
+ ensure
88
+ unless tmp.nil?
89
+ tmp.close
90
+ tmp.unlink
65
91
  end
66
92
  end
67
93
  end
@@ -13,13 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/core/project'
18
- require 'buildr/core/common'
19
- require 'buildr/core/compile'
20
- require 'buildr/packaging'
21
-
22
-
23
16
  module Buildr
24
17
  module Compiler
25
18
 
@@ -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/core/project'
18
-
19
-
20
16
  module Java
21
17
 
22
18
  # *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
@@ -13,8 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- require 'buildr/core/doc'
17
-
18
16
  module Buildr
19
17
  module Doc
20
18
 
@@ -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
 
22
18
  # Provides the <code>emma:html</code> and <code>emma:xml</code> tasks.
@@ -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 'java'
18
17
  require 'jruby'
19
18
 
20
-
21
19
  # Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows
22
20
  # you to access Java classes and create Java objects.
23
21
  #
@@ -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/packaging'
18
-
19
-
20
16
  module Buildr
21
17
  module Packaging #:nodoc:
22
18
 
@@ -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
  module Buildr
18
17
  class POM
19
18
 
@@ -76,36 +75,44 @@ module Buildr
76
75
 
77
76
  # :call-seq:
78
77
  # dependencies(scopes?) => artifacts
78
+ # dependencies(:scopes = [:runtime, :test, ...], :optional = true) => artifacts
79
79
  #
80
80
  # Returns list of required dependencies as specified by the POM. You can specify which scopes
81
81
  # to use (e.g. "compile", "runtime"); use +nil+ for dependencies with unspecified scope.
82
- # The default scopes are +nil+, "compile" and "runtime" (aka SCOPES_WE_USE).
83
- def dependencies(scopes = SCOPES_WE_USE)
84
- #try to cache dependencies also
82
+ # The default scopes are +nil+, "compile" and "runtime" (aka SCOPES_WE_USE) and no optional dependencies.
83
+ # Specifying optional = true will return all optional dependencies matching the given scopes.
84
+ def dependencies(options = {})
85
+ # backward compatibility
86
+ options = { :scopes => options } if Array === options
87
+
88
+ # support symbols, but don't fidget with nil
89
+ options[:scopes] = (options[:scopes] || SCOPES_WE_USE).map { |s| s.to_s if s }
90
+
91
+ # try to cache dependencies also
85
92
  @depends_for_scopes ||= {}
86
- unless depends = @depends_for_scopes[scopes]
93
+ unless depends = @depends_for_scopes[options]
87
94
  declared = project["dependencies"].first["dependency"] rescue nil
88
- depends = (declared || []).reject { |dep| value_of(dep["optional"]) =~ /true/ }.
89
- map { |dep|
95
+ depends = (declared || [])
96
+ depends = depends.reject { |dep| value_of(dep["optional"]) =~ /true/ } unless options[:optional]
97
+ depends = depends.map { |dep|
90
98
  spec = pom_to_hash(dep, properties)
91
99
  apply = managed(spec)
92
100
  spec = apply.merge(spec) if apply
93
101
 
94
- #calculate transitive dependencies
95
- if scopes.include?(spec[:scope])
102
+ # calculate transitive dependencies
103
+ if options[:scopes].include?(spec[:scope])
96
104
  spec.delete(:scope)
97
105
 
98
- exclusions = dep["exclusions"]["exclusion"] rescue nil
99
- transitive_deps = POM.load(spec).dependencies(SCOPES_TRANSITIVE)
106
+ exclusions = dep["exclusions"].first["exclusion"] rescue nil
107
+ transitive_deps = POM.load(spec).dependencies(options[:scopes_transitive] || SCOPES_TRANSITIVE)
100
108
  transitive_deps = transitive_deps.reject{|dep|
101
- exclusions.find {|ex| dep.index("#{dep['groupdId'].first}:#{dep['artifactId'].first}:") == 0}
109
+ exclusions.find {|ex| dep.index("#{ex['groupId'].first}:#{ex['artifactId'].first}:") == 0}
102
110
  } if exclusions
103
111
 
104
112
  [Artifact.to_spec(spec)] + transitive_deps
105
113
  end
106
114
  }.flatten.compact #.uniq_by{|spec| art = spec.split(':'); "#{art[0]}:#{art[1]}"}
107
-
108
- @depends_for_scopes[scopes] = depends
115
+ @depends_for_scopes[options] = depends
109
116
  end
110
117
  depends
111
118
  end
@@ -123,7 +130,7 @@ module Buildr
123
130
  hash
124
131
  }
125
132
  props = project["properties"].first rescue {}
126
- props = props.inject({}) { |mapped, pair| mapped[pair.first] = value_of(pair.last, pom) ; mapped }
133
+ props = props.inject({}) { |mapped, pair| mapped[pair.first] = value_of(pair.last, props) ; mapped }
127
134
  (parent ? parent.properties.merge(props) : props).merge(pom)
128
135
  end
129
136
  end
@@ -157,7 +164,8 @@ module Buildr
157
164
  # property substitution.
158
165
  def value_of(element, substitute = nil)
159
166
  value = element.to_a.join.strip
160
- substitute ? value.gsub(/\$\{([^}]+)\}/) { |key| substitute[$1] } : value
167
+ value = value.gsub(/\$\{([^}]+)\}/) { |key| Array(substitute[$1]).join.strip } if substitute
168
+ value
161
169
  end
162
170
 
163
171
  # :call-seq: