assaf-buildr 1.3.3

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 (163) hide show
  1. data/CHANGELOG +887 -0
  2. data/DISCLAIMER +7 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.rdoc +146 -0
  6. data/Rakefile +62 -0
  7. data/_buildr +38 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +236 -0
  10. data/addon/buildr/emma.rb +238 -0
  11. data/addon/buildr/hibernate.rb +142 -0
  12. data/addon/buildr/javacc.rb +85 -0
  13. data/addon/buildr/jdepend.rb +60 -0
  14. data/addon/buildr/jetty.rb +248 -0
  15. data/addon/buildr/jibx.rb +86 -0
  16. data/addon/buildr/nailgun.rb +817 -0
  17. data/addon/buildr/openjpa.rb +90 -0
  18. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  21. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  25. data/addon/buildr/xmlbeans.rb +93 -0
  26. data/bin/buildr +28 -0
  27. data/buildr.buildfile +53 -0
  28. data/buildr.gemspec +58 -0
  29. data/doc/css/default.css +228 -0
  30. data/doc/css/print.css +100 -0
  31. data/doc/css/syntax.css +52 -0
  32. data/doc/images/apache-incubator-logo.png +0 -0
  33. data/doc/images/buildr-hires.png +0 -0
  34. data/doc/images/buildr.png +0 -0
  35. data/doc/images/favicon.png +0 -0
  36. data/doc/images/growl-icon.tiff +0 -0
  37. data/doc/images/note.png +0 -0
  38. data/doc/images/project-structure.png +0 -0
  39. data/doc/images/tip.png +0 -0
  40. data/doc/images/zbuildr.tif +0 -0
  41. data/doc/pages/artifacts.textile +207 -0
  42. data/doc/pages/building.textile +240 -0
  43. data/doc/pages/contributing.textile +208 -0
  44. data/doc/pages/download.textile +62 -0
  45. data/doc/pages/extending.textile +175 -0
  46. data/doc/pages/getting_started.textile +273 -0
  47. data/doc/pages/index.textile +42 -0
  48. data/doc/pages/languages.textile +407 -0
  49. data/doc/pages/mailing_lists.textile +17 -0
  50. data/doc/pages/more_stuff.textile +286 -0
  51. data/doc/pages/packaging.textile +427 -0
  52. data/doc/pages/projects.textile +274 -0
  53. data/doc/pages/recipes.textile +103 -0
  54. data/doc/pages/settings_profiles.textile +274 -0
  55. data/doc/pages/testing.textile +212 -0
  56. data/doc/pages/troubleshooting.textile +103 -0
  57. data/doc/pages/whats_new.textile +323 -0
  58. data/doc/print.haml +51 -0
  59. data/doc/print.toc.yaml +29 -0
  60. data/doc/scripts/buildr-git.rb +412 -0
  61. data/doc/scripts/install-jruby.sh +44 -0
  62. data/doc/scripts/install-linux.sh +64 -0
  63. data/doc/scripts/install-osx.sh +52 -0
  64. data/doc/site.haml +56 -0
  65. data/doc/site.toc.yaml +47 -0
  66. data/etc/KEYS +151 -0
  67. data/etc/git-svn-authors +16 -0
  68. data/lib/buildr.rb +35 -0
  69. data/lib/buildr/core.rb +27 -0
  70. data/lib/buildr/core/application.rb +489 -0
  71. data/lib/buildr/core/application_cli.rb +139 -0
  72. data/lib/buildr/core/build.rb +311 -0
  73. data/lib/buildr/core/checks.rb +382 -0
  74. data/lib/buildr/core/common.rb +154 -0
  75. data/lib/buildr/core/compile.rb +596 -0
  76. data/lib/buildr/core/environment.rb +120 -0
  77. data/lib/buildr/core/filter.rb +362 -0
  78. data/lib/buildr/core/generate.rb +195 -0
  79. data/lib/buildr/core/help.rb +118 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +892 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +558 -0
  84. data/lib/buildr/core/util.rb +289 -0
  85. data/lib/buildr/groovy.rb +18 -0
  86. data/lib/buildr/groovy/bdd.rb +105 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/ide.rb +19 -0
  89. data/lib/buildr/ide/eclipse.rb +212 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +189 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +210 -0
  94. data/lib/buildr/java.rb +23 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +449 -0
  97. data/lib/buildr/java/commands.rb +211 -0
  98. data/lib/buildr/java/compiler.rb +348 -0
  99. data/lib/buildr/java/deprecated.rb +141 -0
  100. data/lib/buildr/java/jruby.rb +117 -0
  101. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  102. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  103. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  104. data/lib/buildr/java/packaging.rb +713 -0
  105. data/lib/buildr/java/pom.rb +178 -0
  106. data/lib/buildr/java/rjb.rb +155 -0
  107. data/lib/buildr/java/test_result.rb +308 -0
  108. data/lib/buildr/java/tests.rb +324 -0
  109. data/lib/buildr/java/version_requirement.rb +172 -0
  110. data/lib/buildr/packaging.rb +21 -0
  111. data/lib/buildr/packaging/artifact.rb +730 -0
  112. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  113. data/lib/buildr/packaging/artifact_search.rb +140 -0
  114. data/lib/buildr/packaging/gems.rb +102 -0
  115. data/lib/buildr/packaging/package.rb +233 -0
  116. data/lib/buildr/packaging/tar.rb +104 -0
  117. data/lib/buildr/packaging/zip.rb +722 -0
  118. data/lib/buildr/resources/buildr.icns +0 -0
  119. data/lib/buildr/scala.rb +19 -0
  120. data/lib/buildr/scala/compiler.rb +109 -0
  121. data/lib/buildr/scala/tests.rb +203 -0
  122. data/rakelib/apache.rake +191 -0
  123. data/rakelib/changelog.rake +57 -0
  124. data/rakelib/doc.rake +103 -0
  125. data/rakelib/package.rake +73 -0
  126. data/rakelib/release.rake +65 -0
  127. data/rakelib/rspec.rake +83 -0
  128. data/rakelib/rubyforge.rake +53 -0
  129. data/rakelib/scm.rake +49 -0
  130. data/rakelib/setup.rake +86 -0
  131. data/rakelib/stage.rake +48 -0
  132. data/spec/addon/cobertura_spec.rb +77 -0
  133. data/spec/addon/emma_spec.rb +120 -0
  134. data/spec/addon/test_coverage_spec.rb +255 -0
  135. data/spec/core/application_spec.rb +412 -0
  136. data/spec/core/artifact_namespace_spec.rb +646 -0
  137. data/spec/core/build_spec.rb +415 -0
  138. data/spec/core/checks_spec.rb +537 -0
  139. data/spec/core/common_spec.rb +664 -0
  140. data/spec/core/compile_spec.rb +566 -0
  141. data/spec/core/generate_spec.rb +33 -0
  142. data/spec/core/project_spec.rb +754 -0
  143. data/spec/core/test_spec.rb +1091 -0
  144. data/spec/core/transport_spec.rb +500 -0
  145. data/spec/groovy/bdd_spec.rb +80 -0
  146. data/spec/groovy/compiler_spec.rb +239 -0
  147. data/spec/ide/eclipse_spec.rb +243 -0
  148. data/spec/java/ant.rb +28 -0
  149. data/spec/java/bdd_spec.rb +358 -0
  150. data/spec/java/compiler_spec.rb +446 -0
  151. data/spec/java/java_spec.rb +88 -0
  152. data/spec/java/packaging_spec.rb +1103 -0
  153. data/spec/java/tests_spec.rb +466 -0
  154. data/spec/packaging/archive_spec.rb +503 -0
  155. data/spec/packaging/artifact_spec.rb +754 -0
  156. data/spec/packaging/packaging_helper.rb +63 -0
  157. data/spec/packaging/packaging_spec.rb +589 -0
  158. data/spec/sandbox.rb +137 -0
  159. data/spec/scala/compiler_spec.rb +228 -0
  160. data/spec/scala/tests_spec.rb +215 -0
  161. data/spec/spec_helpers.rb +304 -0
  162. data/spec/version_requirement_spec.rb +123 -0
  163. metadata +369 -0
