buildr 1.3.5 → 1.4.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.
- data/CHANGELOG +153 -8
- data/README.rdoc +1 -1
- data/addon/buildr/antlr.rb +5 -5
- data/addon/buildr/drb.rb +18 -18
- data/addon/buildr/hibernate.rb +18 -14
- data/addon/buildr/javacc.rb +4 -4
- data/addon/buildr/jetty.rb +5 -5
- data/addon/buildr/nailgun.rb +23 -23
- data/addon/buildr/openjpa.rb +1 -1
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/protobuf.rb +75 -0
- data/addon/buildr/xmlbeans.rb +5 -5
- data/buildr.buildfile +2 -2
- data/buildr.gemspec +8 -7
- data/doc/_layouts/default.html +2 -2
- data/doc/artifacts.textile +4 -4
- data/doc/building.textile +35 -3
- data/doc/contributing.textile +5 -0
- data/doc/download.textile +16 -5
- data/doc/extending.textile +38 -12
- data/doc/installing.textile +6 -5
- data/doc/languages.textile +182 -42
- data/doc/more_stuff.textile +2 -2
- data/doc/packaging.textile +14 -15
- data/doc/projects.textile +7 -2
- data/doc/quick_start.textile +4 -4
- data/doc/scripts/buildr-git.rb +63 -63
- data/doc/scripts/gitflow.rb +21 -21
- data/doc/settings_profiles.textile +9 -2
- data/doc/testing.textile +16 -5
- data/etc/KEYS +38 -0
- data/lib/buildr/core/application.rb +33 -27
- data/lib/buildr/core/build.rb +41 -28
- data/lib/buildr/core/cc.rb +172 -0
- data/lib/buildr/core/checks.rb +1 -1
- data/lib/buildr/core/common.rb +7 -6
- data/lib/buildr/core/compile.rb +7 -8
- data/lib/buildr/core/doc.rb +263 -0
- data/lib/buildr/core/environment.rb +6 -6
- data/lib/buildr/core/filter.rb +77 -35
- data/lib/buildr/core/generate.rb +7 -7
- data/lib/buildr/core/help.rb +1 -1
- data/lib/buildr/core/osx.rb +6 -6
- data/lib/buildr/core/progressbar.rb +4 -4
- data/lib/buildr/core/project.rb +144 -36
- data/lib/buildr/core/shell.rb +34 -34
- data/lib/buildr/core/test.rb +89 -20
- data/lib/buildr/core/transports.rb +8 -7
- data/lib/buildr/core/util.rb +77 -23
- data/lib/buildr/core.rb +1 -0
- data/lib/buildr/groovy/bdd.rb +5 -5
- data/lib/buildr/groovy/compiler.rb +19 -15
- data/lib/buildr/groovy/shell.rb +6 -6
- data/lib/buildr/ide/eclipse/java.rb +3 -3
- data/lib/buildr/ide/eclipse/plugin.rb +8 -5
- data/lib/buildr/ide/eclipse/scala.rb +4 -2
- data/lib/buildr/ide/eclipse.rb +148 -75
- data/lib/buildr/ide/idea.rb +2 -2
- data/lib/buildr/ide/idea7x.rb +23 -4
- data/lib/buildr/java/ant.rb +4 -4
- data/lib/buildr/java/bdd.rb +51 -54
- data/lib/buildr/java/cobertura.rb +57 -35
- data/lib/buildr/java/commands.rb +14 -5
- data/lib/buildr/java/compiler.rb +3 -217
- data/lib/buildr/java/deprecated.rb +4 -4
- data/lib/buildr/java/doc.rb +70 -0
- data/lib/buildr/java/emma.rb +22 -22
- data/lib/buildr/java/jruby.rb +4 -4
- data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
- data/lib/buildr/java/packaging.rb +30 -29
- data/lib/buildr/java/pom.rb +4 -4
- data/lib/buildr/java/rjb.rb +6 -6
- data/lib/buildr/java/test_result.rb +61 -85
- data/lib/buildr/java/tests.rb +44 -27
- data/lib/buildr/java/version_requirement.rb +8 -8
- data/lib/buildr/java.rb +1 -0
- data/lib/buildr/packaging/archive.rb +55 -22
- data/lib/buildr/packaging/artifact.rb +75 -36
- data/lib/buildr/packaging/artifact_namespace.rb +90 -78
- data/lib/buildr/packaging/artifact_search.rb +5 -5
- data/lib/buildr/packaging/gems.rb +11 -7
- data/lib/buildr/packaging/package.rb +10 -7
- data/lib/buildr/packaging/tar.rb +14 -14
- data/lib/buildr/packaging/version_requirement.rb +30 -10
- data/lib/buildr/packaging/ziptask.rb +51 -13
- data/lib/buildr/scala/bdd.rb +25 -20
- data/lib/buildr/scala/compiler.rb +87 -40
- data/lib/buildr/scala/doc.rb +106 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +14 -9
- data/lib/buildr/scala/tests.rb +33 -26
- data/lib/buildr/scala.rb +1 -0
- data/lib/buildr/shell.rb +33 -33
- data/lib/buildr.rb +1 -1
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +1 -1
- data/rakelib/doc.rake +7 -0
- data/rakelib/package.rake +1 -1
- data/rakelib/release.rake +9 -6
- data/rakelib/rspec.rake +26 -7
- data/rakelib/setup.rake +15 -3
- data/rakelib/stage.rake +18 -11
- data/spec/addon/drb_spec.rb +25 -25
- data/spec/core/application_spec.rb +111 -21
- data/spec/core/build_spec.rb +16 -15
- data/spec/core/cc_spec.rb +174 -0
- data/spec/core/checks_spec.rb +34 -34
- data/spec/core/common_spec.rb +51 -5
- data/spec/core/compile_spec.rb +89 -14
- data/spec/core/extension_spec.rb +127 -19
- data/spec/core/generate_spec.rb +2 -2
- data/spec/core/project_spec.rb +10 -10
- data/spec/core/test_spec.rb +144 -35
- data/spec/core/transport_spec.rb +8 -8
- data/spec/core/util_spec.rb +63 -5
- data/spec/groovy/bdd_spec.rb +5 -5
- data/spec/groovy/compiler_spec.rb +29 -18
- data/spec/ide/eclipse_spec.rb +185 -9
- data/spec/ide/idea7x_spec.rb +22 -10
- data/spec/java/ant_spec.rb +9 -5
- data/spec/java/bdd_spec.rb +29 -37
- data/spec/java/cobertura_spec.rb +12 -12
- data/spec/java/commands_spec.rb +34 -0
- data/spec/java/compiler_spec.rb +53 -53
- data/spec/java/emma_spec.rb +11 -11
- data/spec/java/java_spec.rb +10 -10
- data/spec/java/packaging_spec.rb +67 -20
- data/spec/java/test_coverage_helper.rb +18 -18
- data/spec/java/tests_spec.rb +13 -9
- data/spec/packaging/archive_spec.rb +187 -20
- data/spec/packaging/artifact_namespace_spec.rb +172 -83
- data/spec/packaging/artifact_spec.rb +83 -18
- data/spec/packaging/packaging_spec.rb +41 -14
- data/spec/sandbox.rb +23 -12
- data/spec/scala/bdd_spec.rb +13 -8
- data/spec/scala/compiler_spec.rb +18 -13
- data/spec/scala/scala.rb +3 -3
- data/spec/scala/tests_spec.rb +46 -24
- data/spec/spec_helpers.rb +28 -10
- data/spec/version_requirement_spec.rb +25 -11
- metadata +149 -133
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
- data/rakelib/stage.rake~ +0 -213
|
@@ -166,18 +166,19 @@ module Buildr
|
|
|
166
166
|
@prerequisites << manifest if String === manifest || Rake::Task === manifest
|
|
167
167
|
[meta_inf].flatten.map { |file| file.to_s }.uniq.each { |file| path('META-INF').include file }
|
|
168
168
|
end
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
enhance do
|
|
171
171
|
if manifest
|
|
172
172
|
# Tempfiles gets deleted on garbage collection, so we're going to hold on to it
|
|
173
173
|
# through instance variable not closure variable.
|
|
174
174
|
@manifest_tmp = Tempfile.new('MANIFEST.MF')
|
|
175
|
+
File.chmod 0644, @manifest_tmp.path
|
|
175
176
|
self.manifest = File.read(manifest.to_s) if String === manifest || Rake::Task === manifest
|
|
176
177
|
self.manifest = Manifest.new(manifest) unless Manifest === manifest
|
|
177
178
|
#@manifest_tmp.write Manifest::STANDARD_HEADER
|
|
178
179
|
@manifest_tmp.write manifest.to_s
|
|
179
180
|
@manifest_tmp.write "\n"
|
|
180
|
-
@manifest_tmp.
|
|
181
|
+
@manifest_tmp.close
|
|
181
182
|
path('META-INF').include @manifest_tmp.path, :as=>'MANIFEST.MF'
|
|
182
183
|
end
|
|
183
184
|
end
|
|
@@ -217,7 +218,7 @@ module Buildr
|
|
|
217
218
|
# :call-seq:
|
|
218
219
|
# with(options) => self
|
|
219
220
|
#
|
|
220
|
-
# Additional
|
|
221
|
+
# Additional
|
|
221
222
|
# Pass options to the task. Returns self. ZipTask itself does not support any options,
|
|
222
223
|
# but other tasks (e.g. JarTask, WarTask) do.
|
|
223
224
|
#
|
|
@@ -225,7 +226,8 @@ module Buildr
|
|
|
225
226
|
# package(:jar).with(:manifest=>'MANIFEST_MF')
|
|
226
227
|
def with(*args)
|
|
227
228
|
super args.pop if Hash === args.last
|
|
228
|
-
include
|
|
229
|
+
fail "package.with() should not contain nil values" if args.include? nil
|
|
230
|
+
include :from=>args if args.size > 0
|
|
229
231
|
self
|
|
230
232
|
end
|
|
231
233
|
|
|
@@ -267,7 +269,7 @@ module Buildr
|
|
|
267
269
|
def classes=(value) #:nodoc:
|
|
268
270
|
@classes = [value].flatten.map { |dir| file(dir.to_s) }
|
|
269
271
|
end
|
|
270
|
-
|
|
272
|
+
|
|
271
273
|
end
|
|
272
274
|
|
|
273
275
|
|
|
@@ -340,18 +342,18 @@ module Buildr
|
|
|
340
342
|
# * :map -- A Hash used to map component type to paths within the EAR.
|
|
341
343
|
# By default each component type is mapped to a directory with the same name,
|
|
342
344
|
# for example, EJBs are stored in the /ejb path. To customize:
|
|
343
|
-
# package(:ear).map[:war] = 'web-applications'
|
|
345
|
+
# package(:ear).map[:war] = 'web-applications'
|
|
344
346
|
# package(:ear).map[:lib] = nil # store shared libraries on root of archive
|
|
345
347
|
#
|
|
346
348
|
# EAR components are added by means of the EarTask#add, EarTask#<<, EarTask#push methods
|
|
347
|
-
# Component type is determined from the artifact's type.
|
|
349
|
+
# Component type is determined from the artifact's type.
|
|
348
350
|
#
|
|
349
351
|
# package(:ear) << project('coolWebService').package(:war)
|
|
350
352
|
#
|
|
351
353
|
# The << method is just an alias for push, with the later you can add multiple components
|
|
352
|
-
# at the same time. For example..
|
|
354
|
+
# at the same time. For example..
|
|
353
355
|
#
|
|
354
|
-
# package(:ear).push 'org.springframework:spring:jar:2.6',
|
|
356
|
+
# package(:ear).push 'org.springframework:spring:jar:2.6',
|
|
355
357
|
# projects('reflectUtils', 'springUtils'),
|
|
356
358
|
# project('coolerWebService').package(:war)
|
|
357
359
|
#
|
|
@@ -363,7 +365,7 @@ module Buildr
|
|
|
363
365
|
#
|
|
364
366
|
# # will add an ejb entry for the-cool-ejb-2.5.jar in application.xml
|
|
365
367
|
# package(:ear).add 'org.coolguys:the-cool-ejb:jar:2.5', :type=>:ejb
|
|
366
|
-
# # A better syntax for this is:
|
|
368
|
+
# # A better syntax for this is:
|
|
367
369
|
# package(:ear).add :ejb=>'org.coolguys:the-cool-ejb:jar:2.5'
|
|
368
370
|
#
|
|
369
371
|
# By default, every JAR package is assumed to be a library component, so you need to specify
|
|
@@ -372,13 +374,13 @@ module Buildr
|
|
|
372
374
|
# For WebApplications (:war)s, you can customize the context-root that appears in application.xml.
|
|
373
375
|
# The following example also specifies a different directory inside the EAR where to store the webapp.
|
|
374
376
|
#
|
|
375
|
-
# package(:ear).add project(:remoteService).package(:war),
|
|
377
|
+
# package(:ear).add project(:remoteService).package(:war),
|
|
376
378
|
# :path=>'web-services', :context_root=>'/Some/URL/Path'
|
|
377
379
|
#
|
|
378
380
|
# [1] http://java.sun.com/j2ee/sdk_1.2.1/techdocs/guides/ejb/html/Overview5.html#10106
|
|
379
381
|
# [2] http://java.sun.com/j2ee/verified/packaging.html
|
|
380
382
|
class EarTask < JarTask
|
|
381
|
-
|
|
383
|
+
|
|
382
384
|
SUPPORTED_TYPES = [:war, :ejb, :jar, :rar, :lib]
|
|
383
385
|
|
|
384
386
|
# The display-name entry for application.xml
|
|
@@ -416,7 +418,7 @@ module Buildr
|
|
|
416
418
|
rescue # not an artifact spec, it must me a filename
|
|
417
419
|
file(pkg)
|
|
418
420
|
end
|
|
419
|
-
else
|
|
421
|
+
else
|
|
420
422
|
raise "Invalid EAR component #{pkg.class}: #{pkg}"
|
|
421
423
|
end
|
|
422
424
|
end
|
|
@@ -438,7 +440,7 @@ module Buildr
|
|
|
438
440
|
end
|
|
439
441
|
raise "Unknown EAR component type: #{type}. Perhaps you may explicity tell what component type to use." unless
|
|
440
442
|
SUPPORTED_TYPES.include?(type)
|
|
441
|
-
component = options.merge(:artifact => artifact, :type => type,
|
|
443
|
+
component = options.merge(:artifact => artifact, :type => type,
|
|
442
444
|
:id=>artifact.respond_to?(:to_spec) ? artifact.id : artifact.to_s.pathmap('%n'),
|
|
443
445
|
:path=>options[:path] || dirs[type].to_s)
|
|
444
446
|
component[:clone] = component_clone(component) unless :lib == type
|
|
@@ -448,7 +450,7 @@ module Buildr
|
|
|
448
450
|
end
|
|
449
451
|
self
|
|
450
452
|
end
|
|
451
|
-
|
|
453
|
+
|
|
452
454
|
alias_method :push, :add
|
|
453
455
|
alias_method :<<, :push
|
|
454
456
|
|
|
@@ -482,7 +484,7 @@ module Buildr
|
|
|
482
484
|
|
|
483
485
|
def update_classpath(component)
|
|
484
486
|
package = file(component[:artifact].to_s)
|
|
485
|
-
package.manifest = (package.manifest || {}).dup # avoid mofifying parent projects manifest
|
|
487
|
+
package.manifest = (package.manifest || {}).dup # avoid mofifying parent projects manifest
|
|
486
488
|
package.prepare do
|
|
487
489
|
header = case package.manifest
|
|
488
490
|
when Hash then package.manifest
|
|
@@ -506,7 +508,7 @@ module Buildr
|
|
|
506
508
|
def libs_classpath(component)
|
|
507
509
|
from = component[:path]
|
|
508
510
|
@classpath = @components.select { |comp| comp[:type] == :lib }.
|
|
509
|
-
map do |lib|
|
|
511
|
+
map do |lib|
|
|
510
512
|
basename = lib[:artifact].to_s.pathmap('%f')
|
|
511
513
|
full_path = lib[:path].empty? ? basename : File.join(lib[:path], basename)
|
|
512
514
|
Util.relative_path(full_path, from)
|
|
@@ -516,7 +518,7 @@ module Buildr
|
|
|
516
518
|
def descriptor_xml
|
|
517
519
|
buffer = ""
|
|
518
520
|
xml = Builder::XmlMarkup.new(:target=>buffer, :indent => 2)
|
|
519
|
-
xml.declare! :DOCTYPE, :application, :PUBLIC,
|
|
521
|
+
xml.declare! :DOCTYPE, :application, :PUBLIC,
|
|
520
522
|
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN",
|
|
521
523
|
"http://java.sun.com/j2ee/dtds/application_1_2.dtd"
|
|
522
524
|
xml.application do
|
|
@@ -527,7 +529,7 @@ module Buildr
|
|
|
527
529
|
case comp[:type]
|
|
528
530
|
when :war
|
|
529
531
|
xml.module :id=>comp[:id] do
|
|
530
|
-
xml.web do
|
|
532
|
+
xml.web do
|
|
531
533
|
xml.tag! 'web-uri', uri
|
|
532
534
|
xml.tag! 'context-root', File.join('', (comp[:context_root] || comp[:id])) unless comp[:context_root] == false
|
|
533
535
|
end
|
|
@@ -543,7 +545,7 @@ module Buildr
|
|
|
543
545
|
end
|
|
544
546
|
buffer
|
|
545
547
|
end
|
|
546
|
-
|
|
548
|
+
|
|
547
549
|
# return a FileTask to build the ear application.xml file
|
|
548
550
|
def descriptor
|
|
549
551
|
return @descriptor if @descriptor
|
|
@@ -559,7 +561,7 @@ module Buildr
|
|
|
559
561
|
def xml
|
|
560
562
|
@xml ||= ear.send :descriptor_xml
|
|
561
563
|
end
|
|
562
|
-
|
|
564
|
+
|
|
563
565
|
def needed?
|
|
564
566
|
super || xml != File.read(self.to_s) rescue true
|
|
565
567
|
end
|
|
@@ -567,18 +569,17 @@ module Buildr
|
|
|
567
569
|
@descriptor.ear = self
|
|
568
570
|
@descriptor
|
|
569
571
|
end
|
|
570
|
-
|
|
572
|
+
|
|
571
573
|
end
|
|
572
574
|
|
|
573
575
|
|
|
574
576
|
include Extension
|
|
575
577
|
|
|
576
|
-
before_define do |project|
|
|
577
|
-
|
|
578
|
-
if project.parent && project.parent.manifest
|
|
578
|
+
before_define(:package => :build) do |project|
|
|
579
|
+
if project.parent && project.parent.manifest
|
|
579
580
|
project.manifest = project.parent.manifest.dup
|
|
580
581
|
else
|
|
581
|
-
project.manifest = {
|
|
582
|
+
project.manifest = {
|
|
582
583
|
'Build-By'=>ENV['USER'], 'Build-Jdk'=>ENV_JAVA['java.version'],
|
|
583
584
|
'Implementation-Title'=>project.comment || project.name,
|
|
584
585
|
'Implementation-Version'=>project.version }
|
|
@@ -681,7 +682,7 @@ module Buildr
|
|
|
681
682
|
Java::AarTask.define_task(file_name).tap do |aar|
|
|
682
683
|
aar.with :manifest=>manifest, :meta_inf=>meta_inf
|
|
683
684
|
aar.with :wsdls=>path_to(:source, :main, :axis2, '*.wsdl')
|
|
684
|
-
aar.with :services_xml=>path_to(:source, :main, :axis2, 'services.xml')
|
|
685
|
+
aar.with :services_xml=>path_to(:source, :main, :axis2, 'services.xml')
|
|
685
686
|
aar.with [compile.target, resources.target].compact
|
|
686
687
|
aar.with :libs=>compile.dependencies
|
|
687
688
|
end
|
|
@@ -700,8 +701,8 @@ module Buildr
|
|
|
700
701
|
|
|
701
702
|
def package_as_javadoc(file_name) #:nodoc:
|
|
702
703
|
ZipTask.define_task(file_name).tap do |zip|
|
|
703
|
-
zip.include :from=>
|
|
704
|
-
|
|
704
|
+
zip.include :from=>doc.target
|
|
705
|
+
doc.options[:windowtitle] ||= project.comment || project.name
|
|
705
706
|
end
|
|
706
707
|
end
|
|
707
708
|
|
data/lib/buildr/java/pom.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Buildr
|
|
|
28
28
|
attr_reader :parent
|
|
29
29
|
|
|
30
30
|
class << self
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# :call-seq:
|
|
33
33
|
# POM.load(arg)
|
|
34
34
|
#
|
|
@@ -82,8 +82,8 @@ module Buildr
|
|
|
82
82
|
unless depends = @depends_for_scopes[scopes]
|
|
83
83
|
declared = project["dependencies"].first["dependency"] rescue nil
|
|
84
84
|
depends = (declared || []).reject { |dep| value_of(dep["optional"]) =~ /true/ }.
|
|
85
|
-
map { |dep|
|
|
86
|
-
spec = pom_to_hash(dep, properties)
|
|
85
|
+
map { |dep|
|
|
86
|
+
spec = pom_to_hash(dep, properties)
|
|
87
87
|
apply = managed(spec)
|
|
88
88
|
spec = apply.merge(spec) if apply
|
|
89
89
|
|
|
@@ -93,7 +93,7 @@ module Buildr
|
|
|
93
93
|
|
|
94
94
|
exclusions = dep["exclusions"]["exclusion"] rescue nil
|
|
95
95
|
transitive_deps = POM.load(spec).dependencies(SCOPES_TRANSITIVE)
|
|
96
|
-
transitive_deps = transitive_deps.reject{|dep|
|
|
96
|
+
transitive_deps = transitive_deps.reject{|dep|
|
|
97
97
|
exclusions.find {|ex| dep.index("#{dep['groupdId'].first}:#{dep['artifactId'].first}:") == 0}
|
|
98
98
|
} if exclusions
|
|
99
99
|
|
data/lib/buildr/java/rjb.rb
CHANGED
|
@@ -71,13 +71,13 @@ module Java
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
end
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
# On OS X we know where the default JDK is. We can try to guess for other OS.
|
|
76
76
|
# We set JAVA_HOME early so we can use it without calling Java.load first.
|
|
77
77
|
ENV['JAVA_HOME'] ||= '/System/Library/Frameworks/JavaVM.framework/Home' if Config::CONFIG['host_os'] =~ /darwin/i
|
|
78
78
|
|
|
79
79
|
class << self
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
# Returns the classpath, an array listing directories, JAR files and
|
|
82
82
|
# artifacts. Use when loading the extension to add any additional
|
|
83
83
|
# libraries used by that extension.
|
|
@@ -87,7 +87,7 @@ module Java
|
|
|
87
87
|
def classpath
|
|
88
88
|
@classpath ||= []
|
|
89
89
|
end
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
# Most platforms requires tools.jar to be on the classpath, tools.jar contains the
|
|
92
92
|
# Java compiler (OS X and AIX are two exceptions we know about, may be more).
|
|
93
93
|
# Guess where tools.jar is from JAVA_HOME, which hopefully points to the JDK,
|
|
@@ -99,7 +99,7 @@ module Java
|
|
|
99
99
|
find { |path| File.exist?(path) }
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
# Loads the JVM and all the libraries listed on the classpath. Call this
|
|
104
104
|
# method before accessing any Java class, but only call it from methods
|
|
105
105
|
# used in the build, giving the Buildfile a chance to load all extensions
|
|
@@ -107,14 +107,14 @@ module Java
|
|
|
107
107
|
def load
|
|
108
108
|
return self if @loaded
|
|
109
109
|
classpath << tools_jar if tools_jar
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
classpath.map! { |path| Proc === path ? path.call : path }
|
|
112
112
|
cp = Buildr.artifacts(classpath).map(&:to_s).each { |path| file(path).invoke }
|
|
113
113
|
java_opts = (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split
|
|
114
114
|
::Rjb.load cp.join(File::PATH_SEPARATOR), java_opts
|
|
115
115
|
|
|
116
116
|
props = ::Rjb.import('java.lang.System').getProperties
|
|
117
|
-
enum = props.propertyNames
|
|
117
|
+
enum = props.propertyNames
|
|
118
118
|
while enum.hasMoreElements
|
|
119
119
|
name = enum.nextElement.toString
|
|
120
120
|
ENV_JAVA[name] = props.getProperty(name)
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
|
14
14
|
# the License.
|
|
15
15
|
|
|
16
|
+
# necessary to require YAML even if it is mentioned by autoload as it fails on some platforms.
|
|
17
|
+
require 'yaml'
|
|
16
18
|
require 'fileutils'
|
|
17
19
|
module Buildr #:nodoc:
|
|
18
20
|
module TestFramework
|
|
19
|
-
|
|
20
|
-
# A class used by buildr for jruby based frameworks, so that buildr can know
|
|
21
|
+
|
|
22
|
+
# A class used by buildr for jruby based frameworks, so that buildr can know
|
|
21
23
|
# which tests succeeded/failed.
|
|
22
24
|
class TestResult
|
|
23
25
|
|
|
@@ -35,14 +37,14 @@ module Buildr #:nodoc:
|
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def self.guard(file)
|
|
38
|
-
begin
|
|
40
|
+
begin
|
|
39
41
|
yield
|
|
40
42
|
rescue => e
|
|
41
43
|
dump_yaml(file, e)
|
|
42
44
|
end
|
|
43
45
|
end
|
|
44
46
|
end
|
|
45
|
-
|
|
47
|
+
|
|
46
48
|
attr_accessor :failed, :succeeded
|
|
47
49
|
|
|
48
50
|
def initialize
|
|
@@ -54,7 +56,7 @@ module Buildr #:nodoc:
|
|
|
54
56
|
attr_reader :result
|
|
55
57
|
|
|
56
58
|
attr_accessor :example_group, :options, :where
|
|
57
|
-
|
|
59
|
+
|
|
58
60
|
def initialize(options, where)
|
|
59
61
|
@options = options
|
|
60
62
|
@where = where
|
|
@@ -62,7 +64,7 @@ module Buildr #:nodoc:
|
|
|
62
64
|
@result[:succeeded] = []
|
|
63
65
|
@result[:failed] = []
|
|
64
66
|
end
|
|
65
|
-
|
|
67
|
+
|
|
66
68
|
%w[ example_started
|
|
67
69
|
start_dump dump_failure dump_summary dump_pending ].each do |meth|
|
|
68
70
|
module_eval "def #{meth}(*args); end"
|
|
@@ -73,15 +75,15 @@ module Buildr #:nodoc:
|
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
def example_passed(example)
|
|
76
|
-
result.succeeded <<
|
|
78
|
+
result.succeeded << example_name(example)
|
|
77
79
|
end
|
|
78
80
|
|
|
79
|
-
def example_pending(example, counter
|
|
80
|
-
result.succeeded <<
|
|
81
|
+
def example_pending(example, counter)
|
|
82
|
+
result.succeeded << example_name(example)
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
def example_failed(example, counter, failure)
|
|
84
|
-
result.failed <<
|
|
86
|
+
result.failed << example_name(example)
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
def start(example_count)
|
|
@@ -93,69 +95,16 @@ module Buildr #:nodoc:
|
|
|
93
95
|
FileUtils.mkdir_p File.dirname(where)
|
|
94
96
|
File.open(where, 'w') { |f| f.puts YAML.dump(result) }
|
|
95
97
|
end
|
|
96
|
-
end # YamlFormatter
|
|
97
|
-
|
|
98
|
-
# Rspec formatter used for JtestR
|
|
99
|
-
# (JtestR provides its own version of rspec)
|
|
100
|
-
class JtestRYamlFormatter
|
|
101
|
-
attr_reader :result
|
|
102
|
-
|
|
103
|
-
attr_accessor :example_group, :options, :where
|
|
104
|
-
|
|
105
|
-
def initialize(options, where)
|
|
106
|
-
@options = options
|
|
107
|
-
@where = where
|
|
108
|
-
@result = Hash.new
|
|
109
|
-
@result[:succeeded] = []
|
|
110
|
-
@result[:failed] = []
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
%w[ example_started
|
|
114
|
-
start_dump dump_failure dump_summary dump_pending ].each do |meth|
|
|
115
|
-
module_eval "def #{meth}(*args); end"
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def add_example_group(example_group)
|
|
119
|
-
@example_group = example_group
|
|
120
|
-
end
|
|
121
98
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def example_failed(example, counter, failure)
|
|
129
|
-
if example_group.respond_to?(:spec_path)
|
|
130
|
-
result.failed << example_group.spec_path.gsub(/:\d+$/, '')
|
|
99
|
+
private
|
|
100
|
+
def example_name(example)
|
|
101
|
+
if Spec::Example::ExampleProxy === example
|
|
102
|
+
example_group.location.gsub(/:\d+$/, '')
|
|
131
103
|
else
|
|
132
|
-
|
|
133
|
-
result.failed << path if path
|
|
104
|
+
example.name.gsub(/(.+)(\..+\(\))/, '\1')
|
|
134
105
|
end
|
|
135
106
|
end
|
|
136
|
-
|
|
137
|
-
def start(example_count)
|
|
138
|
-
@result = TestResult.new
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def path_from_bt(ary)
|
|
142
|
-
files = options.files
|
|
143
|
-
test = nil
|
|
144
|
-
ary.find do |bt|
|
|
145
|
-
bt = bt.split(':').first.strip
|
|
146
|
-
test = bt if files.include?(bt)
|
|
147
|
-
end
|
|
148
|
-
test
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def close
|
|
152
|
-
files = options.files
|
|
153
|
-
result.succeeded = files - result.failed
|
|
154
|
-
|
|
155
|
-
FileUtils.mkdir_p File.dirname(where)
|
|
156
|
-
File.open(where, 'w') { |f| f.puts YAML.dump(result) }
|
|
157
|
-
end
|
|
158
|
-
end # JtestRYamlFormatter
|
|
107
|
+
end # YamlFormatter
|
|
159
108
|
|
|
160
109
|
# A JtestR ResultHandler
|
|
161
110
|
# Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
|
|
@@ -177,7 +126,7 @@ module Buildr #:nodoc:
|
|
|
177
126
|
ignore_patterns << /org\.jruby\.javasupport\.JavaMethod\./
|
|
178
127
|
ignore_patterns << /jtestr.*\.jar!/i << /runner\.rb/
|
|
179
128
|
end
|
|
180
|
-
|
|
129
|
+
|
|
181
130
|
def clean_up_double_slashes(line)
|
|
182
131
|
line.gsub!('//','/')
|
|
183
132
|
end
|
|
@@ -197,10 +146,11 @@ module Buildr #:nodoc:
|
|
|
197
146
|
error.backtrace.compact!
|
|
198
147
|
end
|
|
199
148
|
end
|
|
200
|
-
|
|
149
|
+
|
|
201
150
|
class << self
|
|
202
151
|
# an rspec reporter used to proxy events to rspec formatters
|
|
203
152
|
attr_reader :reporter
|
|
153
|
+
attr_accessor :test_files
|
|
204
154
|
|
|
205
155
|
def init(argv = [], out = STDOUT, err = STDERR)
|
|
206
156
|
::JtestR::TestNGResultHandler.module_eval { include TestNGResultHandlerMixin }
|
|
@@ -218,10 +168,11 @@ module Buildr #:nodoc:
|
|
|
218
168
|
reporter.end
|
|
219
169
|
reporter.dump
|
|
220
170
|
end
|
|
171
|
+
|
|
221
172
|
end
|
|
222
173
|
|
|
223
174
|
module ExampleMethods
|
|
224
|
-
attr_accessor :name, :description, :__full_description
|
|
175
|
+
attr_accessor :name, :description, :__full_description, :location
|
|
225
176
|
end
|
|
226
177
|
|
|
227
178
|
def reporter
|
|
@@ -239,9 +190,10 @@ module Buildr #:nodoc:
|
|
|
239
190
|
else
|
|
240
191
|
example_group.description = name.to_s
|
|
241
192
|
end
|
|
242
|
-
reporter.
|
|
193
|
+
reporter.example_group_started(example_group)
|
|
243
194
|
end
|
|
244
195
|
|
|
196
|
+
|
|
245
197
|
def starting
|
|
246
198
|
end
|
|
247
199
|
|
|
@@ -261,8 +213,8 @@ module Buildr #:nodoc:
|
|
|
261
213
|
current_example.extend ::Spec::Example::ExampleMethods
|
|
262
214
|
current_example.extend ExampleMethods
|
|
263
215
|
name = name.to_s
|
|
264
|
-
name
|
|
265
|
-
name =
|
|
216
|
+
current_example.location = name.to_s
|
|
217
|
+
current_example.name = name.gsub(/(.*)\((.+)\)/, '\2')
|
|
266
218
|
current_example.description = name
|
|
267
219
|
if example_group.name[/Spec/]
|
|
268
220
|
current_example.__full_description = "#{example_group.description} #{name}"
|
|
@@ -270,31 +222,56 @@ module Buildr #:nodoc:
|
|
|
270
222
|
current_example.__full_description = "#{example_group.name}: #{name}"
|
|
271
223
|
end
|
|
272
224
|
reporter.example_started(current_example)
|
|
273
|
-
#puts "STARTED #{name} #{current_example.__full_description}"
|
|
274
225
|
end
|
|
275
226
|
|
|
276
227
|
def succeed_single(name = nil)
|
|
277
|
-
#puts "SUCC SINGLE #{name}"
|
|
278
228
|
reporter.example_finished(current_example, nil)
|
|
279
229
|
end
|
|
280
|
-
|
|
230
|
+
|
|
281
231
|
def fail_single(name = nil)
|
|
282
|
-
|
|
232
|
+
current_example.name = current_name
|
|
283
233
|
reporter.example_finished(current_example, current_error)
|
|
284
234
|
end
|
|
285
235
|
|
|
286
236
|
def error_single(name = nil)
|
|
287
|
-
|
|
237
|
+
current_example.name = current_name
|
|
288
238
|
reporter.example_finished(current_example, current_error)
|
|
289
239
|
end
|
|
290
240
|
|
|
291
241
|
def pending_single(name = nil)
|
|
292
|
-
#puts "PEND SINGLE #{name}"
|
|
293
242
|
error = ::Spec::Example::ExamplePendingError.new(name)
|
|
294
243
|
reporter.example_finished(current_example, error)
|
|
295
244
|
end
|
|
296
245
|
|
|
297
246
|
private
|
|
247
|
+
def detect_file(trace)
|
|
248
|
+
# find first matching test file in stacktrace
|
|
249
|
+
file = nil
|
|
250
|
+
first_pos = nil
|
|
251
|
+
RSpecResultHandler.test_files.each do |f|
|
|
252
|
+
pos = trace.index(f)
|
|
253
|
+
if pos && (first_pos.nil? || pos < first_pos)
|
|
254
|
+
file = f
|
|
255
|
+
first_pos = pos
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
file || fail("RSpecResultHandler.detect_file failed: #{trace}")
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def current_name(example = current_example, fault = current_failure)
|
|
262
|
+
return example.name unless fault
|
|
263
|
+
case fault
|
|
264
|
+
when Test::Unit::Error
|
|
265
|
+
detect_file(fault.long_display)
|
|
266
|
+
when Test::Unit::Failure
|
|
267
|
+
detect_file(fault.location.to_s)
|
|
268
|
+
when Spec::Runner::Reporter::Failure
|
|
269
|
+
detect_file(fault.exception.backtrace.to_s)
|
|
270
|
+
else
|
|
271
|
+
example.name
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
298
275
|
def current_error(fault = current_failure)
|
|
299
276
|
case fault
|
|
300
277
|
when nil
|
|
@@ -314,8 +291,7 @@ module Buildr #:nodoc:
|
|
|
314
291
|
fault.exception
|
|
315
292
|
when Spec::Runner::Reporter::Failure
|
|
316
293
|
ex = fault.exception
|
|
317
|
-
|
|
318
|
-
Error.new(ex.message, [$1.to_s] + ex.backtrace)
|
|
294
|
+
Error.new(ex.message, ex.backtrace)
|
|
319
295
|
when Expectations::Results
|
|
320
296
|
file = fault.file
|
|
321
297
|
line = fault.line
|
|
@@ -326,7 +302,7 @@ module Buildr #:nodoc:
|
|
|
326
302
|
test_cls, test_meth = $1.to_s, $`.to_s
|
|
327
303
|
exception = fault.exception
|
|
328
304
|
(class << exception; self; end).module_eval do
|
|
329
|
-
define_method(:backtrace) do
|
|
305
|
+
define_method(:backtrace) do
|
|
330
306
|
(["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
|
|
331
307
|
end
|
|
332
308
|
end
|
|
@@ -335,7 +311,7 @@ module Buildr #:nodoc:
|
|
|
335
311
|
test_cls, test_meth = fault.method.test_class.name, fault.method.method_name
|
|
336
312
|
exception = fault.throwable
|
|
337
313
|
(class << exception; self; end).module_eval do
|
|
338
|
-
define_method(:backtrace) do
|
|
314
|
+
define_method(:backtrace) do
|
|
339
315
|
(["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
|
|
340
316
|
end
|
|
341
317
|
end
|