buildr 1.2.10 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. data/CHANGELOG +566 -268
  2. data/DISCLAIMER +7 -1
  3. data/KEYS +151 -0
  4. data/NOTICE +23 -8
  5. data/README +122 -22
  6. data/Rakefile +49 -229
  7. data/{lib → addon}/buildr/antlr.rb +23 -10
  8. data/addon/buildr/cobertura.rb +232 -0
  9. data/{lib → addon}/buildr/hibernate.rb +20 -4
  10. data/{lib → addon}/buildr/javacc.rb +27 -12
  11. data/addon/buildr/jdepend.rb +60 -0
  12. data/{lib → addon}/buildr/jetty.rb +34 -18
  13. data/addon/buildr/nailgun.rb +892 -0
  14. data/{lib → addon}/buildr/openjpa.rb +23 -6
  15. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  18. data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
  19. data/{lib → addon}/buildr/xmlbeans.rb +39 -14
  20. data/bin/buildr +21 -7
  21. data/buildr.gemspec +50 -0
  22. data/doc/css/default.css +225 -0
  23. data/doc/css/print.css +95 -0
  24. data/doc/css/syntax.css +43 -0
  25. data/doc/images/apache-incubator-logo.png +0 -0
  26. data/doc/images/buildr-hires.png +0 -0
  27. data/doc/images/buildr.png +0 -0
  28. data/doc/images/note.png +0 -0
  29. data/doc/images/tip.png +0 -0
  30. data/doc/images/zbuildr.tif +0 -0
  31. data/doc/pages/artifacts.textile +317 -0
  32. data/doc/pages/building.textile +501 -0
  33. data/doc/pages/contributing.textile +178 -0
  34. data/doc/pages/download.textile +25 -0
  35. data/doc/pages/extending.textile +229 -0
  36. data/doc/pages/getting_started.textile +337 -0
  37. data/doc/pages/index.textile +63 -0
  38. data/doc/pages/mailing_lists.textile +17 -0
  39. data/doc/pages/more_stuff.textile +367 -0
  40. data/doc/pages/packaging.textile +592 -0
  41. data/doc/pages/projects.textile +449 -0
  42. data/doc/pages/recipes.textile +127 -0
  43. data/doc/pages/settings_profiles.textile +339 -0
  44. data/doc/pages/testing.textile +475 -0
  45. data/doc/pages/troubleshooting.textile +121 -0
  46. data/doc/pages/whats_new.textile +389 -0
  47. data/doc/print.haml +52 -0
  48. data/doc/print.toc.yaml +28 -0
  49. data/doc/scripts/buildr-git.rb +411 -0
  50. data/doc/scripts/install-jruby.sh +44 -0
  51. data/doc/scripts/install-linux.sh +64 -0
  52. data/doc/scripts/install-osx.sh +52 -0
  53. data/doc/site.haml +55 -0
  54. data/doc/site.toc.yaml +44 -0
  55. data/lib/buildr.rb +28 -45
  56. data/lib/buildr/core.rb +27 -0
  57. data/lib/buildr/core/application.rb +373 -0
  58. data/lib/buildr/core/application_cli.rb +134 -0
  59. data/lib/{core → buildr/core}/build.rb +91 -77
  60. data/lib/{core → buildr/core}/checks.rb +116 -95
  61. data/lib/buildr/core/common.rb +155 -0
  62. data/lib/buildr/core/compile.rb +594 -0
  63. data/lib/buildr/core/environment.rb +120 -0
  64. data/lib/buildr/core/filter.rb +258 -0
  65. data/lib/{core → buildr/core}/generate.rb +22 -5
  66. data/lib/buildr/core/help.rb +118 -0
  67. data/lib/buildr/core/progressbar.rb +156 -0
  68. data/lib/{core → buildr/core}/project.rb +468 -213
  69. data/lib/buildr/core/test.rb +690 -0
  70. data/lib/{core → buildr/core}/transports.rb +107 -127
  71. data/lib/buildr/core/util.rb +235 -0
  72. data/lib/buildr/ide.rb +19 -0
  73. data/lib/{java → buildr/ide}/eclipse.rb +86 -60
  74. data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
  75. data/lib/buildr/ide/idea.rb +194 -0
  76. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  77. data/lib/buildr/ide/idea7x.rb +210 -0
  78. data/lib/buildr/java.rb +26 -0
  79. data/lib/buildr/java/ant.rb +71 -0
  80. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  81. data/lib/buildr/java/commands.rb +210 -0
  82. data/lib/buildr/java/compilers.rb +432 -0
  83. data/lib/buildr/java/deprecated.rb +141 -0
  84. data/lib/buildr/java/groovyc.rb +137 -0
  85. data/lib/buildr/java/jruby.rb +99 -0
  86. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  89. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  91. data/lib/buildr/java/packaging.rb +706 -0
  92. data/lib/{java → buildr/java}/pom.rb +20 -4
  93. data/lib/buildr/java/rjb.rb +142 -0
  94. data/lib/buildr/java/test_frameworks.rb +290 -0
  95. data/lib/buildr/java/version_requirement.rb +172 -0
  96. data/lib/buildr/packaging.rb +21 -0
  97. data/lib/{java → buildr/packaging}/artifact.rb +170 -179
  98. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  99. data/lib/buildr/packaging/artifact_search.rb +140 -0
  100. data/lib/buildr/packaging/gems.rb +102 -0
  101. data/lib/buildr/packaging/package.rb +233 -0
  102. data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
  103. data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
  104. data/rakelib/apache.rake +126 -0
  105. data/rakelib/changelog.rake +56 -0
  106. data/rakelib/doc.rake +103 -0
  107. data/rakelib/package.rake +44 -0
  108. data/rakelib/release.rake +53 -0
  109. data/rakelib/rspec.rake +81 -0
  110. data/rakelib/rubyforge.rake +45 -0
  111. data/rakelib/scm.rake +49 -0
  112. data/rakelib/setup.rake +59 -0
  113. data/rakelib/stage.rake +45 -0
  114. data/spec/application_spec.rb +316 -0
  115. data/spec/archive_spec.rb +494 -0
  116. data/spec/artifact_namespace_spec.rb +635 -0
  117. data/spec/artifact_spec.rb +738 -0
  118. data/spec/build_spec.rb +193 -0
  119. data/spec/checks_spec.rb +537 -0
  120. data/spec/common_spec.rb +579 -0
  121. data/spec/compile_spec.rb +561 -0
  122. data/spec/groovy_compilers_spec.rb +239 -0
  123. data/spec/java_bdd_frameworks_spec.rb +238 -0
  124. data/spec/java_compilers_spec.rb +446 -0
  125. data/spec/java_packaging_spec.rb +1042 -0
  126. data/spec/java_test_frameworks_spec.rb +414 -0
  127. data/spec/packaging_helper.rb +63 -0
  128. data/spec/packaging_spec.rb +589 -0
  129. data/spec/project_spec.rb +739 -0
  130. data/spec/sandbox.rb +116 -0
  131. data/spec/scala_compilers_spec.rb +239 -0
  132. data/spec/spec.opts +6 -0
  133. data/spec/spec_helpers.rb +283 -0
  134. data/spec/test_spec.rb +871 -0
  135. data/spec/transport_spec.rb +300 -0
  136. data/spec/version_requirement_spec.rb +115 -0
  137. metadata +188 -77
  138. data/lib/buildr/cobertura.rb +0 -89
  139. data/lib/buildr/jdepend.rb +0 -40
  140. data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
  141. data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
  142. data/lib/buildr/jetty/JettyWrapper.class +0 -0
  143. data/lib/buildr/scala.rb +0 -368
  144. data/lib/core/application.rb +0 -188
  145. data/lib/core/common.rb +0 -562
  146. data/lib/core/help.rb +0 -72
  147. data/lib/core/rake_ext.rb +0 -81
  148. data/lib/java/ant.rb +0 -71
  149. data/lib/java/compile.rb +0 -589
  150. data/lib/java/idea.rb +0 -159
  151. data/lib/java/java.rb +0 -432
  152. data/lib/java/packaging.rb +0 -581
  153. data/lib/java/test.rb +0 -795
  154. data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,26 @@
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
+
17
+ ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.framework/Home' if Config::CONFIG['host_os'] =~ /darwin/i
18
+ require PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
19
+
20
+
21
+ require 'buildr/java/compilers'
22
+ require 'buildr/java/test_frameworks'
23
+ require 'buildr/java/bdd_frameworks'
24
+ require 'buildr/java/packaging'
25
+ require 'buildr/java/commands'
26
+ require 'buildr/java/deprecated'
@@ -0,0 +1,71 @@
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
+
17
+ require 'antwrap'
18
+ require 'buildr/core/project'
19
+ require 'buildr/core/help'
20
+
21
+
22
+ module Buildr
23
+ module Ant
24
+
25
+ # Which version of Ant we're using by default.
26
+ VERSION = '1.7.0' unless const_defined?('VERSION')
27
+
28
+ # Libraries used by Ant.
29
+ REQUIRES = [ "org.apache.ant:ant:jar:#{VERSION}", "org.apache.ant:ant-launcher:jar:#{VERSION}", 'xerces:xercesImpl:jar:2.6.2' ]
30
+ Java.classpath << REQUIRES
31
+
32
+ # :call-seq:
33
+ # ant(name) { |AntProject| ... } => AntProject
34
+ #
35
+ # Creates a new AntProject with the specified name, yield to the block for defining various
36
+ # Ant tasks, and executes each task as it's defined.
37
+ #
38
+ # For example:
39
+ # ant("hibernatedoclet') do |doclet|
40
+ # doclet.taskdef :name=>'hibernatedoclet',
41
+ # :classname=>'xdoclet.modules.hibernate.HibernateDocletTask', :classpath=>DOCLET
42
+ # doclet.hibernatedoclet :destdir=>dest_dir, :force=>'true' do
43
+ # hibernate :version=>'3.0'
44
+ # fileset :dir=>source, :includes=>'**/*.java'
45
+ # end
46
+ # end
47
+ def ant(name, &block)
48
+ options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
49
+ options.merge!(:logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG) if Buildr.application.options.trace
50
+ Java.load
51
+ Antwrap::AntProject.new(options).tap do |project|
52
+ # Set Ant logging level to debug (--trace), info (default) or error only (--quiet).
53
+ project.project.getBuildListeners().get(0).
54
+ setMessageOutputLevel((Buildr.application.options.trace && 4) || (verbose && 2) || 0)
55
+ yield project if block_given?
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ include Ant
62
+ class Project
63
+ include Ant
64
+ end
65
+
66
+ Buildr.help do
67
+ Java.load
68
+ "\nUsing Java #{ENV_JAVA['java.version']}, Ant #{Ant::VERSION}."
69
+ end
70
+
71
+ end
@@ -0,0 +1,267 @@
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
+
17
+ require 'buildr/java/test_frameworks'
18
+
19
+
20
+ module Buildr
21
+
22
+ # Mixin for test frameworks using src/spec/{lang}
23
+ module TestFramework::JavaBDD #:nodoc:
24
+
25
+ class << self
26
+ def included(mod)
27
+ mod.module_eval do
28
+ include TestFramework::JavaTest
29
+ include ClassMethods
30
+ end
31
+ mod.extend ClassMethods
32
+ mod.bdd_dir = :spec
33
+ mod.lang = :java
34
+ super
35
+ end
36
+ end
37
+
38
+ module ClassMethods
39
+ attr_accessor :lang, :bdd_dir
40
+ end
41
+
42
+ def initialize(task, options)
43
+ self.bdd_dir = self.class.bdd_dir
44
+ project = task.project
45
+ project.task('test:compile').tap do |comp|
46
+ comp.send :associate_with, project, bdd_dir
47
+ self.lang = comp.language || self.class.lang
48
+ end
49
+ project.task('test:resources').tap do |res|
50
+ res.send :associate_with, project, bdd_dir
51
+ res.filter.clear
52
+ project.path_to(:source, bdd_dir, :resources).tap { |dir| resources.from dir if File.exist?(dir) }
53
+ end
54
+ super
55
+ end
56
+ end
57
+
58
+ class RSpec < TestFramework::Base
59
+ include TestFramework::JavaBDD
60
+ self.lang = :ruby
61
+
62
+ REQUIRES = ['org.jruby:jruby-complete:jar:1.1']
63
+ TESTS_PATTERN = [ /_spec.rb$/ ]
64
+ OPTIONS = [:properties, :java_args]
65
+
66
+ def self.applies_to?(project) #:nodoc:
67
+ !Dir[project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].empty?
68
+ end
69
+
70
+ def tests(dependencies) #:nodoc:
71
+ Dir[task.project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].
72
+ select do |name|
73
+ selector = ENV['SPEC']
74
+ selector.nil? || Regexp.new(selector) === name
75
+ end
76
+ end
77
+
78
+ def run(tests, dependencies) #:nodoc:
79
+ cmd_options = task.options.only(:properties, :java_args)
80
+ cmd_options.update :classpath => dependencies, :project => task.project
81
+ # TODO: Setting up JRuby is something to do before running Buildr.
82
+ #install_gems(cmd_options)
83
+
84
+ report_dir = task.report_to.to_s
85
+ FileUtils.rm_rf report_dir
86
+ ENV['CI_REPORTS'] = report_dir
87
+
88
+ jruby("-Ilib", "-S", "spec",
89
+ #"--require", gem_path(task.project, "ci_reporter", "lib/ci/reporter/rake/rspec_loader"),
90
+ "--require", "ci/reporter/rake/rspec_loader",
91
+ "--format", "CI::Reporter::RSpecDoc", tests,
92
+ cmd_options.merge({:name => "RSpec"}))
93
+ tests
94
+ end
95
+
96
+ private
97
+ def jruby_home(project)
98
+ @jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] : File.expand_path(".jruby", ENV['HOME'])
99
+ end
100
+
101
+ def gem_path(project, gem_name, *additional)
102
+ dir = Dir["#{jruby_home(project)}/lib/ruby/gems/1.8/gems/#{gem_name}*"].to_a.first
103
+ dir = File.join(dir, *additional) unless additional.empty?
104
+ dir
105
+ end
106
+
107
+ def required_gems(options)
108
+ ["ci_reporter", options[:required_gems]].flatten.compact
109
+ end
110
+
111
+ def jruby(*args)
112
+ java_args = ["org.jruby.Main", *args]
113
+ java_args << {} unless Hash === args.last
114
+ cmd_options = java_args.last
115
+ project = cmd_options.delete(:project)
116
+ if RUBY_PLATFORM =~ /java/
117
+ # when run from within JRuby, use jars in launched-JRuby's classpath rather than the
118
+ # stated dependency
119
+ cmd_options[:classpath].delete_if {|e| File.basename(e) =~ /^jruby-complete-.*\.jar$/ }
120
+ cmd_options[:classpath].unshift *(java.lang.System.getProperty("java.class.path").split(File::PATH_SEPARATOR))
121
+ end
122
+ cmd_options[:java_args] ||= []
123
+ cmd_options[:java_args] << "-Xmx512m" unless cmd_options[:java_args].detect {|a| a =~ /^-Xmx/}
124
+ cmd_options[:properties] ||= {}
125
+ cmd_options[:properties]["jruby.home"] = jruby_home(project)
126
+ Java::Commands.java(*java_args)
127
+ end
128
+
129
+ #def install_gems(options)
130
+ # unless required_gems(options).all? {|g| gem_path(options[:project], g)}
131
+ # args = ["-S", "maybe_install_gems", *required_gems(options)]
132
+ # args << {:name => "JRuby Setup"}.merge(options)
133
+ # jruby(*args)
134
+ # end
135
+ #end
136
+
137
+ end
138
+
139
+ class JtestR < TestFramework::Base
140
+ include TestFramework::JavaBDD
141
+ self.lang = :ruby
142
+ end
143
+
144
+ # JBehave is a Java BDD framework. To use in your project:
145
+ # test.using :jbehave
146
+ #
147
+ # This framework will search in your project for:
148
+ # src/spec/java/**/*Behaviour.java
149
+ #
150
+ # JMock libraries are included on runtime.
151
+ #
152
+ # Support the following options:
153
+ # * :properties -- Hash of properties to the test suite
154
+ # * :java_args -- Arguments passed to the JVM
155
+ class JBehave < TestFramework::Base
156
+ include TestFramework::JavaBDD
157
+
158
+ VERSION = "1.0.1" unless const_defined?('VERSION')
159
+ REQUIRES = ["org.jbehave:jbehave:jar:#{VERSION}",
160
+ "jmock:jmock-cglib:jar:#{JMock::VERSION}",
161
+ "cglib:cglib-full:jar:2.0.2",
162
+ ] + JUnit::REQUIRES
163
+ TESTS_PATTERN = [ /Behaviou?r$/ ]
164
+
165
+ def self.applies_to?(project) #:nodoc:
166
+ %w{
167
+ **/*Behaviour.java **/*Behavior.java
168
+ }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
169
+ end
170
+
171
+ def tests(dependencies) #:nodoc:
172
+ filter_classes(dependencies, :class_names => TESTS_PATTERN,
173
+ :interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
174
+ end
175
+
176
+ def run(tests, dependencies) #:nodoc:
177
+ cmd_args = ['org.jbehave.core.BehaviourRunner']
178
+ cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
179
+ tests.inject([]) do |passed, test|
180
+ begin
181
+ Java::Commands.java cmd_args, test, cmd_options
182
+ passed << test
183
+ rescue
184
+ passed
185
+ end
186
+ end
187
+ end
188
+
189
+ end
190
+
191
+ # EasyB is a Groovy based BDD framework.
192
+ # To use in your project:
193
+ #
194
+ # test.using :easyb
195
+ #
196
+ # This framework will search in your project for:
197
+ # src/spec/groovy/**/*Story.groovy
198
+ # src/spec/groovy/**/*Behavior.groovy
199
+ #
200
+ # Support the following options:
201
+ # * :format -- Report format :txt or :xml, default is :txt
202
+ # * :properties -- Hash of properties passed to the test suite.
203
+ # * :java_args -- Arguments passed to the JVM.
204
+ class EasyB < TestFramework::Base
205
+ include TestFramework::JavaBDD
206
+ self.lang = :groovy
207
+
208
+ VERSION = "0.7" unless const_defined?(:VERSION)
209
+ REQUIRES = ["org.easyb:easyb:jar:#{VERSION}",
210
+ 'org.codehaus.groovy:groovy:jar:1.5.3',
211
+ 'asm:asm:jar:2.2.3',
212
+ 'commons-cli:commons-cli:jar:1.0',
213
+ 'antlr:antlr:jar:2.7.7']
214
+ TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
215
+ OPTIONS = [:format, :properties, :java_args]
216
+
217
+ def self.applies_to?(project) #:nodoc:
218
+ %w{
219
+ **/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
220
+ }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
221
+ end
222
+
223
+ def tests(dependencies) #:nodoc:
224
+ Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
225
+ select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
226
+ end
227
+
228
+ def run(tests, dependencies) #:nodoc:
229
+ options = { :format => :txt }.merge(self.options).only(*OPTIONS)
230
+
231
+ if :txt == options[:format]
232
+ easyb_format, ext = 'txtstory', '.txt'
233
+ elsif :xml == options[:format]
234
+ easyb_format, ext = 'xmlbehavior', '.xml'
235
+ else
236
+ raise "Invalid format #{options[:format]} expected one of :txt :xml"
237
+ end
238
+
239
+ cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
240
+ cmd_options = { :properties => options[:properties],
241
+ :java_args => options[:java_args],
242
+ :classpath => dependencies }
243
+
244
+ tests.inject([]) do |passed, test|
245
+ name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
246
+ report = File.join(task.report_to.to_s, name + ext)
247
+ mkpath report.pathmap('%d'), :verbose => false
248
+ begin
249
+ Java::Commands.java cmd_args,
250
+ "-#{easyb_format}", report,
251
+ test, cmd_options.merge(:name => name)
252
+ rescue => e
253
+ passed
254
+ else
255
+ passed << test
256
+ end
257
+ end
258
+ end
259
+
260
+ end # EasyB
261
+
262
+ end
263
+
264
+ Buildr::TestFramework << Buildr::RSpec
265
+ Buildr::TestFramework << Buildr::JtestR
266
+ Buildr::TestFramework << Buildr::JBehave
267
+ Buildr::TestFramework << Buildr::EasyB
@@ -0,0 +1,210 @@
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
+
17
+ # Base module for all things Java.
18
+ module Java
19
+
20
+ # JDK commands: java, javac, javadoc, etc.
21
+ module Commands
22
+
23
+ class << self
24
+
25
+ # :call-seq:
26
+ # java(class, *args, options?)
27
+ #
28
+ # Runs Java with the specified arguments.
29
+ #
30
+ # The last argument may be a Hash with additional options:
31
+ # * :classpath -- One or more file names, tasks or artifact specifications.
32
+ # These are all expanded into artifacts, and all tasks are invoked.
33
+ # * :java_args -- Any additional arguments to pass (e.g. -hotspot, -xms)
34
+ # * :properties -- Hash of system properties (e.g. 'path'=>base_dir).
35
+ # * :name -- Shows this name, otherwise shows the first argument (the class name).
36
+ # * :verbose -- If true, prints the command and all its argument.
37
+ def java(*args, &block)
38
+ options = Hash === args.last ? args.pop : {}
39
+ options[:verbose] ||= Buildr.application.options.trace || false
40
+ rake_check_options options, :classpath, :java_args, :properties, :name, :verbose
41
+
42
+ name = options[:name] || "java #{args.first}"
43
+ cmd_args = [path_to_bin('java')]
44
+ classpath = classpath_from(options)
45
+ cmd_args << '-classpath' << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
46
+ options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]
47
+ cmd_args += (options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split).flatten
48
+ cmd_args += args.flatten.compact
49
+ unless Buildr.application.options.dryrun
50
+ puts "Running #{name}" if verbose
51
+ block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
52
+ puts cmd_args.join(' ') if Buildr.application.options.trace
53
+ system(*cmd_args).tap do |ok|
54
+ block.call ok, $?
55
+ end
56
+ end
57
+ end
58
+
59
+ # :call-seq:
60
+ # apt(*files, options)
61
+ #
62
+ # Runs Apt with the specified arguments.
63
+ #
64
+ # The last argument may be a Hash with additional options:
65
+ # * :compile -- If true, compile source files to class files.
66
+ # * :source -- Specifies source compatibility with a given JVM release.
67
+ # * :output -- Directory where to place the generated source files, or the
68
+ # generated class files when compiling.
69
+ # * :classpath -- One or more file names, tasks or artifact specifications.
70
+ # These are all expanded into artifacts, and all tasks are invoked.
71
+ def apt(*args)
72
+ options = Hash === args.last ? args.pop : {}
73
+ rake_check_options options, :compile, :source, :output, :classpath
74
+
75
+ files = args.flatten.map(&:to_s).
76
+ collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
77
+ cmd_args = [ Buildr.application.options.trace ? '-verbose' : '-nowarn' ]
78
+ if options[:compile]
79
+ cmd_args << '-d' << options[:output].to_s
80
+ else
81
+ cmd_args << '-nocompile' << '-s' << options[:output].to_s
82
+ end
83
+ cmd_args << '-source' << options[:source] if options[:source]
84
+ classpath = classpath_from(options)
85
+ tools = File.expand_path('lib/tools.jar', ENV['JAVA_HOME']) if ENV['JAVA_HOME']
86
+ classpath << tools if tools && File.exist?(tools)
87
+ cmd_args << '-classpath' << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
88
+ cmd_args += files
89
+ unless Buildr.application.options.dryrun
90
+ puts 'Running apt' if verbose
91
+ puts (['apt'] + cmd_args).join(' ') if Buildr.application.options.trace
92
+ Java.load
93
+ Java.com.sun.tools.apt.Main.process(cmd_args.to_java(Java.java.lang.String)) == 0 or
94
+ fail 'Failed to process annotations, see errors above'
95
+ end
96
+ end
97
+
98
+ # :call-seq:
99
+ # javac(*files, options)
100
+ #
101
+ # Runs Javac with the specified arguments.
102
+ #
103
+ # The last argument may be a Hash with additional options:
104
+ # * :output -- Target directory for all compiled class files.
105
+ # * :classpath -- One or more file names, tasks or artifact specifications.
106
+ # These are all expanded into artifacts, and all tasks are invoked.
107
+ # * :sourcepath -- Additional source paths to use.
108
+ # * :javac_args -- Any additional arguments to pass (e.g. -extdirs, -encoding)
109
+ # * :name -- Shows this name, otherwise shows the working directory.
110
+ def javac(*args)
111
+ options = Hash === args.last ? args.pop : {}
112
+ rake_check_options options, :classpath, :sourcepath, :output, :javac_args, :name
113
+
114
+ files = args.flatten.each { |f| f.invoke if f.respond_to?(:invoke) }.map(&:to_s).
115
+ collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
116
+ name = options[:name] || Dir.pwd
117
+
118
+ cmd_args = []
119
+ classpath = classpath_from(options)
120
+ cmd_args << '-classpath' << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
121
+ cmd_args << '-sourcepath' << options[:sourcepath].join(File::PATH_SEPARATOR) if options[:sourcepath]
122
+ cmd_args << '-d' << options[:output].to_s if options[:output]
123
+ cmd_args += options[:javac_args].flatten if options[:javac_args]
124
+ cmd_args += files
125
+ unless Buildr.application.options.dryrun
126
+ puts "Compiling #{files.size} source files in #{name}" if verbose
127
+ puts (['javac'] + cmd_args).join(' ') if Buildr.application.options.trace
128
+ Java.load
129
+ Java.com.sun.tools.javac.Main.compile(cmd_args.to_java(Java.java.lang.String)) == 0 or
130
+ fail 'Failed to compile, see errors above'
131
+ end
132
+ end
133
+
134
+ # :call-seq:
135
+ # javadoc(*files, options)
136
+ #
137
+ # Runs Javadocs with the specified files and options.
138
+ #
139
+ # This method accepts the following special options:
140
+ # * :output -- The output directory
141
+ # * :classpath -- Array of classpath dependencies.
142
+ # * :sourcepath -- Array of sourcepaths (paths or tasks).
143
+ # * :name -- Shows this name, otherwise shows the working directory.
144
+ #
145
+ # All other options are passed to Javadoc as following:
146
+ # * true -- As is, for example, :author=>true becomes -author
147
+ # * false -- Prefixed, for example, :index=>false becomes -noindex
148
+ # * string -- Option with value, for example, :windowtitle=>'My project' becomes -windowtitle "My project"
149
+ # * array -- Option with set of values separated by spaces.
150
+ def javadoc(*args)
151
+ options = Hash === args.last ? args.pop : {}
152
+
153
+ cmd_args = [ '-d', options[:output], Buildr.application.options.trace ? '-verbose' : '-quiet' ]
154
+ options.reject { |key, value| [:output, :name, :sourcepath, :classpath].include?(key) }.
155
+ each { |key, value| value.invoke if value.respond_to?(:invoke) }.
156
+ each do |key, value|
157
+ case value
158
+ when true, nil
159
+ cmd_args << "-#{key}"
160
+ when false
161
+ cmd_args << "-no#{key}"
162
+ when Hash
163
+ value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
164
+ else
165
+ cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
166
+ end
167
+ end
168
+ [:sourcepath, :classpath].each do |option|
169
+ options[option].to_a.flatten.tap do |paths|
170
+ cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
171
+ end
172
+ end
173
+ cmd_args += args.flatten.uniq
174
+ name = options[:name] || Dir.pwd
175
+ unless Buildr.application.options.dryrun
176
+ puts "Generating Javadoc for #{name}" if verbose
177
+ puts (['javadoc'] + cmd_args).join(' ') if Buildr.application.options.trace
178
+ Java.load
179
+ Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or
180
+ fail 'Failed to generate Javadocs, see errors above'
181
+ end
182
+ end
183
+
184
+ protected
185
+
186
+ # :call-seq:
187
+ # path_to_bin(cmd?) => path
188
+ #
189
+ # Returns the path to the specified Java command (with no argument to java itself).
190
+ def path_to_bin(name = nil)
191
+ home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'
192
+ File.expand_path(File.join(home, 'bin', name.to_s))
193
+ end
194
+
195
+ # :call-seq:
196
+ # classpath_from(options) => files
197
+ #
198
+ # Extracts the classpath from the options, expands it by calling artifacts, invokes
199
+ # each of the artifacts and returns an array of paths.
200
+ def classpath_from(options)
201
+ Buildr.artifacts(options[:classpath] || []).map(&:to_s).
202
+ map { |t| task(t).invoke; File.expand_path(t) }
203
+ end
204
+
205
+ end
206
+
207
+ end
208
+
209
+ end
210
+