@@ -0,0 +1,289 @@
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 'rbconfig'
18
+ require 'pathname'
19
+ require 'builder' # A different kind of buildr, one we use to create XML.
20
+
21
+
22
+ module Buildr
23
+
24
+ module Util
25
+ extend self
26
+
27
+ def java_platform?
28
+ RUBY_PLATFORM =~ /java/
29
+ end
30
+
31
+ # In order to determine if we are running on a windows OS,
32
+ # prefer this function instead of using Gem.win_platform?.
33
+ #
34
+ # Gem.win_platform? only checks the RUBY_PLATFORM global,
35
+ # that in some cases like when running on JRuby is not
36
+ # succifient for our purpose:
37
+ #
38
+ # For JRuby, the value for RUBY_PLATFORM will always be 'java'
39
+ # That's why this function checks on Config::CONFIG['host_os']
40
+ def win_os?
41
+ Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
42
+ end
43
+
44
+ # Runs Ruby with these command line arguments. The last argument may be a hash,
45
+ # supporting the following keys:
46
+ # :command -- Runs the specified script (e.g., :command=>'gem')
47
+ # :sudo -- Run as sudo on operating systems that require it.
48
+ # :verbose -- Override Rake's verbose flag.
49
+ def ruby(*args)
50
+ options = Hash === args.last ? args.pop : {}
51
+ cmd = []
52
+ ruby_bin = File.expand_path(Config::CONFIG['ruby_install_name'], Config::CONFIG['bindir'])
53
+ if options.delete(:sudo) && !(win_os? || Process.uid == File.stat(ruby_bin).uid)
54
+ cmd << 'sudo' << '-u' << "##{File.stat(ruby_bin).uid}"
55
+ end
56
+ cmd << ruby_bin
57
+ cmd << '-S' << options.delete(:command) if options[:command]
58
+ sh *cmd.push(*args.flatten).push(options) do |ok, status|
59
+ ok or fail "Command failed with status (#{status ? status.exitstatus : 'unknown'}): [#{cmd.join(" ")}]"
60
+ end
61
+ end
62
+
63
+ # Just like File.expand_path, but for windows systems it
64
+ # capitalizes the drive name and ensures backslashes are used
65
+ def normalize_path(path, *dirs)
66
+ path = File.expand_path(path, *dirs)
67
+ if win_os?
68
+ path.gsub!('/', '\\').gsub!(/^[a-zA-Z]+:/) { |s| s.upcase }
69
+ else
70
+ path
71
+ end
72
+ end
73
+
74
+ # Return the timestamp of file, without having to create a file task
75
+ def timestamp(file)
76
+ if File.exist?(file)
77
+ File.mtime(file)
78
+ else
79
+ Rake::EARLY
80
+ end
81
+ end
82
+
83
+ # Return the path to the first argument, starting from the path provided by the
84
+ # second argument.
85
+ #
86
+ # For example:
87
+ # relative_path('foo/bar', 'foo')
88
+ # => 'bar'
89
+ # relative_path('foo/bar', 'baz')
90
+ # => '../foo/bar'
91
+ # relative_path('foo/bar')
92
+ # => 'foo/bar'
93
+ # relative_path('/foo/bar', 'baz')
94
+ # => '/foo/bar'
95
+ def relative_path(to, from = '.')
96
+ to = Pathname.new(to).cleanpath
97
+ return to.to_s if from.nil?
98
+ to_path = Pathname.new(File.expand_path(to.to_s, "/"))
99
+ from_path = Pathname.new(File.expand_path(from.to_s, "/"))
100
+ to_path.relative_path_from(from_path).to_s
101
+ end
102
+
103
+ # Generally speaking, it's not a good idea to operate on dot files (files starting with dot).
104
+ # These are considered invisible files (.svn, .hg, .irbrc, etc). Dir.glob/FileList ignore them
105
+ # on purpose. There are few cases where we do have to work with them (filter, zip), a better
106
+ # solution is welcome, maybe being more explicit with include. For now, this will do.
107
+ def recursive_with_dot_files(*dirs)
108
+ FileList[dirs.map { |dir| File.join(dir, '/**/{*,.*}') }].reject { |file| File.basename(file) =~ /^[.]{1,2}$/ }
109
+ end
110
+
111
+ # Utility methods for running gem commands
112
+ module Gems
113
+ extend self
114
+
115
+ # Install gems specified by each Gem::Dependency if they are missing. This method prompts the user
116
+ # for permission before installing anything.
117
+ #
118
+ # Returns the installed Gem::Dependency objects or fails if permission not granted or when buildr
119
+ # is not running interactively (on a tty)
120
+ def install(*dependencies)
121
+ raise ArgumentError, "Expected at least one argument" if dependencies.empty?
122
+ remote = dependencies.map { |dep| Gem::SourceInfoCache.search(dep).last || dep }
123
+ not_found_deps, to_install = remote.partition { |gem| gem.is_a?(Gem::Dependency) }
124
+ fail Gem::LoadError, "Build requires the gems #{not_found_deps.join(', ')}, which cannot be found in local or remote repository." unless not_found_deps.empty?
125
+ uses = "This build requires the gems #{to_install.map(&:full_name).join(', ')}:"
126
+ fail Gem::LoadError, "#{uses} to install, run Buildr interactively." unless $stdout.isatty
127
+ unless agree("#{uses} do you want me to install them? [Y/n]", true)
128
+ fail Gem::LoadError, 'Cannot build without these gems.'
129
+ end
130
+ to_install.each do |spec|
131
+ say "Installing #{spec.full_name} ... " if verbose
132
+ command 'install', spec.name, '-v', spec.version.to_s, :verbose => false
133
+ Gem.source_index.load_gems_in Gem::SourceIndex.installed_spec_directories
134
+ end
135
+ to_install
136
+ end
137
+
138
+ # Execute a GemRunner command
139
+ def command(cmd, *args)
140
+ options = Hash === args.last ? args.pop : {}
141
+ gem_home = ENV['GEM_HOME'] || Gem.path.find { |f| File.writable?(f) }
142
+ options[:sudo] = :root unless Util.win_os? || gem_home
143
+ options[:command] = 'gem'
144
+ args << options
145
+ args.unshift '-i', gem_home if cmd == 'install' && gem_home && !args.any?{ |a| a[/-i|--install-dir/] }
146
+ Util.ruby cmd, *args
147
+ end
148
+
149
+ end # Gems
150
+
151
+ end # Util
152
+ end
153
+
154
+
155
+ if RUBY_VERSION < '1.9.0'
156
+ module Kernel #:nodoc:
157
+ # Borrowed from Ruby 1.9.
158
+ def tap
159
+ yield self if block_given?
160
+ self
161
+ end unless method_defined?('tap')
162
+ end
163
+
164
+
165
+ class Symbol #:nodoc:
166
+ # Borrowed from Ruby 1.9.
167
+ def to_proc
168
+ Proc.new{|*args| args.shift.__send__(self, *args)}
169
+ end unless method_defined?('to_proc')
170
+ end
171
+
172
+ # Also borrowed from Ruby 1.9.
173
+ class BasicObject #:nodoc:
174
+ (instance_methods - ['__send__', '__id__', '==', 'send', 'send!', 'respond_to?', 'equal?', 'object_id']).
175
+ each do |method|
176
+ undef_method method
177
+ end
178
+
179
+ def self.ancestors
180
+ [Kernel]
181
+ end
182
+ end
183
+ end
184
+
185
+
186
+ class OpenObject < Hash
187
+
188
+ def initialize(source=nil, &block)
189
+ @hash = Hash.new(&block)
190
+ @hash.update(source) if source
191
+ end
192
+
193
+ def [](key)
194
+ @hash[key]
195
+ end
196
+
197
+ def []=(key, value)
198
+ @hash[key] = value
199
+ end
200
+
201
+ def delete(key)
202
+ @hash.delete(key)
203
+ end
204
+
205
+ def to_hash
206
+ @hash.clone
207
+ end
208
+
209
+ def method_missing(symbol, *args)
210
+ if symbol.to_s =~ /=$/
211
+ self[symbol.to_s[0..-2].to_sym] = args.first
212
+ else
213
+ self[symbol]
214
+ end
215
+ end
216
+ end
217
+
218
+
219
+ class Hash
220
+
221
+ class << self
222
+
223
+ # :call-seq:
224
+ # Hash.from_java_properties(string)
225
+ #
226
+ # Returns a hash from a string in the Java properties file format. For example:
227
+ # str = 'foo=bar\nbaz=fab'
228
+ # Hash.from_properties(str)
229
+ # => { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
230
+ def from_java_properties(string)
231
+ hash = {}
232
+ input_stream = Java.java.io.StringBufferInputStream.new(string)
233
+ java_properties = Java.java.util.Properties.new
234
+ java_properties.load input_stream
235
+ keys = java_properties.keySet.iterator
236
+ while keys.hasNext
237
+ # Calling key.next in JRuby returns a java.lang.String, behaving as a Ruby string and life is good.
238
+ # MRI, unfortunately, treats next() like the interface says returning an object that's not a String,
239
+ # and the Hash doesn't work the way we need it to. Unfortunately, we can call toString on MRI's object,
240
+ # but not on the JRuby one; calling to_s on the JRuby object returns what we need, but ... you guessed it.
241
+ # So this seems like the one hack to unite them both.
242
+ key = Java.java.lang.String.valueOf(keys.next)
243
+ hash[key] = java_properties.getProperty(key)
244
+ end
245
+ hash
246
+ end
247
+
248
+ end
249
+
250
+ # :call-seq:
251
+ # only(keys*) => hash
252
+ #
253
+ # Returns a new hash with only the specified keys.
254
+ #
255
+ # For example:
256
+ # { :a=>1, :b=>2, :c=>3, :d=>4 }.only(:a, :c)
257
+ # => { :a=>1, :c=>3 }
258
+ def only(*keys)
259
+ keys.inject({}) { |hash, key| has_key?(key) ? hash.merge(key=>self[key]) : hash }
260
+ end
261
+
262
+
263
+ # :call-seq:
264
+ # except(keys*) => hash
265
+ #
266
+ # Returns a new hash without the specified keys.
267
+ #
268
+ # For example:
269
+ # { :a=>1, :b=>2, :c=>3, :d=>4 }.except(:a, :c)
270
+ # => { :b=>2, :d=>4 }
271
+ def except(*keys)
272
+ (self.keys - keys).inject({}) { |hash, key| hash.merge(key=>self[key]) }
273
+ end
274
+
275
+ # :call-seq:
276
+ # to_java_properties => string
277
+ #
278
+ # Convert hash to string format used for Java properties file. For example:
279
+ # { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
280
+ # => foo=bar
281
+ # baz=fab
282
+ def to_java_properties
283
+ keys.sort.map { |key|
284
+ value = self[key].gsub(/[\t\r\n\f\\]/) { |escape| "\\" + {"\t"=>"t", "\r"=>"r", "\n"=>"n", "\f"=>"f", "\\"=>"\\"}[escape] }
285
+ "#{key}=#{value}"
286
+ }.join("\n")
287
+ end
288
+
289
+ end
@@ -0,0 +1,18 @@
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/groovy/compiler'
18
+ require 'buildr/groovy/bdd'
@@ -0,0 +1,105 @@
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::Groovy
17
+
18
+ # EasyB is a Groovy based BDD framework.
19
+ # To use in your project:
20
+ #
21
+ # test.using :easyb
22
+ #
23
+ # This framework will search in your project for:
24
+ # src/spec/groovy/**/*Story.groovy
25
+ # src/spec/groovy/**/*Behavior.groovy
26
+ #
27
+ # Support the following options:
28
+ # * :format -- Report format :txt or :xml, default is :txt
29
+ # * :properties -- Hash of properties passed to the test suite.
30
+ # * :java_args -- Arguments passed to the JVM.
31
+ class EasyB < TestFramework::JavaBDD
32
+ @lang = :groovy
33
+ @bdd_dir = :spec
34
+
35
+ VERSION = "0.7"
36
+ TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
37
+ OPTIONS = [:format, :properties, :java_args]
38
+
39
+ class << self
40
+ def version
41
+ Buildr.settings.build['jbehave'] || VERSION
42
+ end
43
+
44
+ def dependencies
45
+ @dependencies ||= ["org.easyb:easyb:jar:#{version}",
46
+ 'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
47
+ 'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
48
+ end
49
+
50
+ def applies_to?(project) #:nodoc:
51
+ %w{
52
+ **/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
53
+ }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
54
+ end
55
+
56
+ private
57
+ def const_missing(const)
58
+ return super unless const == :REQUIRES # TODO: remove in 1.5
59
+ Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION"
60
+ dependencies
61
+ end
62
+ end
63
+
64
+ def tests(dependencies) #:nodoc:
65
+ Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
66
+ select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
67
+ end
68
+
69
+ def run(tests, dependencies) #:nodoc:
70
+ options = { :format => :txt }.merge(self.options).only(*OPTIONS)
71
+
72
+ if :txt == options[:format]
73
+ easyb_format, ext = 'txtstory', '.txt'
74
+ elsif :xml == options[:format]
75
+ easyb_format, ext = 'xmlbehavior', '.xml'
76
+ else
77
+ raise "Invalid format #{options[:format]} expected one of :txt :xml"
78
+ end
79
+
80
+ cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
81
+ cmd_options = { :properties => options[:properties],
82
+ :java_args => options[:java_args],
83
+ :classpath => dependencies }
84
+
85
+ tests.inject([]) do |passed, test|
86
+ name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
87
+ report = File.join(task.report_to.to_s, name + ext)
88
+ mkpath report.pathmap('%d'), :verbose => false
89
+ begin
90
+ Java::Commands.java cmd_args,
91
+ "-#{easyb_format}", report,
92
+ test, cmd_options.merge(:name => name)
93
+ rescue => e
94
+ passed
95
+ else
96
+ passed << test
97
+ end
98
+ end
99
+ end
100
+
101
+ end # EasyB
102
+
103
+ end
104
+
105
+ Buildr::TestFramework << Buildr::Groovy::EasyB
@@ -0,0 +1,138 @@
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
+ module Buildr::Groovy
18
+
19
+ # Groovyc compiler:
20
+ # compile.using(:groovyc)
21
+ #
22
+ # You need to require 'buildr/java/groovyc' if you need to use this compiler.
23
+ #
24
+ # Used by default if .groovy files are found in the src/main/groovy directory (or src/test/groovy)
25
+ # and sets the target directory to target/classes (or target/test/classes).
26
+ #
27
+ # Groovyc is a joint compiler, this means that when selected for a project, this compiler is used
28
+ # to compile both groovy and java sources. It's recommended that Groovy sources are placed in the
29
+ # src/main/groovy directory, even though this compiler also looks in src/main/java
30
+ #
31
+ # Groovyc accepts the following options:
32
+ #
33
+ # * :encoding -- Encoding of source files
34
+ # * :verbose -- Asks the compiler for verbose output, true when running in verbose mode.
35
+ # * :fork -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
36
+ # * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
37
+ # Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
38
+ # * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
39
+ # Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
40
+ # * :listfiles -- Indicates whether the source files to be compiled will be listed; defaults to no
41
+ # * :stacktrace -- If true each compile error message will contain a stacktrace
42
+ # * :warnings -- Issue warnings when compiling. True when running in verbose mode.
43
+ # * :debug -- Generates bytecode with debugging information. Set from the debug
44
+ # environment variable/global option.
45
+ # * :deprecation -- If true, shows deprecation messages. False by default.
46
+ # * :optimise -- Generates faster bytecode by applying optimisations to the program.
47
+ # * :source -- Source code compatibility.
48
+ # * :target -- Bytecode compatibility.
49
+ # * :javac -- Hash of options passed to the ant javac task
50
+ #
51
+ class Groovyc < Compiler::Base
52
+
53
+ # The groovyc compiler jars are added to classpath at load time,
54
+ # if you want to customize artifact versions, you must set them on the
55
+ #
56
+ # artifact_ns['Buildr::Compiler::Groovyc'].groovy = '1.5.4'
57
+ #
58
+ # namespace before this file is required.
59
+ REQUIRES = ArtifactNamespace.for(self) do |ns|
60
+ ns.groovy! 'org.codehaus.groovy:groovy:jar:>=1.5.3'
61
+ ns.commons_cli! 'commons-cli:commons-cli:jar:>=1.0'
62
+ ns.asm! 'asm:asm:jar:>=2.2'
63
+ ns.antlr! 'antlr:antlr:jar:>=2.7.7'
64
+ end
65
+
66
+ ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
67
+ GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
68
+ JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
69
+ OPTIONS = GROOVYC_OPTIONS + JAVAC_OPTIONS
70
+
71
+ class << self
72
+ def dependencies #:nodoc:
73
+ REQUIRES.artifacts
74
+ end
75
+
76
+ def applies_to?(project, task) #:nodoc:
77
+ paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
78
+ paths.flatten!
79
+ # Just select if we find .groovy files
80
+ paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
81
+ end
82
+ end
83
+
84
+ Java.classpath << dependencies
85
+
86
+ specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
87
+ :target => 'classes', :target_ext => 'class', :packaging => :jar
88
+
89
+ def initialize(project, options) #:nodoc:
90
+ super
91
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
92
+ options[:deprecation] ||= false
93
+ options[:optimise] ||= false
94
+ options[:verbose] ||= Buildr.application.options.trace if options[:verbose].nil?
95
+ options[:warnings] = verbose if options[:warnings].nil?
96
+ options[:javac] = OpenObject.new if options[:javac].nil?
97
+ end
98
+
99
+ # http://groovy.codehaus.org/The+groovyc+Ant+Task
100
+ def compile(sources, target, dependencies) #:nodoc:
101
+ return if Buildr.application.options.dryrun
102
+ Buildr.ant 'groovyc' do |ant|
103
+ classpath = dependencies | self.class.dependencies.map(&:to_s)
104
+ ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
105
+ ant.groovyc groovyc_options(sources, target) do
106
+ sources.each { |src| ant.src :path => src }
107
+ ant.classpath do
108
+ classpath.each { |dep| ant.pathelement :path => dep }
109
+ end
110
+ ant.javac(javac_options)
111
+ end
112
+ end
113
+ end
114
+
115
+ private
116
+ def groovyc_options(sources, target)
117
+ check_options options, OPTIONS
118
+ groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
119
+ groovyc_options[:destdir] = File.expand_path(target)
120
+ groovyc_options
121
+ end
122
+
123
+ def javac_options
124
+ check_options options, OPTIONS
125
+ javac_options = options.to_hash.only(*JAVAC_OPTIONS)
126
+ javac_options[:optimize] = (javac_options.delete(:optimise) || false)
127
+ javac_options[:nowarn] = (javac_options.delete(:warnings) || verbose).to_s !~ /^(true|yes|on)$/i
128
+ other = javac_options.delete(:javac) || {}
129
+ javac_options.merge!(other)
130
+ javac_options
131
+ end
132
+
133
+ end
134
+ end
135
+
136
+ # Groovy compiler comes first, ahead of Javac, this allows it to pick
137
+ # projects that mix Groovy and Java code by spotting Groovy code first.
138
+ Buildr::Compiler.compilers.unshift Buildr::Groovy::Groovyc