ittayd-buildr 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +62 -9
- data/NOTICE +1 -1
- data/README.rdoc +9 -21
- data/Rakefile +20 -39
- data/_buildr +1 -0
- data/{spec/java/ant.rb → _jbuildr} +11 -15
- metadata +30 -210
- data/DISCLAIMER +0 -7
- data/addon/buildr/antlr.rb +0 -65
- data/addon/buildr/cobertura.rb +0 -22
- data/addon/buildr/drb.rb +0 -281
- data/addon/buildr/emma.rb +0 -22
- data/addon/buildr/hibernate.rb +0 -142
- data/addon/buildr/javacc.rb +0 -85
- data/addon/buildr/jdepend.rb +0 -60
- data/addon/buildr/jetty.rb +0 -248
- data/addon/buildr/jibx.rb +0 -86
- data/addon/buildr/nailgun.rb +0 -221
- data/addon/buildr/openjpa.rb +0 -90
- 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/BuildrNail.java +0 -41
- 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/org/apache/buildr/JettyWrapper.java +0 -144
- data/addon/buildr/path.rb +0 -136
- data/addon/buildr/xmlbeans.rb +0 -93
- data/buildr.buildfile +0 -53
- data/buildr.gemspec +0 -58
- data/doc/css/default.css +0 -228
- data/doc/css/print.css +0 -100
- data/doc/css/syntax.css +0 -52
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +0 -207
- data/doc/pages/building.textile +0 -240
- data/doc/pages/contributing.textile +0 -208
- data/doc/pages/download.textile +0 -62
- data/doc/pages/extending.textile +0 -175
- data/doc/pages/getting_started.textile +0 -273
- data/doc/pages/index.textile +0 -42
- data/doc/pages/languages.textile +0 -407
- data/doc/pages/mailing_lists.textile +0 -17
- data/doc/pages/more_stuff.textile +0 -314
- data/doc/pages/packaging.textile +0 -427
- data/doc/pages/projects.textile +0 -274
- data/doc/pages/recipes.textile +0 -103
- data/doc/pages/settings_profiles.textile +0 -274
- data/doc/pages/testing.textile +0 -212
- data/doc/pages/troubleshooting.textile +0 -103
- data/doc/pages/whats_new.textile +0 -323
- data/doc/print.haml +0 -51
- data/doc/print.toc.yaml +0 -29
- data/doc/scripts/buildr-git.rb +0 -412
- data/doc/scripts/install-jruby.sh +0 -44
- data/doc/scripts/install-linux.sh +0 -64
- data/doc/scripts/install-osx.sh +0 -52
- data/doc/site.haml +0 -56
- data/doc/site.toc.yaml +0 -47
- data/etc/KEYS +0 -151
- data/etc/git-svn-authors +0 -16
- data/lib/buildr.rb +0 -33
- data/lib/buildr/core.rb +0 -29
- data/lib/buildr/core/application.rb +0 -665
- data/lib/buildr/core/build.rb +0 -311
- data/lib/buildr/core/checks.rb +0 -254
- data/lib/buildr/core/common.rb +0 -150
- data/lib/buildr/core/compile.rb +0 -590
- data/lib/buildr/core/environment.rb +0 -117
- data/lib/buildr/core/filter.rb +0 -366
- data/lib/buildr/core/generate.rb +0 -195
- data/lib/buildr/core/help.rb +0 -119
- data/lib/buildr/core/osx.rb +0 -49
- data/lib/buildr/core/progressbar.rb +0 -156
- data/lib/buildr/core/project.rb +0 -923
- data/lib/buildr/core/test.rb +0 -715
- data/lib/buildr/core/transports.rb +0 -560
- data/lib/buildr/core/util.rb +0 -294
- data/lib/buildr/groovy.rb +0 -18
- data/lib/buildr/groovy/bdd.rb +0 -106
- data/lib/buildr/groovy/compiler.rb +0 -138
- data/lib/buildr/ide.rb +0 -19
- data/lib/buildr/ide/eclipse.rb +0 -222
- data/lib/buildr/ide/idea.ipr.template +0 -300
- data/lib/buildr/ide/idea.rb +0 -190
- data/lib/buildr/ide/idea7x.ipr.template +0 -290
- data/lib/buildr/ide/idea7x.rb +0 -212
- data/lib/buildr/java.rb +0 -23
- data/lib/buildr/java/ant.rb +0 -92
- data/lib/buildr/java/bdd.rb +0 -451
- data/lib/buildr/java/cobertura.rb +0 -236
- data/lib/buildr/java/commands.rb +0 -211
- data/lib/buildr/java/compiler.rb +0 -348
- data/lib/buildr/java/deprecated.rb +0 -141
- data/lib/buildr/java/emma.rb +0 -238
- data/lib/buildr/java/jruby.rb +0 -117
- data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
- data/lib/buildr/java/packaging.rb +0 -717
- data/lib/buildr/java/pom.rb +0 -174
- data/lib/buildr/java/rjb.rb +0 -155
- data/lib/buildr/java/test_result.rb +0 -307
- data/lib/buildr/java/tests.rb +0 -329
- data/lib/buildr/java/version_requirement.rb +0 -172
- data/lib/buildr/packaging.rb +0 -24
- data/lib/buildr/packaging/archive.rb +0 -488
- data/lib/buildr/packaging/artifact.rb +0 -759
- data/lib/buildr/packaging/artifact_namespace.rb +0 -972
- data/lib/buildr/packaging/artifact_search.rb +0 -140
- data/lib/buildr/packaging/gems.rb +0 -102
- data/lib/buildr/packaging/package.rb +0 -233
- data/lib/buildr/packaging/tar.rb +0 -186
- data/lib/buildr/packaging/version_requirement.rb +0 -172
- data/lib/buildr/packaging/zip.rb +0 -64
- data/lib/buildr/packaging/ziptask.rb +0 -313
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +0 -19
- data/lib/buildr/scala/compiler.rb +0 -109
- data/lib/buildr/scala/tests.rb +0 -203
- data/rakelib/apache.rake +0 -191
- data/rakelib/changelog.rake +0 -57
- data/rakelib/doc.rake +0 -103
- data/rakelib/package.rake +0 -76
- data/rakelib/release.rake +0 -65
- data/rakelib/rspec.rake +0 -83
- data/rakelib/rubyforge.rake +0 -56
- data/rakelib/scm.rake +0 -49
- data/rakelib/setup.rake +0 -81
- data/rakelib/stage.rake +0 -48
- data/spec/addon/drb_spec.rb +0 -328
- data/spec/core/application_spec.rb +0 -419
- data/spec/core/build_spec.rb +0 -423
- data/spec/core/checks_spec.rb +0 -519
- data/spec/core/common_spec.rb +0 -670
- data/spec/core/compile_spec.rb +0 -582
- data/spec/core/generate_spec.rb +0 -33
- data/spec/core/project_spec.rb +0 -776
- data/spec/core/test_spec.rb +0 -1098
- data/spec/core/transport_spec.rb +0 -500
- data/spec/groovy/bdd_spec.rb +0 -80
- data/spec/groovy/compiler_spec.rb +0 -239
- data/spec/ide/eclipse_spec.rb +0 -311
- data/spec/java/bdd_spec.rb +0 -358
- data/spec/java/cobertura_spec.rb +0 -77
- data/spec/java/compiler_spec.rb +0 -446
- data/spec/java/emma_spec.rb +0 -120
- data/spec/java/java_spec.rb +0 -96
- data/spec/java/packaging_spec.rb +0 -1120
- data/spec/java/test_coverage_spec.rb +0 -255
- data/spec/java/tests_spec.rb +0 -471
- data/spec/packaging/archive_spec.rb +0 -503
- data/spec/packaging/artifact_namespace_spec.rb +0 -646
- data/spec/packaging/artifact_spec.rb +0 -795
- data/spec/packaging/packaging_helper.rb +0 -63
- data/spec/packaging/packaging_spec.rb +0 -589
- data/spec/sandbox.rb +0 -139
- data/spec/scala/compiler_spec.rb +0 -228
- data/spec/scala/tests_spec.rb +0 -215
- data/spec/spec_helpers.rb +0 -327
- data/spec/version_requirement_spec.rb +0 -123
data/lib/buildr/java/pom.rb
DELETED
@@ -1,174 +0,0 @@
|
|
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
|
-
class POM
|
19
|
-
|
20
|
-
POM_TO_SPEC_MAP = { :group=>"groupId", :id=>"artifactId", :type=>"type",
|
21
|
-
:version=>"version", :classifier=>"classifier", :scope=>"scope" }
|
22
|
-
SCOPES_TRANSITIVE = [nil, "compile", "runtime"]
|
23
|
-
SCOPES_WE_USE = SCOPES_TRANSITIVE + ["provided"]
|
24
|
-
|
25
|
-
# POM project as Hash (using XmlSimple).
|
26
|
-
attr_reader :project
|
27
|
-
# Parent POM if referenced by this POM.
|
28
|
-
attr_reader :parent
|
29
|
-
|
30
|
-
class << self
|
31
|
-
|
32
|
-
# :call-seq:
|
33
|
-
# POM.load(arg)
|
34
|
-
#
|
35
|
-
# Load new POM object form various kind of sources such as artifact, hash representing spec, filename, XML.
|
36
|
-
def load(source)
|
37
|
-
case source
|
38
|
-
when Hash
|
39
|
-
load(Buildr.artifact(source).pom)
|
40
|
-
when Artifact
|
41
|
-
pom = source.pom
|
42
|
-
pom.invoke
|
43
|
-
load(pom.to_s)
|
44
|
-
when Rake::FileTask
|
45
|
-
source.invoke
|
46
|
-
load(source.to_s)
|
47
|
-
when String
|
48
|
-
filename = File.expand_path(source)
|
49
|
-
unless pom = cache[filename]
|
50
|
-
trace "Loading m2 pom file from #{filename}"
|
51
|
-
pom = POM.new(IO.read(filename))
|
52
|
-
cache[filename] = pom
|
53
|
-
end
|
54
|
-
pom
|
55
|
-
else
|
56
|
-
raise ArgumentError, "Expecting Hash spec, Artifact, file name or file task"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def cache()
|
63
|
-
@cache ||= {}
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def initialize(xml) #:nodoc:
|
69
|
-
@project = XmlSimple.xml_in(xml)
|
70
|
-
@parent = POM.load(pom_to_hash(project["parent"].first).merge(:type=>'pom')) if project['parent']
|
71
|
-
end
|
72
|
-
|
73
|
-
# :call-seq:
|
74
|
-
# dependencies(scopes?) => artifacts
|
75
|
-
#
|
76
|
-
# Returns list of required dependencies as specified by the POM. You can specify which scopes
|
77
|
-
# to use (e.g. "compile", "runtime"); use +nil+ for dependencies with unspecified scope.
|
78
|
-
# The default scopes are +nil+, "compile" and "runtime" (aka SCOPES_WE_USE).
|
79
|
-
def dependencies(scopes = SCOPES_WE_USE)
|
80
|
-
#try to cache dependencies also
|
81
|
-
@depends_for_scopes ||= {}
|
82
|
-
unless depends = @depends_for_scopes[scopes]
|
83
|
-
declared = project["dependencies"].first["dependency"] rescue nil
|
84
|
-
depends = (declared || []).reject { |dep| value_of(dep["optional"]) =~ /true/ }.
|
85
|
-
map { |dep|
|
86
|
-
spec = pom_to_hash(dep, properties)
|
87
|
-
apply = managed(spec)
|
88
|
-
spec = apply.merge(spec) if apply
|
89
|
-
|
90
|
-
#calculate transitive dependencies
|
91
|
-
if scopes.include?(spec[:scope])
|
92
|
-
spec.delete(:scope)
|
93
|
-
|
94
|
-
exclusions = dep["exclusions"]["exclusion"] rescue nil
|
95
|
-
transitive_deps = POM.load(spec).dependencies(SCOPES_TRANSITIVE)
|
96
|
-
transitive_deps = transitive_deps.reject{|dep|
|
97
|
-
exclusions.find {|ex| dep.index("#{dep['groupdId'].first}:#{dep['artifactId'].first}:") == 0}
|
98
|
-
} if exclusions
|
99
|
-
|
100
|
-
[Artifact.to_spec(spec)] + transitive_deps
|
101
|
-
end
|
102
|
-
}.flatten.compact #.uniq_by{|spec| art = spec.split(':'); "#{art[0]}:#{art[1]}"}
|
103
|
-
|
104
|
-
@depends_for_scopes[scopes] = depends
|
105
|
-
end
|
106
|
-
depends
|
107
|
-
end
|
108
|
-
|
109
|
-
# :call-seq:
|
110
|
-
# properties() => hash
|
111
|
-
#
|
112
|
-
# Returns properties available to this POM as hash. Includes explicit properties and pom.xxx/project.xxx
|
113
|
-
# properties for groupId, artifactId, version and packaging.
|
114
|
-
def properties()
|
115
|
-
@properties ||= begin
|
116
|
-
pom = ["groupId", "artifactId", "version", "packaging"].inject({}) { |hash, key|
|
117
|
-
value = project[key] || (parent ? parent.project[key] : nil)
|
118
|
-
hash["pom.#{key}"] = hash["project.#{key}"] = value_of(value) if value
|
119
|
-
hash
|
120
|
-
}
|
121
|
-
props = project["properties"].first rescue {}
|
122
|
-
props = props.inject({}) { |mapped, pair| mapped[pair.first] = value_of(pair.last, pom) ; mapped }
|
123
|
-
(parent ? parent.properties.merge(props) : props).merge(pom)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
# :call-seq:
|
128
|
-
# managed() => hash
|
129
|
-
# managed(hash) => hash
|
130
|
-
#
|
131
|
-
# The first form returns all the managed dependencies specified by this POM in dependencyManagement.
|
132
|
-
# The second form uses a single spec hash and expands it from the current/parent POM. Used to determine
|
133
|
-
# the version number if specified in dependencyManagement instead of dependencies.
|
134
|
-
def managed(spec = nil)
|
135
|
-
if spec
|
136
|
-
managed.detect { |dep| [:group, :id, :type, :classifier].all? { |key| spec[key] == dep[key] } } ||
|
137
|
-
(parent ? parent.managed(spec) : nil)
|
138
|
-
else
|
139
|
-
@managed ||= begin
|
140
|
-
managed = project["dependencyManagement"].first["dependencies"].first["dependency"] rescue nil
|
141
|
-
managed ? managed.map { |dep| pom_to_hash(dep, properties) } : []
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
private
|
147
|
-
|
148
|
-
# :call-seq:
|
149
|
-
# value_of(element) => string
|
150
|
-
# value_of(element, true) => string
|
151
|
-
#
|
152
|
-
# Returns the normalized text value of an element from its XmlSimple value. The second form performs
|
153
|
-
# property substitution.
|
154
|
-
def value_of(element, substitute = nil)
|
155
|
-
value = element.to_a.join.strip
|
156
|
-
substitute ? value.gsub(/\$\{([^}]+)\}/) { |key| substitute[$1] } : value
|
157
|
-
end
|
158
|
-
|
159
|
-
# :call-seq:
|
160
|
-
# pom_to_hash(element) => hash
|
161
|
-
# pom_to_hash(element, true) => hash
|
162
|
-
#
|
163
|
-
# Return the spec hash from an XmlSimple POM referencing element (e.g. project, parent, dependency).
|
164
|
-
# The second form performs property substitution.
|
165
|
-
def pom_to_hash(element, substitute = nil)
|
166
|
-
hash = POM_TO_SPEC_MAP.inject({}) { |spec, pair|
|
167
|
-
spec[pair.first] = value_of(element[pair.last], substitute) if element[pair.last]
|
168
|
-
spec
|
169
|
-
}
|
170
|
-
{ :type=>"jar" }.merge(hash)
|
171
|
-
end
|
172
|
-
|
173
|
-
end
|
174
|
-
end
|
data/lib/buildr/java/rjb.rb
DELETED
@@ -1,155 +0,0 @@
|
|
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 'rjb'
|
18
|
-
|
19
|
-
|
20
|
-
# Equivalent to Java system properties. For example:
|
21
|
-
# ENV_JAVA['java.version']
|
22
|
-
# ENV_JAVA['java.class.version']
|
23
|
-
ENV_JAVA = {}
|
24
|
-
|
25
|
-
|
26
|
-
# Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows
|
27
|
-
# you to access Java classes and create Java objects.
|
28
|
-
#
|
29
|
-
# Java classes are accessed as static methods on the Java module, for example:
|
30
|
-
# str = Java.java.lang.String.new('hai!')
|
31
|
-
# str.toUpperCase
|
32
|
-
# => 'HAI!'
|
33
|
-
# Java.java.lang.String.isInstance(str)
|
34
|
-
# => true
|
35
|
-
# Java.com.sun.tools.javac.Main.compile(args)
|
36
|
-
#
|
37
|
-
# The classpath attribute allows Buildr to add JARs and directories to the classpath,
|
38
|
-
# for example, we use it to load Ant and various Ant tasks, code generators, test
|
39
|
-
# frameworks, and so forth.
|
40
|
-
#
|
41
|
-
# When using an artifact specification, Buildr will automatically download and
|
42
|
-
# install the artifact before adding it to the classpath.
|
43
|
-
#
|
44
|
-
# For example, Ant is loaded as follows:
|
45
|
-
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
46
|
-
#
|
47
|
-
# Artifacts can only be downloaded after the Buildfile has loaded, giving it
|
48
|
-
# a chance to specify which remote repositories to use, so adding to classpath
|
49
|
-
# does not by itself load any libraries. You must call Java.load before accessing
|
50
|
-
# any Java classes to give Buildr a chance to load the libraries specified in the
|
51
|
-
# classpath.
|
52
|
-
#
|
53
|
-
# When building an extension, make sure to follow these rules:
|
54
|
-
# 1. Add to the classpath when the extension is loaded (i.e. in module or class
|
55
|
-
# definition), so the first call to Java.load anywhere in the code will include
|
56
|
-
# the libraries you specify.
|
57
|
-
# 2. Call Java.load once before accessing any Java classes, allowing Buildr to
|
58
|
-
# set up the classpath.
|
59
|
-
# 3. Only call Java.load when invoked, otherwise you may end up loading the JVM
|
60
|
-
# with a partial classpath, or before all remote repositories are listed.
|
61
|
-
# 4. Check on a clean build with empty local repository.
|
62
|
-
module Java
|
63
|
-
|
64
|
-
module Package #:nodoc:
|
65
|
-
|
66
|
-
def method_missing(sym, *args, &block)
|
67
|
-
raise ArgumentError, 'No arguments expected' unless args.empty?
|
68
|
-
name = "#{@name}.#{sym}"
|
69
|
-
return ::Rjb.import(name) if sym.to_s =~ /^[[:upper:]]/
|
70
|
-
::Java.send :__package__, name
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
# On OS X we know where the default JDK is. We can try to guess for other OS.
|
76
|
-
# We set JAVA_HOME early so we can use it without calling Java.load first.
|
77
|
-
ENV['JAVA_HOME'] ||= '/System/Library/Frameworks/JavaVM.framework/Home' if Config::CONFIG['host_os'] =~ /darwin/i
|
78
|
-
|
79
|
-
class << self
|
80
|
-
|
81
|
-
# Returns the classpath, an array listing directories, JAR files and
|
82
|
-
# artifacts. Use when loading the extension to add any additional
|
83
|
-
# libraries used by that extension.
|
84
|
-
#
|
85
|
-
# For example, Ant is loaded as follows:
|
86
|
-
# Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
87
|
-
def classpath
|
88
|
-
@classpath ||= []
|
89
|
-
end
|
90
|
-
|
91
|
-
# Most platforms requires tools.jar to be on the classpath, tools.jar contains the
|
92
|
-
# Java compiler (OS X and AIX are two exceptions we know about, may be more).
|
93
|
-
# Guess where tools.jar is from JAVA_HOME, which hopefully points to the JDK,
|
94
|
-
# but maybe the JRE. Return nil if not found.
|
95
|
-
def tools_jar #:nodoc:
|
96
|
-
@tools_jar ||= begin
|
97
|
-
home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'
|
98
|
-
['lib/tools.jar', '../lib/tools.jar'].map { |path| File.expand_path(path, home) }.
|
99
|
-
find { |path| File.exist?(path) }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# Loads the JVM and all the libraries listed on the classpath. Call this
|
104
|
-
# method before accessing any Java class, but only call it from methods
|
105
|
-
# used in the build, giving the Buildfile a chance to load all extensions
|
106
|
-
# that append to the classpath and specify which remote repositories to use.
|
107
|
-
def load
|
108
|
-
return self if @loaded
|
109
|
-
classpath << tools_jar if tools_jar
|
110
|
-
|
111
|
-
classpath.map! { |path| Proc === path ? path.call : path }
|
112
|
-
cp = Buildr.artifacts(classpath).map(&:to_s).each { |path| file(path).invoke }
|
113
|
-
java_opts = (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split
|
114
|
-
::Rjb.load cp.join(File::PATH_SEPARATOR), java_opts
|
115
|
-
|
116
|
-
props = ::Rjb.import('java.lang.System').getProperties
|
117
|
-
enum = props.propertyNames
|
118
|
-
while enum.hasMoreElements
|
119
|
-
name = enum.nextElement.toString
|
120
|
-
ENV_JAVA[name] = props.getProperty(name)
|
121
|
-
end
|
122
|
-
@loaded = true
|
123
|
-
self
|
124
|
-
end
|
125
|
-
|
126
|
-
def method_missing(sym, *args, &block) #:nodoc:
|
127
|
-
raise ArgumentError, 'No arguments expected' unless args.empty?
|
128
|
-
name = sym.to_s
|
129
|
-
return ::Rjb.import(name) if name =~ /^[[:upper:]]/
|
130
|
-
__package__ name
|
131
|
-
end
|
132
|
-
|
133
|
-
private
|
134
|
-
|
135
|
-
def __package__(name) #:nodoc:
|
136
|
-
const = name.split('.').map { |part| part.gsub(/^./) { |char| char.upcase } }.join
|
137
|
-
return const_get(const) if const_defined?(const)
|
138
|
-
package = Module.new
|
139
|
-
package.extend Package
|
140
|
-
package.instance_variable_set :@name, name
|
141
|
-
const_set(const, package)
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
class Array
|
150
|
-
# Converts a Ruby array into a typed Java array, argument specifies the element type.
|
151
|
-
# This is necessary for JRuby and causes no harm on RJB.
|
152
|
-
def to_java(cls)
|
153
|
-
map { |item| cls.new(item) }
|
154
|
-
end
|
155
|
-
end
|
@@ -1,307 +0,0 @@
|
|
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 #:nodoc:
|
18
|
-
module TestFramework
|
19
|
-
|
20
|
-
# A class used by buildr for jruby based frameworks, so that buildr can know
|
21
|
-
# which tests succeeded/failed.
|
22
|
-
class TestResult
|
23
|
-
|
24
|
-
class Error < ::Exception
|
25
|
-
attr_reader :message, :backtrace
|
26
|
-
def initialize(message, backtrace)
|
27
|
-
@message = message
|
28
|
-
@backtrace = backtrace
|
29
|
-
set_backtrace backtrace
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.dump_yaml(file, e)
|
33
|
-
require 'fileutils'
|
34
|
-
FileUtils.mkdir_p(File.dirname(file))
|
35
|
-
File.open(file, 'w') { |f| f.puts(YAML.dump(Error.new(e.message, e.backtrace))) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.guard(file)
|
39
|
-
begin
|
40
|
-
yield
|
41
|
-
rescue
|
42
|
-
dump_yaml(file)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
attr_accessor :failed, :succeeded
|
48
|
-
|
49
|
-
def initialize
|
50
|
-
@failed, @succeeded = [], []
|
51
|
-
end
|
52
|
-
|
53
|
-
# An Rspec formatter used by buildr
|
54
|
-
class YamlFormatter
|
55
|
-
attr_reader :result
|
56
|
-
|
57
|
-
attr_accessor :example_group, :options, :where
|
58
|
-
|
59
|
-
def initialize(options, where)
|
60
|
-
@options = options
|
61
|
-
@where = where
|
62
|
-
@result = Hash.new
|
63
|
-
@result[:succeeded] = []
|
64
|
-
@result[:failed] = []
|
65
|
-
end
|
66
|
-
|
67
|
-
%w[ example_started
|
68
|
-
start_dump dump_failure dump_summary dump_pending ].each do |meth|
|
69
|
-
module_eval "def #{meth}(*args); end"
|
70
|
-
end
|
71
|
-
|
72
|
-
def add_example_group(example_group)
|
73
|
-
@example_group = example_group
|
74
|
-
end
|
75
|
-
|
76
|
-
def example_passed(example)
|
77
|
-
end
|
78
|
-
|
79
|
-
def example_pending(example, counter, failure)
|
80
|
-
end
|
81
|
-
|
82
|
-
def example_failed(example, counter, failure)
|
83
|
-
if example_group.respond_to?(:spec_path)
|
84
|
-
result.failed << example_group.spec_path.gsub(/:\d+$/, '')
|
85
|
-
else
|
86
|
-
path = path_from_bt(failure.exception.backtrace)
|
87
|
-
result.failed << path if path
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def start(example_count)
|
92
|
-
@result = TestResult.new
|
93
|
-
end
|
94
|
-
|
95
|
-
def path_from_bt(ary)
|
96
|
-
files = options.files
|
97
|
-
test = nil
|
98
|
-
ary.find do |bt|
|
99
|
-
bt = bt.split(':').first.strip
|
100
|
-
test = bt if files.include?(bt)
|
101
|
-
end
|
102
|
-
test
|
103
|
-
end
|
104
|
-
|
105
|
-
def close
|
106
|
-
files = options.files
|
107
|
-
result.succeeded = files - result.failed
|
108
|
-
|
109
|
-
FileUtils.mkdir_p(File.dirname(where))
|
110
|
-
File.open(where, 'w') { |f| f.puts YAML.dump(result) }
|
111
|
-
end
|
112
|
-
end # YamlFormatter
|
113
|
-
|
114
|
-
# A JtestR ResultHandler
|
115
|
-
# Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
|
116
|
-
# Created for YamlFormatter
|
117
|
-
class RSpecResultHandler
|
118
|
-
|
119
|
-
# Workaround for http://jira.codehaus.org/browse/JTESTR-68
|
120
|
-
module TestNGResultHandlerMixin
|
121
|
-
def onTestSuccess(test_result)
|
122
|
-
@result_handler.succeed_single(test_result.name)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
class BacktraceTweaker
|
127
|
-
attr_reader :ignore_patterns
|
128
|
-
def initialize
|
129
|
-
@ignore_patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS.dup
|
130
|
-
# ignore jruby/jtestr backtrace
|
131
|
-
ignore_patterns << /org\.jruby\.javasupport\.JavaMethod\./
|
132
|
-
ignore_patterns << /jtestr.*\.jar!/i << /runner\.rb/
|
133
|
-
end
|
134
|
-
|
135
|
-
def clean_up_double_slashes(line)
|
136
|
-
line.gsub!('//','/')
|
137
|
-
end
|
138
|
-
|
139
|
-
def tweak_backtrace(error)
|
140
|
-
return if error.backtrace.nil?
|
141
|
-
error.backtrace.collect! do |line|
|
142
|
-
clean_up_double_slashes(line)
|
143
|
-
ignore_patterns.each do |ignore|
|
144
|
-
if line =~ ignore
|
145
|
-
line = nil
|
146
|
-
break
|
147
|
-
end
|
148
|
-
end
|
149
|
-
line
|
150
|
-
end
|
151
|
-
error.backtrace.compact!
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
class << self
|
156
|
-
# an rspec reporter used to proxy events to rspec formatters
|
157
|
-
attr_reader :reporter
|
158
|
-
|
159
|
-
def init(argv = [], out = STDOUT, err = STDERR)
|
160
|
-
::JtestR::TestNGResultHandler.module_eval { include TestNGResultHandlerMixin }
|
161
|
-
rspec_parser = ::Spec::Runner::OptionParser.new(err, out)
|
162
|
-
rspec_parser.order!(argv)
|
163
|
-
rspec_parser.options.backtrace_tweaker = BacktraceTweaker.new
|
164
|
-
@reporter = Spec::Runner::Reporter.new(rspec_parser.options)
|
165
|
-
end
|
166
|
-
|
167
|
-
def before
|
168
|
-
reporter.start(reporter.options.files.size)
|
169
|
-
end
|
170
|
-
|
171
|
-
def after
|
172
|
-
reporter.end
|
173
|
-
reporter.dump
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
module ExampleMethods
|
178
|
-
attr_accessor :name, :description, :__full_description
|
179
|
-
end
|
180
|
-
|
181
|
-
def reporter
|
182
|
-
self.class.reporter
|
183
|
-
end
|
184
|
-
|
185
|
-
attr_accessor :example_group, :current_example, :current_failure
|
186
|
-
|
187
|
-
def initialize(name, desc, *args)
|
188
|
-
self.example_group = ::Spec::Example::ExampleGroup.new(desc)
|
189
|
-
example_group.extend ExampleMethods
|
190
|
-
example_group.name = name.to_s
|
191
|
-
if example_group.name[/Spec/]
|
192
|
-
example_group.description = desc.to_s
|
193
|
-
else
|
194
|
-
example_group.description = name.to_s
|
195
|
-
end
|
196
|
-
reporter.add_example_group(example_group)
|
197
|
-
end
|
198
|
-
|
199
|
-
def starting
|
200
|
-
end
|
201
|
-
|
202
|
-
def ending
|
203
|
-
end
|
204
|
-
|
205
|
-
def add_fault(fault)
|
206
|
-
self.current_failure = fault
|
207
|
-
end
|
208
|
-
|
209
|
-
def add_pending(pending)
|
210
|
-
end
|
211
|
-
|
212
|
-
def starting_single(name = nil)
|
213
|
-
self.current_failure = nil
|
214
|
-
self.current_example = Object.new
|
215
|
-
current_example.extend ::Spec::Example::ExampleMethods
|
216
|
-
current_example.extend ExampleMethods
|
217
|
-
name = name.to_s
|
218
|
-
name[/\((pen?ding|error|failure|success)\)?$/]
|
219
|
-
name = $`
|
220
|
-
current_example.description = name
|
221
|
-
if example_group.name[/Spec/]
|
222
|
-
current_example.__full_description = "#{example_group.description} #{name}"
|
223
|
-
else
|
224
|
-
current_example.__full_description = "#{example_group.name}: #{name}"
|
225
|
-
end
|
226
|
-
reporter.example_started(current_example)
|
227
|
-
#puts "STARTED #{name} #{current_example.__full_description}"
|
228
|
-
end
|
229
|
-
|
230
|
-
def succeed_single(name = nil)
|
231
|
-
#puts "SUCC SINGLE #{name}"
|
232
|
-
reporter.example_finished(current_example, nil)
|
233
|
-
end
|
234
|
-
|
235
|
-
def fail_single(name = nil)
|
236
|
-
#puts "FAIL SINGLE #{name}"
|
237
|
-
reporter.example_finished(current_example, current_error)
|
238
|
-
end
|
239
|
-
|
240
|
-
def error_single(name = nil)
|
241
|
-
#puts "ERR SINGLE #{name}"
|
242
|
-
reporter.example_finished(current_example, current_error)
|
243
|
-
end
|
244
|
-
|
245
|
-
def pending_single(name = nil)
|
246
|
-
#puts "PEND SINGLE #{name}"
|
247
|
-
error = ::Spec::Example::ExamplePendingError.new(name)
|
248
|
-
reporter.example_finished(current_example, error)
|
249
|
-
end
|
250
|
-
|
251
|
-
private
|
252
|
-
def current_error(fault = current_failure)
|
253
|
-
case fault
|
254
|
-
when nil
|
255
|
-
nil
|
256
|
-
when Test::Unit::Failure
|
257
|
-
Error.new(fault.message, fault.location)
|
258
|
-
when Test::Unit::Error
|
259
|
-
if fault.exception.is_a?(NativeException)
|
260
|
-
exception = fault.exception.cause
|
261
|
-
bt = exception.stack_trace.to_a
|
262
|
-
else
|
263
|
-
exception = fault.exception
|
264
|
-
bt = exception.backtrace
|
265
|
-
end
|
266
|
-
Error.new(exception.message, bt)
|
267
|
-
when Expectations::Results::Error
|
268
|
-
fault.exception
|
269
|
-
when Spec::Runner::Reporter::Failure
|
270
|
-
ex = fault.exception
|
271
|
-
fault.example.instance_variable_get(:@_implementation).to_s =~ /@(.+:\d+)/
|
272
|
-
Error.new(ex.message, [$1.to_s] + ex.backtrace)
|
273
|
-
when Expectations::Results
|
274
|
-
file = fault.file
|
275
|
-
line = fault.line
|
276
|
-
Error.new(fault.message, ["#{fault.file}:#{fault.line}"])
|
277
|
-
else
|
278
|
-
if fault.respond_to?(:test_header)
|
279
|
-
fault.test_header[/\((.+)\)/]
|
280
|
-
test_cls, test_meth = $1.to_s, $`.to_s
|
281
|
-
exception = fault.exception
|
282
|
-
(class << exception; self; end).module_eval do
|
283
|
-
define_method(:backtrace) do
|
284
|
-
(["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
|
285
|
-
end
|
286
|
-
end
|
287
|
-
exception
|
288
|
-
elsif fault.respond_to?(:method)
|
289
|
-
test_cls, test_meth = fault.method.test_class.name, fault.method.method_name
|
290
|
-
exception = fault.throwable
|
291
|
-
(class << exception; self; end).module_eval do
|
292
|
-
define_method(:backtrace) do
|
293
|
-
(["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
|
294
|
-
end
|
295
|
-
end
|
296
|
-
exception
|
297
|
-
else
|
298
|
-
raise "Cannot handle fault #{fault.class}: #{fault.inspect}"
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
end # RSpecResultHandler
|
304
|
-
|
305
|
-
end # TestResult
|
306
|
-
end
|
307
|
-
end
|