buildr 1.3.3-java → 1.3.4-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +76 -0
- data/NOTICE +1 -1
- data/README.rdoc +9 -21
- data/Rakefile +17 -34
- data/_buildr +3 -12
- data/{doc/print.toc.yaml → _jbuildr} +14 -14
- data/addon/buildr/cobertura.rb +5 -219
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +5 -221
- data/addon/buildr/nailgun.rb +93 -689
- data/bin/buildr +0 -9
- data/buildr.buildfile +4 -4
- data/buildr.gemspec +27 -21
- data/doc/_layouts/default.html +82 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/{pages/artifacts.textile → artifacts.textile} +82 -42
- data/doc/{pages/building.textile → building.textile} +89 -47
- data/doc/{pages/contributing.textile → contributing.textile} +53 -45
- data/doc/css/default.css +6 -5
- data/doc/css/print.css +17 -24
- data/doc/css/syntax.css +7 -36
- data/doc/download.textile +68 -0
- data/doc/{pages/extending.textile → extending.textile} +45 -24
- data/doc/{pages/getting_started.textile → getting_started.textile} +158 -88
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/note.png +0 -0
- data/doc/index.textile +47 -0
- data/doc/{pages/languages.textile → languages.textile} +108 -54
- data/doc/mailing_lists.textile +25 -0
- data/doc/{pages/more_stuff.textile → more_stuff.textile} +152 -73
- data/doc/{pages/packaging.textile → packaging.textile} +181 -96
- data/doc/preface.textile +28 -0
- data/doc/{pages/projects.textile → projects.textile} +55 -40
- data/doc/scripts/buildr-git.rb +364 -264
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +2 -2
- data/doc/scripts/install-linux.sh +6 -6
- data/doc/scripts/install-osx.sh +2 -2
- data/doc/{pages/settings_profiles.textile → settings_profiles.textile} +83 -45
- data/doc/{pages/testing.textile → testing.textile} +77 -41
- data/lib/buildr.rb +5 -5
- data/lib/buildr/core.rb +2 -0
- data/lib/buildr/core/application.rb +321 -151
- data/lib/buildr/core/build.rb +298 -167
- data/lib/buildr/core/checks.rb +4 -132
- data/lib/buildr/core/common.rb +1 -5
- data/lib/buildr/core/compile.rb +3 -9
- data/lib/buildr/core/environment.rb +12 -3
- data/lib/buildr/core/filter.rb +20 -18
- data/lib/buildr/core/generate.rb +36 -36
- data/lib/buildr/core/help.rb +2 -1
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +7 -34
- data/lib/buildr/core/test.rb +12 -6
- data/lib/buildr/core/transports.rb +13 -11
- data/lib/buildr/core/util.rb +14 -23
- data/lib/buildr/groovy/bdd.rb +3 -2
- data/lib/buildr/groovy/compiler.rb +1 -1
- data/lib/buildr/ide/eclipse.rb +31 -21
- data/lib/buildr/ide/idea.rb +3 -2
- data/lib/buildr/ide/idea7x.rb +6 -4
- data/lib/buildr/java/ant.rb +3 -1
- data/lib/buildr/java/bdd.rb +9 -7
- data/lib/buildr/java/cobertura.rb +243 -0
- data/lib/buildr/java/compiler.rb +5 -4
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/packaging.rb +11 -8
- data/lib/buildr/java/pom.rb +0 -4
- data/lib/buildr/java/rjb.rb +1 -1
- data/lib/buildr/java/test_result.rb +5 -7
- data/lib/buildr/java/tests.rb +17 -11
- data/lib/buildr/packaging.rb +5 -2
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +48 -29
- data/lib/buildr/packaging/artifact_namespace.rb +6 -6
- data/lib/buildr/packaging/gems.rb +4 -4
- data/lib/buildr/packaging/package.rb +3 -2
- data/lib/buildr/packaging/tar.rb +85 -3
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +24 -682
- data/lib/buildr/packaging/ziptask.rb +313 -0
- data/lib/buildr/scala.rb +5 -0
- data/lib/buildr/scala/bdd.rb +100 -0
- data/lib/buildr/scala/compiler.rb +45 -4
- data/lib/buildr/scala/tests.rb +12 -59
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +58 -68
- data/rakelib/jekylltask.rb +110 -0
- data/rakelib/package.rake +35 -37
- data/rakelib/release.rake +119 -35
- data/rakelib/rspec.rake +29 -39
- data/rakelib/setup.rake +21 -59
- data/rakelib/stage.rake +184 -26
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +32 -25
- data/spec/core/build_spec.rb +336 -126
- data/spec/core/checks_spec.rb +292 -310
- data/spec/core/common_spec.rb +8 -2
- data/spec/core/compile_spec.rb +17 -1
- data/spec/core/generate_spec.rb +3 -3
- data/spec/core/project_spec.rb +18 -10
- data/spec/core/test_spec.rb +8 -1
- data/spec/core/transport_spec.rb +40 -3
- data/spec/core/util_spec.rb +67 -0
- data/spec/ide/eclipse_spec.rb +96 -28
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant.rb +5 -0
- data/spec/java/bdd_spec.rb +12 -3
- data/spec/{addon → java}/cobertura_spec.rb +6 -6
- data/spec/{addon → java}/emma_spec.rb +5 -6
- data/spec/java/java_spec.rb +12 -2
- data/spec/java/packaging_spec.rb +31 -2
- data/spec/{addon → java}/test_coverage_spec.rb +3 -3
- data/spec/java/tests_spec.rb +5 -0
- data/spec/packaging/archive_spec.rb +11 -1
- data/spec/{core → packaging}/artifact_namespace_spec.rb +10 -2
- data/spec/packaging/artifact_spec.rb +44 -3
- data/spec/packaging/packaging_spec.rb +1 -1
- data/spec/sandbox.rb +17 -14
- data/spec/scala/bdd_spec.rb +150 -0
- data/spec/scala/compiler_spec.rb +27 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +78 -33
- data/spec/spec_helpers.rb +29 -5
- data/spec/version_requirement_spec.rb +6 -0
- metadata +176 -172
- data/DISCLAIMER +0 -7
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/pages/download.textile +0 -51
- data/doc/pages/index.textile +0 -42
- data/doc/pages/mailing_lists.textile +0 -17
- data/doc/pages/recipes.textile +0 -103
- data/doc/pages/troubleshooting.textile +0 -103
- data/doc/pages/whats_new.textile +0 -323
- data/doc/print.haml +0 -51
- data/doc/site.haml +0 -56
- data/doc/site.toc.yaml +0 -47
- data/etc/git-svn-authors +0 -16
- data/lib/buildr/core/application_cli.rb +0 -139
- data/rakelib/apache.rake +0 -191
- data/rakelib/changelog.rake +0 -57
- data/rakelib/rubyforge.rake +0 -53
- data/rakelib/scm.rake +0 -49
data/addon/buildr/drb.rb
ADDED
@@ -0,0 +1,281 @@
|
|
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 'delegate'
|
18
|
+
require 'drb/drb'
|
19
|
+
|
20
|
+
|
21
|
+
module Buildr
|
22
|
+
|
23
|
+
# This addon allows you start a DRb server hosting a buildfile, so that
|
24
|
+
# you can later invoke tasks on it without having to load
|
25
|
+
# the complete buildr runtime again.
|
26
|
+
#
|
27
|
+
# Usage:
|
28
|
+
#
|
29
|
+
# buildr -r buildr/drb drb:start
|
30
|
+
#
|
31
|
+
# Once the server has been started you can invoke tasks using a simple script:
|
32
|
+
#
|
33
|
+
# #!/usr/bin/env ruby
|
34
|
+
# require 'rubygems'
|
35
|
+
# require 'buildr/drb'
|
36
|
+
# Buildr::DRbApplication.run
|
37
|
+
#
|
38
|
+
# Save this script as 'dbuildr', make it executable and use it to invoke tasks.
|
39
|
+
#
|
40
|
+
# dbuildr clean compile
|
41
|
+
#
|
42
|
+
# The dbuildr script will run as the server if there isn't one already running.
|
43
|
+
# Subsequent calls to dbuildr will act as the client and invoke the tasks you
|
44
|
+
# provide in the server.
|
45
|
+
# If the buildfile has been modified it will be reloaded on the BuildrServer.
|
46
|
+
#
|
47
|
+
# JRuby users can use a nailgun client to invoke tasks as fast as possible
|
48
|
+
# without having to incur JVM startup time.
|
49
|
+
# See the documentation for buildr/nailgun.
|
50
|
+
module DRbApplication
|
51
|
+
|
52
|
+
port = ENV['DRB_PORT'] || 2111
|
53
|
+
PORT = port.to_i
|
54
|
+
|
55
|
+
class SavedTask #:nodoc:
|
56
|
+
|
57
|
+
def initialize(original)
|
58
|
+
@original = original.clone
|
59
|
+
@prerequisites = original.prerequisites.clone if original.respond_to?(:prerequisites)
|
60
|
+
@actions = original.actions.clone if original.respond_to?(:actions)
|
61
|
+
end
|
62
|
+
|
63
|
+
def name
|
64
|
+
@original.name
|
65
|
+
end
|
66
|
+
|
67
|
+
def actions
|
68
|
+
@actions ||= []
|
69
|
+
end
|
70
|
+
|
71
|
+
def prerequisites
|
72
|
+
@prerequisites ||= []
|
73
|
+
end
|
74
|
+
|
75
|
+
def define!
|
76
|
+
@original.class.send(:define_task, @original.name => prerequisites).tap do |task|
|
77
|
+
task.comment = @original.comment
|
78
|
+
actions.each { |action| task.enhance &action }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end # SavedTask
|
82
|
+
|
83
|
+
class Snapshot #:nodoc:
|
84
|
+
|
85
|
+
attr_accessor :projects, :tasks, :rules, :layout, :options
|
86
|
+
|
87
|
+
# save the tasks,rules,layout defined by buildr
|
88
|
+
def initialize
|
89
|
+
@rules = Buildr.application.instance_eval { @rules || [] }.clone
|
90
|
+
@options = Buildr.application.options.clone
|
91
|
+
@options.rakelib ||= ['tasks']
|
92
|
+
@layout = Layout.default.clone
|
93
|
+
@projects = Project.instance_eval { @projects || {} }.clone
|
94
|
+
@tasks = Buildr.application.tasks.inject({}) do |hash, original|
|
95
|
+
unless projects.key? original.name # don't save project definitions
|
96
|
+
hash.update original.name => SavedTask.new(original)
|
97
|
+
end
|
98
|
+
hash
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end # Snapshot
|
103
|
+
|
104
|
+
class << self
|
105
|
+
|
106
|
+
attr_accessor :original, :snapshot
|
107
|
+
|
108
|
+
def run
|
109
|
+
begin
|
110
|
+
client = connect
|
111
|
+
rescue DRb::DRbConnError => e
|
112
|
+
run_server!
|
113
|
+
else
|
114
|
+
run_client(client)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def client_uri
|
119
|
+
"druby://:#{PORT + 1}"
|
120
|
+
end
|
121
|
+
|
122
|
+
def remote_run(cfg)
|
123
|
+
with_config(cfg) { Buildr.application.remote_run(self) }
|
124
|
+
rescue => e
|
125
|
+
cfg[:err].puts e.message
|
126
|
+
e.backtrace.each { |b| cfg[:err].puts "\tfrom #{b}" }
|
127
|
+
raise e
|
128
|
+
end
|
129
|
+
|
130
|
+
def save_snapshot(app)
|
131
|
+
if app.instance_eval { @rakefile }
|
132
|
+
@snapshot = self::Snapshot.new
|
133
|
+
app.buildfile_reloaded!
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
def server_uri
|
140
|
+
"druby://:#{PORT}"
|
141
|
+
end
|
142
|
+
|
143
|
+
def connect
|
144
|
+
buildr = DRbObject.new(nil, server_uri)
|
145
|
+
uri = buildr.client_uri # obtain our uri from the server
|
146
|
+
DRb.start_service(uri)
|
147
|
+
buildr
|
148
|
+
end
|
149
|
+
|
150
|
+
def run_client(client)
|
151
|
+
client.remote_run :dir => Dir.pwd, :argv => ARGV,
|
152
|
+
:in => $stdin, :out => $stdout, :err => $stderr
|
153
|
+
end
|
154
|
+
|
155
|
+
def setup
|
156
|
+
unless original
|
157
|
+
# Create the stdio delegator that can be cached (eg by fileutils)
|
158
|
+
delegate_stdio
|
159
|
+
|
160
|
+
# Lazily load buildr the first time it's needed
|
161
|
+
require 'buildr'
|
162
|
+
|
163
|
+
# Save the tasks,rules,layout defined by buildr
|
164
|
+
# before loading any project
|
165
|
+
@original = self::Snapshot.new
|
166
|
+
|
167
|
+
Buildr.application.extend self
|
168
|
+
save_snapshot(Buildr.application)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def run_server
|
173
|
+
setup
|
174
|
+
DRb.start_service(server_uri, self)
|
175
|
+
puts "#{self} waiting on #{server_uri}"
|
176
|
+
end
|
177
|
+
|
178
|
+
def run_server!
|
179
|
+
setup
|
180
|
+
if RUBY_PLATFORM[/java/]
|
181
|
+
require 'buildr/nailgun'
|
182
|
+
Buildr.application['nailgun:drb'].invoke
|
183
|
+
else
|
184
|
+
run_server
|
185
|
+
DRb.thread.join
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def delegate_stdio
|
190
|
+
$stdin = SimpleDelegator.new($stdin)
|
191
|
+
$stdout = SimpleDelegator.new($stdout)
|
192
|
+
$stderr = SimpleDelegator.new($stderr)
|
193
|
+
end
|
194
|
+
|
195
|
+
def with_config(remote)
|
196
|
+
@invoked = true
|
197
|
+
set = lambda do |env|
|
198
|
+
ARGV.replace env[:argv]
|
199
|
+
$stdin.__setobj__(env[:in])
|
200
|
+
$stdout.__setobj__(env[:out])
|
201
|
+
$stderr.__setobj__(env[:err])
|
202
|
+
Buildr.application.instance_variable_set :@original_dir, env[:dir]
|
203
|
+
end
|
204
|
+
original = {
|
205
|
+
:dir => Buildr.application.instance_variable_get(:@original_dir),
|
206
|
+
:argv => ARGV,
|
207
|
+
:in => $stdin.__getobj__,
|
208
|
+
:out => $stdout.__getobj__,
|
209
|
+
:err => $stderr.__getobj__
|
210
|
+
}
|
211
|
+
begin
|
212
|
+
set[remote]
|
213
|
+
yield
|
214
|
+
ensure
|
215
|
+
set[original]
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
end # class << DRbApplication
|
220
|
+
|
221
|
+
def remote_run(server)
|
222
|
+
@options = server.original.options.clone
|
223
|
+
init 'Distributed Buildr'
|
224
|
+
if @rakefile
|
225
|
+
if buildfile_needs_reload?
|
226
|
+
reload_buildfile(server, server.original)
|
227
|
+
else
|
228
|
+
clear_invoked_tasks(server.snapshot || server.original)
|
229
|
+
end
|
230
|
+
else
|
231
|
+
reload_buildfile(server, server.original)
|
232
|
+
end
|
233
|
+
top_level
|
234
|
+
end
|
235
|
+
|
236
|
+
def buildfile_reloaded!
|
237
|
+
@last_loaded = buildfile.timestamp if @rakefile
|
238
|
+
end
|
239
|
+
|
240
|
+
private
|
241
|
+
|
242
|
+
def buildfile_needs_reload?
|
243
|
+
!@last_loaded || @last_loaded < buildfile.timestamp
|
244
|
+
end
|
245
|
+
|
246
|
+
def reload_buildfile(server, snapshot)
|
247
|
+
clear_for_reload(snapshot)
|
248
|
+
load_buildfile
|
249
|
+
server.save_snapshot(self)
|
250
|
+
end
|
251
|
+
|
252
|
+
def clear_for_reload(snapshot)
|
253
|
+
Project.clear
|
254
|
+
@tasks = {}
|
255
|
+
@rules = snapshot.rules.clone
|
256
|
+
snapshot.tasks.each_pair { |name, saved| saved.define! }
|
257
|
+
Layout.default = snapshot.layout.clone
|
258
|
+
end
|
259
|
+
|
260
|
+
def clear_invoked_tasks(snapshot)
|
261
|
+
@rules = snapshot.rules.clone
|
262
|
+
(@tasks.keys - snapshot.projects.keys).each do |name|
|
263
|
+
if saved = snapshot.tasks[name]
|
264
|
+
# reenable this task, restoring its actions/prereqs
|
265
|
+
task = @tasks[name]
|
266
|
+
task.reenable
|
267
|
+
task.prerequisites.replace saved.prerequisites.clone
|
268
|
+
task.actions.replace saved.actions.clone
|
269
|
+
else
|
270
|
+
# tasks generated at runtime, drop it
|
271
|
+
@tasks.delete(name)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
task('drb:start') { run_server! } if Buildr.respond_to?(:application)
|
277
|
+
|
278
|
+
end # DRbApplication
|
279
|
+
|
280
|
+
end
|
281
|
+
|
data/addon/buildr/emma.rb
CHANGED
@@ -14,225 +14,9 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# Provides the <code>emma:html</code> and <code>emma:xml</code> tasks.
|
23
|
-
# Require explicitly using <code>require "buildr/emma"</code>.
|
24
|
-
#
|
25
|
-
# You can generate emma reports for a single project
|
26
|
-
# using the project name as prefix:
|
27
|
-
#
|
28
|
-
# project_name:emma:html
|
29
|
-
#
|
30
|
-
# You can also specify which classes to include/exclude from instrumentation by
|
31
|
-
# passing a class name regexp to the <code>emma.include</code> or
|
32
|
-
# <code>emma.exclude</code> methods.
|
33
|
-
#
|
34
|
-
# define 'someModule' do
|
35
|
-
# emma.include 'some.package.*'
|
36
|
-
# emma.exclude 'some.foo.util.SimpleUtil'
|
37
|
-
# end
|
38
|
-
module Emma
|
39
|
-
|
40
|
-
class << self
|
41
|
-
|
42
|
-
REQUIRES = ['emma:emma_ant:jar:2.0.5312', 'emma:emma:jar:2.0.5312'] unless const_defined?('REQUIRES')
|
43
|
-
|
44
|
-
def requires()
|
45
|
-
@requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
|
46
|
-
end
|
47
|
-
|
48
|
-
def report_to format=nil
|
49
|
-
File.expand_path('reports/emma')
|
50
|
-
end
|
51
|
-
|
52
|
-
def data_file()
|
53
|
-
File.join(report_to, 'coverage.es')
|
54
|
-
end
|
55
|
-
|
56
|
-
def ant
|
57
|
-
Buildr.ant 'emma' do |ant|
|
58
|
-
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>'emma_ant.properties'
|
59
|
-
ant.emma :verbosity=>(Buildr.application.options.trace ? 'verbose' : 'warning') do
|
60
|
-
yield ant
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
class EmmaConfig # :nodoc:
|
67
|
-
|
68
|
-
def initialize(project)
|
69
|
-
@project = project
|
70
|
-
end
|
71
|
-
|
72
|
-
attr_reader :project
|
73
|
-
private :project
|
74
|
-
|
75
|
-
attr_writer :metadata_file, :coverage_file, :instrumented_dir, :report_dir
|
76
|
-
|
77
|
-
def coverage_file
|
78
|
-
@coverage_file ||= File.join(report_dir, 'coverage.ec')
|
79
|
-
end
|
80
|
-
|
81
|
-
def metadata_file
|
82
|
-
@metadata_file ||= File.join(report_dir, 'coverage.em')
|
83
|
-
end
|
84
|
-
|
85
|
-
def instrumented_dir
|
86
|
-
@instrumented_dir ||= project.path_to(:target, :instrumented, :classes)
|
87
|
-
end
|
88
|
-
|
89
|
-
def report_dir
|
90
|
-
@report_dir ||= project.path_to(:reports, :emma)
|
91
|
-
end
|
92
|
-
|
93
|
-
def report_to format
|
94
|
-
report_dir
|
95
|
-
end
|
96
|
-
|
97
|
-
# :call-seq:
|
98
|
-
# project.emma.include(*classPatterns)
|
99
|
-
#
|
100
|
-
def include(*classPatterns)
|
101
|
-
includes.push(*classPatterns)
|
102
|
-
self
|
103
|
-
end
|
104
|
-
|
105
|
-
def includes
|
106
|
-
@includeClasses ||= []
|
107
|
-
end
|
108
|
-
|
109
|
-
# :call-seq:
|
110
|
-
# project.emma.exclude(*classPatterns)
|
111
|
-
#
|
112
|
-
def exclude(*classPatterns)
|
113
|
-
excludes.push(*classPatterns)
|
114
|
-
self
|
115
|
-
end
|
116
|
-
|
117
|
-
def excludes
|
118
|
-
@excludeClasses ||= []
|
119
|
-
end
|
120
|
-
|
121
|
-
def sources
|
122
|
-
project.compile.sources
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
module EmmaExtension # :nodoc:
|
127
|
-
include Buildr::Extension
|
128
|
-
|
129
|
-
def emma
|
130
|
-
@emma_config ||= EmmaConfig.new(self)
|
131
|
-
end
|
132
|
-
|
133
|
-
after_define do |project|
|
134
|
-
emma = project.emma
|
135
|
-
|
136
|
-
namespace 'emma' do
|
137
|
-
unless project.compile.target.nil?
|
138
|
-
# Instrumented bytecode goes in a different directory. This task creates before running the test
|
139
|
-
# cases and monitors for changes in the generate bytecode.
|
140
|
-
instrumented = project.file(emma.instrumented_dir => project.compile.target) do |task|
|
141
|
-
unless project.compile.sources.empty?
|
142
|
-
info "Instrumenting classes with emma metadata file #{emma.metadata_file}"
|
143
|
-
Emma.ant do |ant|
|
144
|
-
ant.instr :instrpath=>project.compile.target.to_s, :destdir=>task.to_s, :metadatafile=>emma.metadata_file do
|
145
|
-
ant.filter :includes=>emma.includes.join(', ') unless emma.includes.empty?
|
146
|
-
ant.filter :excludes=>emma.excludes.join(', ') unless emma.excludes.empty?
|
147
|
-
end
|
148
|
-
end
|
149
|
-
touch task.to_s, :verbose=>false
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
task 'instrument' => instrumented
|
154
|
-
|
155
|
-
# We now have two target directories with bytecode.
|
156
|
-
project.test.dependencies.unshift emma.instrumented_dir
|
157
|
-
project.test.with Emma.requires
|
158
|
-
project.test.options[:properties]["emma.coverage.out.file"] = emma.coverage_file
|
159
|
-
|
160
|
-
[:xml, :html].each do |format|
|
161
|
-
task format => ['instrument', 'test'] do
|
162
|
-
missing_required_files = [emma.metadata_file, emma.coverage_file].reject { |f| File.exist?(f) }
|
163
|
-
if missing_required_files.empty?
|
164
|
-
info "Creating test coverage reports in #{emma.report_dir}"
|
165
|
-
mkdir_p emma.report_dir, :verbose=>false
|
166
|
-
Emma.ant do |ant|
|
167
|
-
ant.report do
|
168
|
-
ant.infileset :file=>emma.metadata_file
|
169
|
-
ant.infileset :file=>emma.coverage_file
|
170
|
-
ant.send format, :outfile=>File.join(emma.report_to(format),"coverage.#{format}")
|
171
|
-
ant.sourcepath do
|
172
|
-
emma.sources.flatten.each do |src|
|
173
|
-
ant.dirset(:dir=>src.to_s) if File.exist?(src.to_s)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
else
|
179
|
-
info "No test coverage report for #{project}. Missing: #{missing_required_files.join(', ')}"
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
project.clean do
|
187
|
-
rm_rf [emma.report_dir, emma.coverage_file, emma.metadata_file, emma.instrumented_dir], :verbose=>false
|
188
|
-
end
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
end
|
193
|
-
|
194
|
-
class Buildr::Project
|
195
|
-
include EmmaExtension
|
196
|
-
end
|
197
|
-
|
198
|
-
namespace "emma" do
|
199
|
-
|
200
|
-
Project.local_task('instrument') { |name| "Instrumenting #{name}" }
|
201
|
-
|
202
|
-
[:xml, :html].each do |format|
|
203
|
-
desc "Run the test cases and produce code coverage reports in #{format}"
|
204
|
-
task format => ['instrument', 'test'] do
|
205
|
-
info "Creating test coverage reports in #{format}"
|
206
|
-
mkdir_p report_to(format), :verbose=>false
|
207
|
-
Emma.ant do |ant|
|
208
|
-
ant.merge :outfile=>data_file do
|
209
|
-
Buildr.projects.each do |project|
|
210
|
-
[project.emma.metadata_file, project.emma.coverage_file].each do |data_file|
|
211
|
-
ant.fileset :file=>data_file if File.exist?(data_file)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
ant.report do
|
216
|
-
ant.infileset :file=>data_file
|
217
|
-
ant.send format, :outfile=>File.join(report_to(format), "coverage.#{format}")
|
218
|
-
ant.sourcepath do
|
219
|
-
Buildr.projects.map(&:emma).map(&:sources).flatten.map(&:to_s).each do |src|
|
220
|
-
ant.dirset :dir=>src if File.exist?(src)
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
task :clean do
|
229
|
-
rm_rf [report_to, data_file], :verbose=>false
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
task :clean do
|
234
|
-
task('emma:clean').invoke if Dir.pwd == Rake.application.original_dir
|
235
|
-
end
|
236
|
-
|
237
|
-
end
|
17
|
+
if Buildr::VERSION < '1.5'
|
18
|
+
Buildr.application.deprecated "'buildr/emma', use 'buildr/java/emma' instead"
|
19
|
+
require 'buildr/java/emma'
|
20
|
+
else
|
21
|
+
raise "#{__FILE__} should be removed since its use is deprecated since version 1.3.4"
|
238
22
|
end
|