buildr 1.3.5-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +998 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +244 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +79 -0
  40. data/doc/extending.textile +186 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +266 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +280 -0
  68. data/doc/testing.textile +222 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +656 -0
  73. data/lib/buildr/core/build.rb +452 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +362 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
@@ -0,0 +1,333 @@
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/core/build'
18
+ require 'buildr/core/compile'
19
+ require 'buildr/java/ant'
20
+
21
+
22
+ module Buildr
23
+
24
+ class TestFramework::Java < TestFramework::Base
25
+
26
+ class << self
27
+
28
+ def applies_to?(project) #:nodoc:
29
+ project.test.compile.language == :java
30
+ end
31
+
32
+ end
33
+
34
+ private
35
+
36
+ # Add buildr utilities (JavaTestFilter) to classpath
37
+ Java.classpath << File.join(File.dirname(__FILE__))
38
+
39
+ # :call-seq:
40
+ # filter_classes(dependencies, criteria)
41
+ #
42
+ # Return a list of classnames that match the given criteria.
43
+ # The criteria parameter is a hash that must contain at least one of:
44
+ #
45
+ # * :class_names -- List of patterns to match against class name
46
+ # * :interfaces -- List of java interfaces or java classes
47
+ # * :class_annotations -- List of annotations on class level
48
+ # * :method_annotations -- List of annotations on method level
49
+ # * :fields -- List of java field names
50
+ #
51
+ def filter_classes(dependencies, criteria = {})
52
+ return [] unless task.compile.target
53
+ target = task.compile.target.to_s
54
+ candidates = Dir["#{target}/**/*.class"].
55
+ map { |file| Util.relative_path(file, target).ext('').gsub(File::SEPARATOR, '.') }.
56
+ reject { |name| name =~ /\$./ }
57
+ result = []
58
+ if criteria[:class_names]
59
+ result.concat candidates.select { |name| criteria[:class_names].flatten.any? { |pat| pat === name } }
60
+ end
61
+ begin
62
+ Java.load
63
+ filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
64
+ if criteria[:interfaces]
65
+ filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String))
66
+ end
67
+ if criteria[:class_annotations]
68
+ filter.add_class_annotations(criteria[:class_annotations].to_java(Java.java.lang.String))
69
+ end
70
+ if criteria[:method_annotations]
71
+ filter.add_method_annotations(criteria[:method_annotations].to_java(Java.java.lang.String))
72
+ end
73
+ if criteria[:fields]
74
+ filter.add_fields(criteria[:fields].to_java(Java.java.lang.String))
75
+ end
76
+ result.concat filter.filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
77
+ rescue =>ex
78
+ info "#{ex.class}: #{ex.message}"
79
+ raise
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+
86
+ # JMock is available when using JUnit and TestNG, JBehave.
87
+ module JMock
88
+
89
+ VERSION = '1.2.0'
90
+
91
+ class << self
92
+ def version
93
+ Buildr.settings.build['jmock'] || VERSION
94
+ end
95
+
96
+ def dependencies
97
+ @dependencies ||= ["jmock:jmock:jar:#{version}"]
98
+ end
99
+
100
+ private
101
+ def const_missing(const)
102
+ return super unless const == :REQUIRES # TODO: remove in 1.5
103
+ Buildr.application.deprecated "Please use JMock.dependencies/.version instead of JMock::REQUIRES/VERSION"
104
+ dependencies
105
+ end
106
+ end
107
+ end
108
+
109
+
110
+ # JUnit test framework, the default test framework for Java tests.
111
+ #
112
+ # Support the following options:
113
+ # * :fork -- If true/:once (default), fork for each test class. If :each, fork for each individual
114
+ # test case. If false, run all tests in the same VM (fast, but dangerous).
115
+ # * :clonevm -- If true clone the VM each time it is forked.
116
+ # * :properties -- Hash of system properties available to the test case.
117
+ # * :environment -- Hash of environment variables available to the test case.
118
+ # * :java_args -- Arguments passed as is to the JVM.
119
+ class JUnit < TestFramework::Java
120
+
121
+ # Used by the junit:report task. Access through JUnit#report if you want to set various
122
+ # options for that task, for example:
123
+ # JUnit.report.frames = false
124
+ class Report
125
+
126
+ # Parameters passed to the Ant JUnitReport task.
127
+ attr_reader :params
128
+ # True (default) to produce a report using frames, false to produce a single-page report.
129
+ attr_accessor :frames
130
+ # Directory for the report style (defaults to using the internal style).
131
+ attr_accessor :style_dir
132
+ # Target directory for generated report.
133
+ attr_accessor :target
134
+
135
+ def initialize
136
+ @params = {}
137
+ @frames = true
138
+ @target = 'reports/junit'
139
+ end
140
+
141
+ # :call-seq:
142
+ # generate(projects, target?)
143
+ #
144
+ # Generates a JUnit report for these projects (must run JUnit tests first) into the
145
+ # target directory. You can specify a target, or let it pick the default one from the
146
+ # target attribute.
147
+ def generate(projects, target = @target.to_s)
148
+ html_in = File.join(target, 'html')
149
+ rm_rf html_in ; mkpath html_in
150
+
151
+ Buildr.ant('junit-report') do |ant|
152
+ ant.taskdef :name=>'junitreport', :classname=>'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
153
+ :classpath=>Buildr.artifacts(JUnit.ant_taskdef).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
154
+ ant.junitreport :todir=>target do
155
+ projects.select { |project| project.test.framework == :junit }.
156
+ map { |project| project.test.report_to.to_s }.select { |path| File.exist?(path) }.
157
+ each { |path| ant.fileset(:dir=>path) { ant.include :name=>'TEST-*.xml' } }
158
+ options = { :format=>frames ? 'frames' : 'noframes' }
159
+ options[:styledir] = style_dir if style_dir
160
+ ant.report options.merge(:todir=>html_in) do
161
+ params.each { |key, value| ant.param :name=>key, :expression=>value }
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ end
168
+
169
+ # JUnit version number.
170
+ VERSION = '4.5'
171
+
172
+ class << self
173
+ # :call-seq:
174
+ # report()
175
+ #
176
+ # Returns the Report object used by the junit:report task. You can use this object to set
177
+ # various options that affect your report, for example:
178
+ # JUnit.report.frames = false
179
+ # JUnit.report.params['title'] = 'My App'
180
+ def report
181
+ @report ||= Report.new
182
+ end
183
+
184
+ def version
185
+ Buildr.settings.build['junit'] || VERSION
186
+ end
187
+
188
+ def dependencies
189
+ @dependencies ||= ["junit:junit:jar:#{version}"]+ JMock.dependencies
190
+ end
191
+
192
+ def ant_taskdef #:nodoc:
193
+ "org.apache.ant:ant-junit:jar:#{Ant.version}"
194
+ end
195
+
196
+ private
197
+ def const_missing(const)
198
+ return super unless const == :REQUIRES # TODO: remove in 1.5
199
+ Buildr.application.deprecated "Please use JUnit.dependencies/.version instead of JUnit::REQUIRES/VERSION"
200
+ dependencies
201
+ end
202
+ end
203
+
204
+ def tests(dependencies) #:nodoc:
205
+ filter_classes(dependencies,
206
+ :interfaces => %w{junit.framework.TestCase},
207
+ :class_annotations => %w{org.junit.runner.RunWith},
208
+ :method_annotations => %w{org.junit.Test})
209
+ end
210
+
211
+ def run(tests, dependencies) #:nodoc:
212
+ # Use Ant to execute the Junit tasks, gives us performance and reporting.
213
+ Buildr.ant('junit') do |ant|
214
+ case options[:fork]
215
+ when false
216
+ forking = {}
217
+ when :each
218
+ forking = { :fork=>true, :forkmode=>'perTest' }
219
+ when true, :once
220
+ forking = { :fork=>true, :forkmode=>'once' }
221
+ else
222
+ fail 'Option fork must be :once, :each or false.'
223
+ end
224
+ mkpath task.report_to.to_s
225
+
226
+ taskdef = Buildr.artifact(JUnit.ant_taskdef)
227
+ taskdef.invoke
228
+ ant.taskdef :name=>'junit', :classname=>'org.apache.tools.ant.taskdefs.optional.junit.JUnitTask', :classpath=>taskdef.to_s
229
+
230
+ ant.junit forking.merge(:clonevm=>options[:clonevm] || false, :dir=>task.send(:project).path_to) do
231
+ ant.classpath :path=>dependencies.join(File::PATH_SEPARATOR)
232
+ (options[:properties] || []).each { |key, value| ant.sysproperty :key=>key, :value=>value }
233
+ (options[:environment] || []).each { |key, value| ant.env :key=>key, :value=>value }
234
+ Array(options[:java_args]).each { |value| ant.jvmarg :value=>value }
235
+ ant.formatter :type=>'plain'
236
+ ant.formatter :type=>'plain', :usefile=>false # log test
237
+ ant.formatter :type=>'xml'
238
+ ant.batchtest :todir=>task.report_to.to_s, :failureproperty=>'failed' do
239
+ ant.fileset :dir=>task.compile.target.to_s do
240
+ tests.each { |test| ant.include :name=>File.join(*test.split('.')).ext('class') }
241
+ end
242
+ end
243
+ end
244
+ return tests unless ant.project.getProperty('failed')
245
+ end
246
+ # But Ant doesn't tell us what went kaput, so we'll have to parse the test files.
247
+ tests.inject([]) do |passed, test|
248
+ report_file = File.join(task.report_to.to_s, "TEST-#{test}.txt")
249
+ if File.exist?(report_file)
250
+ report = File.read(report_file)
251
+ # The second line (if exists) is the status line and we scan it for its values.
252
+ status = (report.split("\n")[1] || '').scan(/(run|failures|errors):\s*(\d+)/i).
253
+ inject(Hash.new(0)) { |hash, pair| hash[pair[0].downcase.to_sym] = pair[1].to_i ; hash }
254
+ passed << test if status[:failures] == 0 && status[:errors] == 0
255
+ end
256
+ passed
257
+ end
258
+ end
259
+
260
+ namespace 'junit' do
261
+ desc "Generate JUnit tests report in #{report.target}"
262
+ task('report') do |task|
263
+ report.generate Project.projects
264
+ info "Generated JUnit tests report in #{report.target}"
265
+ end
266
+ end
267
+
268
+ task('clean') { rm_rf report.target.to_s }
269
+
270
+ end
271
+
272
+
273
+ # TestNG test framework. To use in your project:
274
+ # test.using :testng
275
+ #
276
+ # Support the following options:
277
+ # * :properties -- Hash of properties passed to the test suite.
278
+ # * :java_args -- Arguments passed to the JVM.
279
+ class TestNG < TestFramework::Java
280
+
281
+ VERSION = '5.10'
282
+
283
+ class << self
284
+ def version
285
+ Buildr.settings.build['testng'] || VERSION
286
+ end
287
+
288
+ def dependencies
289
+ ["org.testng:testng:jar:jdk15:#{version}"]+ JMock.dependencies
290
+ end
291
+
292
+ private
293
+ def const_missing(const)
294
+ return super unless const == :REQUIRES # TODO: remove in 1.5
295
+ Buildr.application.deprecated "Please use TestNG.dependencies/.version instead of TestNG::REQUIRES/VERSION"
296
+ dependencies
297
+ end
298
+ end
299
+
300
+ def tests(dependencies) #:nodoc:
301
+ filter_classes(dependencies,
302
+ :class_annotations => %w{org.testng.annotations.Test},
303
+ :method_annotations => %w{org.testng.annotations.Test})
304
+ end
305
+
306
+ def run(tests, dependencies) #:nodoc:
307
+ cmd_args = [ 'org.testng.TestNG', '-log', '2', '-sourcedir', task.compile.sources.join(';'), '-suitename', task.project.id ]
308
+ cmd_args << '-d' << task.report_to.to_s
309
+ # run all tests in the same suite
310
+ cmd_args << '-testclass' << tests
311
+ cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args],
312
+ :classpath=>dependencies, :name => "TestNG in #{task.send(:project).name}" }
313
+
314
+ begin
315
+ Java::Commands.java cmd_args, cmd_options
316
+ return tests
317
+ rescue
318
+ # testng-failed.xml contains the list of failed tests *only*
319
+ report = File.read(File.join(task.report_to.to_s, 'testng-failed.xml'))
320
+ failed = report.scan(/<class name="(.*?)">/im).flatten
321
+ error "TestNG regexp returned unexpected failed tests #{failed.inspect}" unless (failed - tests).empty?
322
+ # return the list of passed tests
323
+ return tests - failed
324
+ end
325
+ end
326
+
327
+ end
328
+
329
+ end # Buildr
330
+
331
+
332
+ Buildr::TestFramework << Buildr::JUnit
333
+ Buildr::TestFramework << Buildr::TestNG
@@ -0,0 +1,172 @@
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
18
+
19
+ #
20
+ # See ArtifactNamespace#need
21
+ class VersionRequirement
22
+
23
+ CMP_PROCS = Gem::Requirement::OPS.dup
24
+ CMP_REGEX = Gem::Requirement::OP_RE.dup
25
+ CMP_CHARS = CMP_PROCS.keys.join
26
+ BOOL_CHARS = '\|\&\!'
27
+ VER_CHARS = '\w\.\-'
28
+
29
+ class << self
30
+ # is +str+ a version string?
31
+ def version?(str)
32
+ /^\s*[#{VER_CHARS}]+\s*$/ === str
33
+ end
34
+
35
+ # is +str+ a version requirement?
36
+ def requirement?(str)
37
+ /[#{BOOL_CHARS}#{CMP_CHARS}\(\)]/ === str
38
+ end
39
+
40
+ # :call-seq:
41
+ # VersionRequirement.create(" >1 <2 !(1.5) ") -> requirement
42
+ #
43
+ # parse the +str+ requirement
44
+ def create(str)
45
+ instance_eval normalize(str)
46
+ rescue StandardError => e
47
+ raise "Failed to parse #{str.inspect} due to: #{e}"
48
+ end
49
+
50
+ private
51
+ def requirement(req)
52
+ unless req =~ /^\s*(#{CMP_REGEX})?\s*([#{VER_CHARS}]+)\s*$/
53
+ raise "Invalid requirement string: #{req}"
54
+ end
55
+ comparator, version = $1, $2
56
+ version = Gem::Version.new(0).tap { |v| v.version = version }
57
+ VersionRequirement.new(nil, [$1, version])
58
+ end
59
+
60
+ def negate(vreq)
61
+ vreq.negative = !vreq.negative
62
+ vreq
63
+ end
64
+
65
+ def normalize(str)
66
+ str = str.strip
67
+ if str[/[^\s\(\)#{BOOL_CHARS + VER_CHARS + CMP_CHARS}]/]
68
+ raise "version string #{str.inspect} contains invalid characters"
69
+ end
70
+ str.gsub!(/\s+(and|\&\&)\s+/, ' & ')
71
+ str.gsub!(/\s+(or|\|\|)\s+/, ' | ')
72
+ str.gsub!(/(^|\s*)not\s+/, ' ! ')
73
+ pattern = /(#{CMP_REGEX})?\s*[#{VER_CHARS}]+/
74
+ left_pattern = /[#{VER_CHARS}\)]$/
75
+ right_pattern = /^(#{pattern}|\()/
76
+ str = str.split.inject([]) do |ary, i|
77
+ ary << '&' if ary.last =~ left_pattern && i =~ right_pattern
78
+ ary << i
79
+ end
80
+ str = str.join(' ')
81
+ str.gsub!(/!([^=])?/, ' negate \1')
82
+ str.gsub!(pattern) do |expr|
83
+ case expr.strip
84
+ when 'not', 'negate' then 'negate '
85
+ else 'requirement("' + expr + '")'
86
+ end
87
+ end
88
+ str.gsub!(/negate\s+\(/, 'negate(')
89
+ str
90
+ end
91
+ end
92
+
93
+ def initialize(op, *requirements) #:nodoc:
94
+ @op, @requirements = op, requirements
95
+ end
96
+
97
+ # Is this object a composed requirement?
98
+ # VersionRequirement.create('1').composed? -> false
99
+ # VersionRequirement.create('1 | 2').composed? -> true
100
+ # VersionRequirement.create('1 & 2').composed? -> true
101
+ def composed?
102
+ requirements.size > 1
103
+ end
104
+
105
+ # Return the last requirement on this object having an = operator.
106
+ def default
107
+ default = nil
108
+ requirements.reverse.find do |r|
109
+ if Array === r
110
+ if !negative && (r.first.nil? || r.first.include?('='))
111
+ default = r.last.to_s
112
+ end
113
+ else
114
+ default = r.default
115
+ end
116
+ end
117
+ default
118
+ end
119
+
120
+ # Test if this requirement can be satisfied by +version+
121
+ def satisfied_by?(version)
122
+ return false unless version
123
+ unless version.kind_of?(Gem::Version)
124
+ raise "Invalid version: #{version.inspect}" unless self.class.version?(version)
125
+ version = Gem::Version.new(0).tap { |v| v.version = version.strip }
126
+ end
127
+ message = op == :| ? :any? : :all?
128
+ result = requirements.send message do |req|
129
+ if Array === req
130
+ cmp, rv = *req
131
+ CMP_PROCS[cmp || '='].call(version, rv)
132
+ else
133
+ req.satisfied_by?(version)
134
+ end
135
+ end
136
+ negative ? !result : result
137
+ end
138
+
139
+ # Either modify the current requirement (if it's already an or operation)
140
+ # or create a new requirement
141
+ def |(other)
142
+ operation(:|, other)
143
+ end
144
+
145
+ # Either modify the current requirement (if it's already an and operation)
146
+ # or create a new requirement
147
+ def &(other)
148
+ operation(:&, other)
149
+ end
150
+
151
+ # return the parsed expression
152
+ def to_s
153
+ str = requirements.map(&:to_s).join(" " + @op.to_s + " ").to_s
154
+ str = "( " + str + " )" if negative || requirements.size > 1
155
+ str = "!" + str if negative
156
+ str
157
+ end
158
+
159
+ attr_accessor :negative
160
+ protected
161
+ attr_reader :requirements, :op
162
+ def operation(op, other)
163
+ @op ||= op
164
+ if negative == other.negative && @op == op && other.requirements.size == 1
165
+ @requirements << other.requirements.first
166
+ self
167
+ else
168
+ self.class.new(op, self, other)
169
+ end
170
+ end
171
+ end # VersionRequirement
172
+ end