buildr 1.3.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +998 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +45 -0
- data/_buildr +29 -0
- data/_jbuildr +29 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +90 -0
- 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 +41 -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/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +65 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +88 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +211 -0
- data/doc/building.textile +244 -0
- data/doc/contributing.textile +252 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +79 -0
- data/doc/extending.textile +186 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-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.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +69 -0
- data/doc/installing.textile +266 -0
- data/doc/languages.textile +459 -0
- data/doc/mailing_lists.textile +25 -0
- data/doc/more_stuff.textile +457 -0
- data/doc/packaging.textile +430 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +271 -0
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +72 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +280 -0
- data/doc/testing.textile +222 -0
- data/etc/KEYS +151 -0
- data/lib/buildr.rb +36 -0
- data/lib/buildr/core.rb +35 -0
- data/lib/buildr/core/application.rb +656 -0
- data/lib/buildr/core/build.rb +452 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +608 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +866 -0
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +723 -0
- data/lib/buildr/core/transports.rb +559 -0
- data/lib/buildr/core/util.rb +449 -0
- data/lib/buildr/groovy.rb +19 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +334 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +190 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +212 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +459 -0
- data/lib/buildr/java/cobertura.rb +274 -0
- data/lib/buildr/java/commands.rb +213 -0
- data/lib/buildr/java/compiler.rb +349 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/jruby.rb +117 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
- data/lib/buildr/java/packaging.rb +716 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +353 -0
- data/lib/buildr/java/tests.rb +333 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +749 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +238 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +73 -0
- data/lib/buildr/packaging/ziptask.rb +316 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +25 -0
- data/lib/buildr/scala/bdd.rb +109 -0
- data/lib/buildr/scala/compiler.rb +195 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +157 -0
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +92 -0
- data/rakelib/jekylltask.rb +120 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +149 -0
- data/rakelib/rspec.rake +73 -0
- data/rakelib/setup.rake +54 -0
- data/rakelib/stage.rake +213 -0
- data/rakelib/stage.rake~ +213 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +502 -0
- data/spec/core/build_spec.rb +677 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +583 -0
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +762 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +537 -0
- data/spec/core/util_spec.rb +67 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +240 -0
- data/spec/ide/eclipse_spec.rb +501 -0
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant_spec.rb +33 -0
- data/spec/java/bdd_spec.rb +382 -0
- data/spec/java/cobertura_spec.rb +85 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +119 -0
- data/spec/java/java_spec.rb +124 -0
- data/spec/java/packaging_spec.rb +1134 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +493 -0
- data/spec/packaging/archive_spec.rb +527 -0
- data/spec/packaging/artifact_namespace_spec.rb +654 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +684 -0
- data/spec/sandbox.rb +142 -0
- data/spec/scala/bdd_spec.rb +119 -0
- data/spec/scala/compiler_spec.rb +284 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +261 -0
- data/spec/spec_helpers.rb +340 -0
- data/spec/version_requirement_spec.rb +129 -0
- metadata +383 -0
@@ -0,0 +1,22 @@
|
|
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
|
+
if Buildr::VERSION < '1.5'
|
18
|
+
Buildr.application.deprecated "'buildr/cobertura', use 'buildr/java/cobertura' instead"
|
19
|
+
require 'buildr/java/cobertura'
|
20
|
+
else
|
21
|
+
raise "#{__FILE__} should be removed since its use is deprecated since version 1.3.4"
|
22
|
+
end
|
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
|
+
|
@@ -0,0 +1,22 @@
|
|
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
|
+
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"
|
22
|
+
end
|
@@ -0,0 +1,142 @@
|
|
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/java'
|
18
|
+
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
|
22
|
+
# Provides Hibernate Doclet and schema export tasks. Require explicitly using <code>require "buildr/hibernate"</code>.
|
23
|
+
module Hibernate
|
24
|
+
|
25
|
+
REQUIRES = Buildr.struct(
|
26
|
+
:collections => "commons-collections:commons-collections:jar:3.1",
|
27
|
+
:logging => "commons-logging:commons-logging:jar:1.0.3",
|
28
|
+
:dom4j => "dom4j:dom4j:jar:1.6.1",
|
29
|
+
:hibernate => "org.hibernate:hibernate:jar:3.1.2",
|
30
|
+
:xdoclet => Buildr.group("xdoclet", "xdoclet-xdoclet-module", "xdoclet-hibernate-module",
|
31
|
+
# :under=>"xdoclet", :version=>"1.2.3") + ["xdoclet:xjavadoc:jar:1.1-j5"]
|
32
|
+
:under=>"xdoclet", :version=>"1.2.3") + ["xdoclet:xjavadoc:jar:1.1"]
|
33
|
+
)
|
34
|
+
|
35
|
+
class << self
|
36
|
+
include Buildr::Ant
|
37
|
+
|
38
|
+
# :call-seq:
|
39
|
+
# doclet(options) => AntProject
|
40
|
+
#
|
41
|
+
# Uses XDoclet to generate HBM files form annotated source files.
|
42
|
+
# Options include:
|
43
|
+
# * :sources -- Directory (or directories) containing source files.
|
44
|
+
# * :target -- The target directory.
|
45
|
+
# * :excludetags -- Tags to exclude (see HibernateDocletTask)
|
46
|
+
#
|
47
|
+
# For example:
|
48
|
+
# doclet :sources=>compile.sources, :target=>compile.target, :excludedtags=>"@version,@author,@todo"
|
49
|
+
def doclet(options)
|
50
|
+
options[:sources].each { |src| file(src).invoke }
|
51
|
+
ant "hibernatedoclet" do |ant|
|
52
|
+
ant.taskdef :name=>"hibernatedoclet", :classname=>"xdoclet.modules.hibernate.HibernateDocletTask", :classpath=>requires
|
53
|
+
ant.hibernatedoclet :destdir=>options[:target].to_s, :excludedtags=>options[:excludedtags], :force=>"true" do
|
54
|
+
ant.hibernate :version=>"3.0"
|
55
|
+
options[:sources].map(&:to_s).each do |source|
|
56
|
+
ant.fileset :dir=>source.to_s, :includes=>"**/*.java"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# :call-seq:
|
63
|
+
# schemaexport(properties) { ... } => AntProject
|
64
|
+
#
|
65
|
+
# Runs the Hibernate SchemaExportTask with the specified properties. For example:
|
66
|
+
# Buildr::Hibernate.schemaexport(:properties=>properties.to_s, :quiet=>"yes", :text=>"yes", :delimiter=>";",
|
67
|
+
# :drop=>"no", :create=>"yes", :output=>target) do
|
68
|
+
# fileset :dir=>source.to_s, :includes=>"**/*.hbm.xml"
|
69
|
+
# end
|
70
|
+
def schemaexport(options = nil)
|
71
|
+
ant "schemaexport" do |ant|
|
72
|
+
ant.taskdef :name=>"schemaexport", :classname=>"org.hibernate.tool.hbm2ddl.SchemaExportTask", :classpath=>requires
|
73
|
+
ant.schemaexport(options) { yield ant if block_given? } if options
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
protected
|
78
|
+
|
79
|
+
# This will download all the required artifacts before returning a classpath, and we want to do this only once.
|
80
|
+
def requires()
|
81
|
+
@requires ||= Buildr.artifacts(REQUIRES.to_a).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
# :call-seq:
|
87
|
+
# hibernate_doclet(options?) => task
|
88
|
+
#
|
89
|
+
# Runs the hibernate doclet on the source files and creates HBM files in the target directory.
|
90
|
+
# By default runs on all source files, but you can limit it to a given package using the :package
|
91
|
+
# options. You can also pass other options to the doclet task.
|
92
|
+
#
|
93
|
+
# For example:
|
94
|
+
# resources hibernate_doclet(:package=>"org.apache.ode.store.hib", :excludedtags=>"@version,@author,@todo")
|
95
|
+
def hibernate_doclet(options = {})
|
96
|
+
if options[:package]
|
97
|
+
depends = compile.sources.map { |src| FileList[File.join(src.to_s, options[:package].gsub(".", "/"), "*.java")] }.flatten
|
98
|
+
else
|
99
|
+
depends = compile.sources.map { |src| FileList[File.join(src.to_s, "**/*.java")] }.flatten
|
100
|
+
end
|
101
|
+
file("target/hbm.timestamp"=>depends) do |task|
|
102
|
+
Hibernate.doclet({ :sources=>compile.sources, :target=>compile.target }.merge(options))
|
103
|
+
write task.name
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# :call-seq:
|
108
|
+
# hibernate_schemaexport(path) => task
|
109
|
+
# hibernate_schemaexport(path) { |task, ant| .. } => task
|
110
|
+
#
|
111
|
+
# Returns an new file task with an accessor (ant) to an AntProject that defines the schemaexport task.
|
112
|
+
# If called with a block, the task will yield to the block passing both itself and the Ant project.
|
113
|
+
#
|
114
|
+
# See #schemaexport.
|
115
|
+
#
|
116
|
+
# For example:
|
117
|
+
# hibernate_schemaexport "derby.sql" do |task, ant|
|
118
|
+
# ant.schemaexport :properties=>"derby.properties", :output=>task.name,
|
119
|
+
# :delimiter=>";", :drop=>"no", :create=>"yes" do
|
120
|
+
# fileset(:dir=>compile.sources.first) { include :name=>"**/*.hbm.xml" } }
|
121
|
+
# end
|
122
|
+
# end
|
123
|
+
def hibernate_schemaexport(args, &block)
|
124
|
+
path, arg_names, deps = Rake.application.resolve_args([args])
|
125
|
+
unless Rake::Task.task_defined?(path)
|
126
|
+
class << file(path) ; attr_accessor :ant ; end
|
127
|
+
file(path).enhance { |task| task.ant = Hibernate.schemaexport }
|
128
|
+
end
|
129
|
+
if block
|
130
|
+
file(path).enhance(deps) { |task| block.call task, task.ant }
|
131
|
+
else
|
132
|
+
file(path).enhance deps
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
class Project
|
139
|
+
include Hibernate
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|