warbler 1.2.1 → 1.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/Gemfile +8 -5
  2. data/History.txt +5 -0
  3. data/Manifest.txt +43 -23
  4. data/README.txt +67 -26
  5. data/Rakefile +17 -6
  6. data/ext/JarMain.java +147 -0
  7. data/ext/{Main.java → WarMain.java} +4 -4
  8. data/ext/{WarblerWar.java → WarblerJar.java} +79 -13
  9. data/ext/{WarblerWarService.java → WarblerJarService.java} +2 -2
  10. data/lib/warbler/application.rb +9 -9
  11. data/lib/warbler/config.rb +58 -204
  12. data/lib/warbler/gems.rb +2 -2
  13. data/lib/warbler/jar.rb +247 -0
  14. data/lib/warbler/task.rb +28 -60
  15. data/lib/warbler/templates/config.erb +1 -1
  16. data/lib/warbler/templates/rack.erb +1 -1
  17. data/lib/warbler/templates/rails.erb +1 -1
  18. data/lib/warbler/traits/bundler.rb +58 -0
  19. data/lib/warbler/traits/gemspec.rb +64 -0
  20. data/lib/warbler/traits/jar.rb +53 -0
  21. data/lib/warbler/traits/merb.rb +34 -0
  22. data/lib/warbler/traits/nogemspec.rb +41 -0
  23. data/lib/warbler/traits/rack.rb +31 -0
  24. data/lib/warbler/traits/rails.rb +57 -0
  25. data/lib/warbler/traits/war.rb +191 -0
  26. data/lib/warbler/traits.rb +105 -0
  27. data/lib/warbler/version.rb +1 -1
  28. data/lib/warbler/war.rb +1 -247
  29. data/lib/warbler.rb +2 -5
  30. data/lib/warbler_jar.jar +0 -0
  31. data/spec/sample_jar/History.txt +6 -0
  32. data/spec/sample_jar/Manifest.txt +8 -0
  33. data/spec/sample_jar/README.txt +30 -0
  34. data/spec/sample_jar/lib/sample_jar.rb +6 -0
  35. data/spec/sample_jar/sample_jar.gemspec +41 -0
  36. data/spec/sample_jar/test/test_sample_jar.rb +8 -0
  37. data/spec/{sample → sample_war}/app/controllers/application.rb +0 -0
  38. data/spec/{sample → sample_war}/app/helpers/application_helper.rb +0 -0
  39. data/spec/{sample → sample_war}/config/boot.rb +0 -0
  40. data/spec/{sample → sample_war}/config/database.yml +0 -0
  41. data/spec/{sample → sample_war}/config/environment.rb +0 -0
  42. data/spec/{sample → sample_war}/config/environments/development.rb +0 -0
  43. data/spec/{sample → sample_war}/config/environments/production.rb +0 -0
  44. data/spec/{sample → sample_war}/config/environments/test.rb +0 -0
  45. data/spec/{sample → sample_war}/config/initializers/inflections.rb +0 -0
  46. data/spec/{sample → sample_war}/config/initializers/mime_types.rb +0 -0
  47. data/spec/{sample → sample_war}/config/initializers/new_rails_defaults.rb +0 -0
  48. data/spec/{sample → sample_war}/config/routes.rb +0 -0
  49. data/spec/{sample → sample_war}/lib/tasks/utils.rake +0 -0
  50. data/spec/{sample → sample_war}/public/404.html +0 -0
  51. data/spec/{sample → sample_war}/public/422.html +0 -0
  52. data/spec/{sample → sample_war}/public/500.html +0 -0
  53. data/spec/{sample → sample_war}/public/favicon.ico +0 -0
  54. data/spec/{sample → sample_war}/public/index.html +0 -0
  55. data/spec/{sample → sample_war}/public/robots.txt +0 -0
  56. data/spec/spec_helper.rb +40 -0
  57. data/spec/warbler/application_spec.rb +2 -9
  58. data/spec/warbler/config_spec.rb +101 -83
  59. data/spec/warbler/jar_spec.rb +763 -0
  60. data/spec/warbler/task_spec.rb +56 -41
  61. data/spec/warbler/traits_spec.rb +16 -0
  62. data/spec/warbler/war_spec.rb +2 -492
  63. data/warble.rb +36 -32
  64. metadata +57 -35
  65. data/lib/warbler_war.jar +0 -0
@@ -7,497 +7,7 @@
7
7
  require File.dirname(__FILE__) + '/../spec_helper'
8
8
 
9
9
  describe Warbler::War do
10
- before(:each) do
11
- @rake = Rake::Application.new
12
- Rake.application = @rake
13
- verbose(false)
14
- @pwd = Dir.getwd
15
- Dir.chdir("spec/sample")
16
- mkdir_p "log"
17
- touch "log/test.log"
18
- @config = Warbler::Config.new do |config|
19
- config.war_name = "warbler"
20
- config.gems = ["rake"]
21
- config.webxml.jruby.max.runtimes = 5
22
- end rescue nil
23
- @war = Warbler::War.new
24
- @env_save = {}
25
- (ENV.keys.grep(/BUNDLE/) + ["RUBYOPT", "GEM_PATH"]).each {|k| @env_save[k] = ENV[k]; ENV[k] = nil}
26
- end
27
-
28
- after(:each) do
29
- rm_rf FileList["log", ".bundle", "tmp/war"]
30
- rm_f FileList["*.war", "config.ru", "*web.xml*", "config/web.xml*", "config/warble.rb",
31
- "file.txt", 'manifest', 'Gemfile*', 'MANIFEST.MF*', 'init.rb*']
32
- Dir.chdir(@pwd)
33
- @env_save.keys.each {|k| ENV[k] = @env_save[k]}
34
- end
35
-
36
- def file_list(regex)
37
- @war.files.keys.select {|f| f =~ regex }
38
- end
39
-
40
- it "should collect files in public" do
41
- @war.apply(@config)
42
- file_list(%r{^index\.html}).should_not be_empty
43
- end
44
-
45
- it "should collect gem files" do
46
- @config.gems << "rake"
47
- @war.apply(@config)
48
- file_list(%r{WEB-INF/gems/gems/rake.*/lib/rake.rb}).should_not be_empty
49
- file_list(%r{WEB-INF/gems/specifications/rake.*\.gemspec}).should_not be_empty
50
- end
51
-
52
- it "should not include log files by default" do
53
- @war.apply(@config)
54
- file_list(%r{WEB-INF/log}).should_not be_empty
55
- file_list(%r{WEB-INF/log/.*\.log}).should be_empty
56
- end
57
-
58
- def expand_webxml
59
- @war.apply(@config)
60
- @war.files.should include("WEB-INF/web.xml")
61
- require 'rexml/document'
62
- REXML::Document.new(@war.files["WEB-INF/web.xml"]).root.elements
63
- end
64
-
65
- it "should create a web.xml file" do
66
- elements = expand_webxml
67
- elements.to_a(
68
- "context-param/param-name[text()='jruby.max.runtimes']"
69
- ).should_not be_empty
70
- elements.to_a(
71
- "context-param/param-name[text()='jruby.max.runtimes']/../param-value"
72
- ).first.text.should == "5"
73
- end
74
-
75
- it "should include custom context parameters in web.xml" do
76
- @config.webxml.some.custom.config = "myconfig"
77
- elements = expand_webxml
78
- elements.to_a(
79
- "context-param/param-name[text()='some.custom.config']"
80
- ).should_not be_empty
81
- elements.to_a(
82
- "context-param/param-name[text()='some.custom.config']/../param-value"
83
- ).first.text.should == "myconfig"
84
- end
85
-
86
- it "should allow one jndi resource to be included" do
87
- @config.webxml.jndi = 'jndi/rails'
88
- elements = expand_webxml
89
- elements.to_a(
90
- "resource-ref/res-ref-name[text()='jndi/rails']"
91
- ).should_not be_empty
92
- end
93
-
94
- it "should allow multiple jndi resources to be included" do
95
- @config.webxml.jndi = ['jndi/rails1', 'jndi/rails2']
96
- elements = expand_webxml
97
- elements.to_a(
98
- "resource-ref/res-ref-name[text()='jndi/rails1']"
99
- ).should_not be_empty
100
- elements.to_a(
101
- "resource-ref/res-ref-name[text()='jndi/rails2']"
102
- ).should_not be_empty
103
- end
104
-
105
- it "should not include any ignored context parameters" do
106
- @config.webxml.foo = "bar"
107
- @config.webxml.ignored << "foo"
108
- elements = expand_webxml
109
- elements.to_a(
110
- "context-param/param-name[text()='foo']"
111
- ).should be_empty
112
- elements.to_a(
113
- "context-param/param-name[text()='ignored']"
114
- ).should be_empty
115
- elements.to_a(
116
- "context-param/param-name[text()='jndi']"
117
- ).should be_empty
118
- end
119
-
120
- it "should use a config/web.xml if it exists" do
121
- mkdir_p "config"
122
- touch "config/web.xml"
123
- @war.apply(Warbler::Config.new)
124
- @war.files["WEB-INF/web.xml"].should == "config/web.xml"
125
- end
126
-
127
- it "should use a config/web.xml.erb if it exists" do
128
- mkdir_p "config"
129
- File.open("config/web.xml.erb", "w") {|f| f << "Hi <%= webxml.public.root %>" }
130
- @war.apply(Warbler::Config.new)
131
- @war.files["WEB-INF/web.xml"].should_not be_nil
132
- @war.files["WEB-INF/web.xml"].read.should == "Hi /"
133
- end
134
-
135
- it "should collect java libraries" do
136
- @war.apply(@config)
137
- file_list(%r{WEB-INF/lib/jruby-.*\.jar$}).should_not be_empty
138
- end
139
-
140
- it "should collect application files" do
141
- @war.apply(@config)
142
- file_list(%r{WEB-INF/app$}).should_not be_empty
143
- file_list(%r{WEB-INF/config$}).should_not be_empty
144
- file_list(%r{WEB-INF/lib$}).should_not be_empty
145
- end
146
-
147
- it "should accept an autodeploy directory where the war should be created" do
148
- require 'tmpdir'
149
- @config.autodeploy_dir = Dir::tmpdir
150
- touch "file.txt"
151
- @war.files["file.txt"] = "file.txt"
152
- silence { @war.create(@config) }
153
- File.exist?(File.join("#{Dir::tmpdir}","warbler.war")).should == true
154
- end
155
-
156
- it "should accept a custom manifest file" do
157
- touch 'manifest'
158
- @config.manifest_file = 'manifest'
159
- @war.apply(@config)
160
- @war.files['META-INF/MANIFEST.MF'].should == "manifest"
161
- end
162
-
163
- it "should not add a manifest if one already exists" do
164
- @war.files['META-INF/MANIFEST.MF'] = 'manifest'
165
- @war.add_manifest(@config)
166
- @war.files['META-INF/MANIFEST.MF'].should == "manifest"
167
- end
168
-
169
- it "should be able to exclude files from the .war" do
170
- @config.excludes += FileList['lib/tasks/utils.rake']
171
- @war.apply(@config)
172
- file_list(%r{lib/tasks/utils.rake}).should be_empty
173
- end
174
-
175
- it "should read configuration from #{Warbler::Config::FILE}" do
176
- mkdir_p "config"
177
- File.open(Warbler::Config::FILE, "w") do |dest|
178
- contents =
179
- File.open("#{Warbler::WARBLER_HOME}/warble.rb") do |src|
180
- src.read
181
- end
182
- dest << contents.sub(/# config\.war_name/, 'config.war_name'
183
- ).sub(/# config.gems << "tzinfo"/, 'config.gems = []')
184
- end
185
- t = Warbler::Task.new "warble"
186
- t.config.war_name.should == "mywar"
187
- end
188
-
189
- it "should fail if a gem is requested that is not installed" do
190
- @config.gems = ["nonexistent-gem"]
191
- lambda {
192
- Warbler::Task.new "warble", @config
193
- @war.apply(@config)
194
- }.should raise_error
195
- end
196
-
197
- it "should allow specification of dependency by Gem::Dependency" do
198
- spec = mock "gem spec"
199
- spec.stub!(:full_name).and_return "hpricot-0.6.157"
200
- spec.stub!(:full_gem_path).and_return "hpricot-0.6.157"
201
- spec.stub!(:loaded_from).and_return "hpricot.gemspec"
202
- spec.stub!(:files).and_return ["Rakefile"]
203
- spec.stub!(:dependencies).and_return []
204
- Gem.source_index.should_receive(:search).and_return do |gem|
205
- gem.name.should == "hpricot"
206
- [spec]
207
- end
208
- @config.gems = [Gem::Dependency.new("hpricot", "> 0.6")]
209
- @war.apply(@config)
210
- end
211
-
212
- it "should copy loose java classes to WEB-INF/classes" do
213
- @config.java_classes = FileList["Rakefile"]
214
- @war.apply(@config)
215
- file_list(%r{WEB-INF/classes/Rakefile$}).should_not be_empty
216
- end
217
-
218
- def mock_rails_module
219
- rails = Module.new
220
- Object.const_set("Rails", rails)
221
- version = Module.new
222
- rails.const_set("VERSION", version)
223
- version.const_set("STRING", "2.1.0")
224
- rails
225
- end
226
-
227
- def mock_merb_module
228
- merb = Module.new
229
- silence { Object.const_set("Merb", merb) }
230
- boot_loader = Module.new
231
- merb.const_set("BootLoader", boot_loader)
232
- merb.const_set("VERSION", "1.0")
233
- dependencies = Class.new do
234
- @@dependencies = []
235
- def self.dependencies
236
- @@dependencies
237
- end
238
- def self.dependencies=(deps)
239
- @@dependencies = deps
240
- end
241
- end
242
- boot_loader.const_set("Dependencies", dependencies)
243
- dependencies
244
- end
245
-
246
- it "should auto-detect a Rails application" do
247
- task :environment do
248
- mock_rails_module
249
- end
250
- @config = Warbler::Config.new
251
- @config.webxml.booter.should == :rails
252
- @config.gems["rails"].should == "2.1.0"
253
- end
254
-
255
- it "should provide Rails gems by default, unless vendor/rails is present" do
256
- rails = nil
257
- task :environment do
258
- rails = mock_rails_module
259
- end
260
-
261
- config = Warbler::Config.new
262
- config.gems.should have_key("rails")
263
-
264
- mkdir_p "vendor/rails"
265
- config = Warbler::Config.new
266
- config.gems.should be_empty
267
-
268
- rm_rf "vendor/rails"
269
- rails.stub!(:vendor_rails?).and_return true
270
- config = Warbler::Config.new
271
- config.gems.should be_empty
272
- end
273
-
274
- it "should not try to autodetect frameworks when Warbler.framework_detection is false" do
275
- begin
276
- Warbler.framework_detection = false
277
- task :environment
278
- config = Warbler::Config.new
279
- config.webxml.booter.should_not == :rails
280
- t = Rake::Task['environment']
281
- class << t; public :instance_variable_get; end
282
- t.instance_variable_get("@already_invoked").should == false
283
- ensure
284
- Warbler.framework_detection = true
285
- end
286
- end
287
-
288
- it "should auto-detect a Merb application" do
289
- task :merb_env do
290
- mock_merb_module
291
- end
292
- @config = Warbler::Config.new
293
- @config.webxml.booter.should == :merb
294
- @config.gems.keys.should_not include("rails")
295
- end
296
-
297
- it "should auto-detect a Rack application with a config.ru file" do
298
- rackup = "run Proc.new {|env| [200, {}, ['Hello World']]}"
299
- File.open("config.ru", "w") {|f| f << rackup }
300
- @config = Warbler::Config.new
301
- @war.apply(@config)
302
- @war.files['WEB-INF/config.ru'].should == 'config.ru'
303
- end
304
-
305
- it "should automatically add Rails.configuration.gems to the list of gems" do
306
- task :environment do
307
- rails = mock_rails_module
308
- config = mock "config"
309
- rails.stub!(:configuration).and_return(config)
310
- gem = mock "gem"
311
- gem.stub!(:name).and_return "hpricot"
312
- gem.stub!(:requirement).and_return Gem::Requirement.new("=0.6")
313
- config.stub!(:gems).and_return [gem]
314
- end
315
-
316
- @config = Warbler::Config.new
317
- @config.webxml.booter.should == :rails
318
- @config.gems.keys.should include(Gem::Dependency.new("hpricot", Gem::Requirement.new("=0.6")))
319
- end
320
-
321
- it "should automatically add Merb::BootLoader::Dependencies.dependencies to the list of gems" do
322
- task :merb_env do
323
- deps = mock_merb_module
324
- deps.dependencies = [Gem::Dependency.new("merb-core", ">= 1.0.6.1")]
325
- end
326
- @config = Warbler::Config.new
327
- @config.webxml.booter.should == :merb
328
- @config.gems.keys.should include(Gem::Dependency.new("merb-core", ">= 1.0.6.1"))
329
- end
330
-
331
- it "should skip Merb development dependencies" do
332
- task :merb_env do
333
- deps = mock_merb_module
334
- deps.dependencies = [Gem::Dependency.new("rake", "= #{RAKEVERSION}", :development)]
335
- end
336
- @war.apply(Warbler::Config.new)
337
- file_list(/rake-#{RAKEVERSION}/).should be_empty
338
- end
339
-
340
- it "should warn about using Merb < 1.0" do
341
- task :merb_env do
342
- silence { Object.const_set("Merb", Module.new) }
343
- end
344
- @config = silence { Warbler::Config.new }
345
- @config.webxml.booter.should == :merb
346
- end
347
-
348
- it "should set the jruby max runtimes to 1 when MT Rails is detected" do
349
- task :environment do
350
- rails = mock_rails_module
351
- config = mock "config"
352
- rails.stub!(:configuration).and_return(config)
353
- config.stub!(:threadsafe!)
354
- config.should_receive(:allow_concurrency).and_return true
355
- config.should_receive(:preload_frameworks).and_return true
356
- end
357
- @config = Warbler::Config.new
358
- @config.webxml.booter.should == :rails
359
- @config.webxml.jruby.max.runtimes.should == 1
360
- end
361
-
362
- it "should skip directories that don't exist in config.dirs and print a warning" do
363
- @config.dirs = %w(lib notexist)
364
- silence { @war.apply(@config) }
365
- file_list(%r{WEB-INF/lib}).should_not be_empty
366
- file_list(%r{WEB-INF/notexist}).should be_empty
367
- end
368
-
369
- it "should exclude Warbler's old tmp/war directory by default" do
370
- mkdir_p "tmp/war"
371
- touch "tmp/war/index.html"
372
- @config = Warbler::Config.new
373
- @config.dirs += ["tmp"]
374
- @war.apply(@config)
375
- file_list(%r{WEB-INF/tmp/war/index\.html}).should be_empty
376
- end
377
-
378
- it "should write gems to location specified by gem_path" do
379
- @config = Warbler::Config.new do |c|
380
- c.gem_path = "/WEB-INF/jewels"
381
- c.gems << 'rake'
382
- end
383
- elements = expand_webxml
384
- file_list(%r{WEB-INF/jewels}).should_not be_empty
385
- elements.to_a(
386
- "context-param/param-name[text()='gem.path']"
387
- ).should_not be_empty
388
- elements.to_a(
389
- "context-param/param-name[text()='gem.path']/../param-value"
390
- ).first.text.should == "/WEB-INF/jewels"
391
-
392
- end
393
-
394
- it "should detect a Bundler Gemfile and process only its gems" do
395
- File.open("Gemfile", "w") {|f| f << "gem 'rspec'"}
396
- @war.apply(conf = Warbler::Config.new {|c| c.gems << "rake"})
397
- file_list(%r{WEB-INF/Gemfile}).should_not be_empty
398
- file_list(%r{WEB-INF/gems/specifications/rspec}).should_not be_empty
399
- file_list(%r{WEB-INF/gems/specifications/rake}).should be_empty
400
- end
401
-
402
- it "should copy Bundler gemfiles into the war" do
403
- File.open("Gemfile", "w") {|f| f << "gem 'rspec'"}
404
- File.open("Gemfile.lock", "w") {|f| f << "GEM"}
405
- @war.apply(Warbler::Config.new)
406
- file_list(%r{WEB-INF/Gemfile}).should_not be_empty
407
- file_list(%r{WEB-INF/Gemfile.lock}).should_not be_empty
408
- end
409
-
410
- it "should allow overriding of the gem path when using Bundler" do
411
- File.open("Gemfile", "w") {|f| f << "gem 'rspec'"}
412
- @war.apply(Warbler::Config.new {|c| c.gem_path = '/WEB-INF/jewels' })
413
- file_list(%r{WEB-INF/jewels/specifications/rspec}).should_not be_empty
414
- end
415
-
416
- it "should work with :git entries in Bundler Gemfiles" do
417
- File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
418
- silence { ruby "-S", "bundle", "install", "--local" }
419
- @war.apply(Warbler::Config.new)
420
- file_list(%r{WEB-INF/gems/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
421
- file_list(%r{WEB-INF/gems/specifications/warbler}).should_not be_empty
422
- end
423
-
424
- it "should not bundle dependencies in the test group by default when bundling" do
425
- File.open("Gemfile", "w") {|f| f << "gem 'rake'\ngroup :test do\ngem 'rspec'\nend\n"}
426
- @war.apply(Warbler::Config.new)
427
- file_list(%r{WEB-INF/gems/gems/rake[^/]*/}).should_not be_empty
428
- file_list(%r{WEB-INF/gems/gems/rspec[^/]*/}).should be_empty
429
- file_list(%r{WEB-INF/gems/specifications/rake}).should_not be_empty
430
- file_list(%r{WEB-INF/gems/specifications/rspec}).should be_empty
431
- end
432
-
433
- it "should allow adding additional WEB-INF files via config.webinf_files" do
434
- File.open("myserver-web.xml", "w") do |f|
435
- f << "<web-app></web-app>"
436
- end
437
- @war.apply(Warbler::Config.new {|c| c.webinf_files = FileList['myserver-web.xml'] })
438
- file_list(%r{WEB-INF/myserver-web.xml}).should_not be_empty
439
- end
440
-
441
- it "should allow expanding of additional WEB-INF files via config.webinf_files" do
442
- File.open("myserver-web.xml.erb", "w") do |f|
443
- f << "<web-app><%= webxml.rails.env %></web-app>"
444
- end
445
- @war.apply(Warbler::Config.new {|c| c.webinf_files = FileList['myserver-web.xml.erb'] })
446
- file_list(%r{WEB-INF/myserver-web.xml}).should_not be_empty
447
- @war.files['WEB-INF/myserver-web.xml'].read.should =~ /web-app.*production/
448
- end
449
-
450
- it "should exclude test files in gems according to config.gem_excludes" do
451
- @config.gem_excludes += [/^(test|spec)\//]
452
- @war.apply(@config)
453
- file_list(%r{WEB-INF/gems/gems/rake([^/]+)/test/test_rake.rb}).should be_empty
454
- end
455
-
456
- it "should create a META-INF/init.rb file with startup config" do
457
- @war.apply(@config)
458
- file_list(%r{META-INF/init.rb}).should_not be_empty
459
- end
460
-
461
- it "should allow adjusting the init file location in the war" do
462
- @config.init_filename = 'WEB-INF/init.rb'
463
- @war.add_init_file(@config)
464
- file_list(%r{WEB-INF/init.rb}).should_not be_empty
465
- end
466
-
467
- it "should add RAILS_ENV to init.rb for Rails apps" do
468
- @config = Warbler::Config.new { |c| c.webxml.booter = :rails }
469
- @war.add_init_file(@config)
470
- contents = @war.files['META-INF/init.rb'].read
471
- contents.should =~ /ENV\['RAILS_ENV'\]/
472
- contents.should =~ /'production'/
473
- end
474
-
475
- it "should add RACK_ENV to init.rb for Rack apps" do
476
- @config = Warbler::Config.new { |c| c.webxml.booter = :rack }
477
- @war.add_init_file(@config)
478
- contents = @war.files['META-INF/init.rb'].read
479
- contents.should =~ /ENV\['RACK_ENV'\]/
480
- contents.should =~ /'production'/
481
- end
482
-
483
- it "should add BUNDLE_WITHOUT to init.rb when Bundler is used" do
484
- File.open("Gemfile", "w") {|f| f << "gem 'rake'"}
485
- @war.add_init_file(Warbler::Config.new)
486
- contents = @war.files['META-INF/init.rb'].read
487
- contents.should =~ /ENV\['BUNDLE_WITHOUT'\]/
488
- contents.should =~ /'development:test'/
489
- end
490
-
491
- it "should allow adding custom files' contents to init.rb" do
492
- @config = Warbler::Config.new { |c| c.init_contents << "Rakefile" }
493
- @war.add_init_file(@config)
494
- contents = @war.files['META-INF/init.rb'].read
495
- contents.should =~ /require 'rake'/
496
- end
497
-
498
- it "should not have escaped HTML in WARBLER_CONFIG" do
499
- @config.webxml.dummy = '<dummy/>'
500
- @war.apply(@config)
501
- @war.files['META-INF/init.rb'].read.should =~ /<dummy\/>/
10
+ it "is deprecated, replace occurrences with Warbler::Jar" do
11
+ capture { Warbler::War.new }.should =~ /deprecated/
502
12
  end
503
13
  end
data/warble.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Disable automatic framework detection by uncommenting/setting to false
1
+ # Disable Rake-environment-task framework detection by uncommenting/setting to false
2
2
  # Warbler.framework_detection = false
3
3
 
4
4
  # Warbler web application assembly configuration file
@@ -6,6 +6,8 @@ Warbler::Config.new do |config|
6
6
  # Features: additional options controlling how the jar is built.
7
7
  # Currently the following features are supported:
8
8
  # - gemjar: package the gem repository in a jar file in WEB-INF/lib
9
+ # - executable: embed a web server and make the war executable
10
+ # - compiled: compile .rb files to .class files
9
11
  # config.features = %w(gemjar)
10
12
 
11
13
  # Application directories to be included in the webapp.
@@ -23,20 +25,15 @@ Warbler::Config.new do |config|
23
25
  # own versions if you directly set the value
24
26
  # config.java_libs += FileList["lib/java/*.jar"]
25
27
 
26
- # Loose Java classes and miscellaneous files to be placed in WEB-INF/classes.
28
+ # Loose Java classes and miscellaneous files to be included.
27
29
  # config.java_classes = FileList["target/classes/**.*"]
28
30
 
29
31
  # One or more pathmaps defining how the java classes should be copied into
30
- # WEB-INF/classes. The example pathmap below accompanies the java_classes
32
+ # the archive. The example pathmap below accompanies the java_classes
31
33
  # configuration above. See http://rake.rubyforge.org/classes/String.html#M000017
32
34
  # for details of how to specify a pathmap.
33
35
  # config.pathmaps.java_classes << "%{target/classes/,}p"
34
36
 
35
- # Path to the pre-bundled gem directory inside the war file. Default
36
- # is 'WEB-INF/gems'. Specify path if gems are already bundled
37
- # before running Warbler. This also sets 'gem.path' inside web.xml.
38
- # config.gem_path = "WEB-INF/vendor/bundler_gems"
39
-
40
37
  # Bundler support is built-in. If Warbler finds a Gemfile in the
41
38
  # project directory, it will be used to collect the gems to bundle
42
39
  # in your application. If you wish to explicitly disable this
@@ -47,17 +44,11 @@ Warbler::Config.new do |config|
47
44
  # Defaults to ["development", "test"].
48
45
  # config.bundle_without = []
49
46
 
50
- # Files for WEB-INF directory (next to web.xml). This contains
51
- # web.xml by default. If there is an .erb-File it will be processed
52
- # with webxml-config. You may want to exclude this file via
53
- # config.excludes.
54
- # config.webinf_files += FileList["jboss-web.xml"]
55
-
56
- # Other gems to be included. You need to tell Warbler which gems
57
- # your application needs so that they can be packaged in the war
58
- # file.
59
- # The Rails gems are included by default unless the vendor/rails
60
- # directory is present.
47
+ # Other gems to be included. If you don't use Bundler or a gemspec
48
+ # file, you need to tell Warbler which gems your application needs
49
+ # so that they can be packaged in the archive.
50
+ # For Rails applications, the Rails gems are included by default
51
+ # unless the vendor/rails directory is present.
61
52
  # config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"]
62
53
  # config.gems << "tzinfo"
63
54
 
@@ -66,10 +57,10 @@ Warbler::Config.new do |config|
66
57
 
67
58
  # The most recent versions of gems are used.
68
59
  # You can specify versions of gems by using a hash assignment:
69
- # config.gems["rails"] = "2.0.2"
60
+ # config.gems["rails"] = "2.3.10"
70
61
 
71
62
  # You can also use regexps or Gem::Dependency objects for flexibility or
72
- # fine-grained control.
63
+ # finer-grained control.
73
64
  # config.gems << /^merb-/
74
65
  # config.gems << Gem::Dependency.new("merb-core", "= 0.9.3")
75
66
 
@@ -82,19 +73,12 @@ Warbler::Config.new do |config|
82
73
  # below, which excludes test files.
83
74
  # config.gem_excludes = [/^(test|spec)\//]
84
75
 
85
- # Files to be included in the root of the webapp. Note that files in public
86
- # will have the leading 'public/' part of the path stripped during staging.
87
- # config.public_html = FileList["public/**/*", "doc/**/*"]
88
-
89
- # Pathmaps for controlling how public HTML files are copied into the .war
90
- # config.pathmaps.public_html = ["%{public/,}p"]
91
-
92
- # Pathmaps for controlling how application files are copied into the .war
76
+ # Pathmaps for controlling how application files are copied into the archive
93
77
  # config.pathmaps.application = ["WEB-INF/%p"]
94
78
 
95
- # Name of the war file (without the .war) -- defaults to the basename
96
- # of RAILS_ROOT
97
- # config.war_name = "mywar"
79
+ # Name of the archive (without the extension). Defaults to the basename
80
+ # of the project directory.
81
+ # config.jar_name = "mywar"
98
82
 
99
83
  # Name of the MANIFEST.MF template for the war file. Defaults to a simple
100
84
  # MANIFEST.MF that contains the version of Warbler used to create the war file.
@@ -105,6 +89,26 @@ Warbler::Config.new do |config|
105
89
  # the application.
106
90
  # config.compiled_ruby_files = FileList['app/**/*.rb']
107
91
 
92
+ # === War files only below here ===
93
+
94
+ # Path to the pre-bundled gem directory inside the war file. Default
95
+ # is 'WEB-INF/gems'. Specify path if gems are already bundled
96
+ # before running Warbler. This also sets 'gem.path' inside web.xml.
97
+ # config.gem_path = "WEB-INF/vendor/bundler_gems"
98
+
99
+ # Files for WEB-INF directory (next to web.xml). This contains
100
+ # web.xml by default. If there is an .erb-File it will be processed
101
+ # with webxml-config. You may want to exclude this file via
102
+ # config.excludes.
103
+ # config.webinf_files += FileList["jboss-web.xml"]
104
+
105
+ # Files to be included in the root of the webapp. Note that files in public
106
+ # will have the leading 'public/' part of the path stripped during staging.
107
+ # config.public_html = FileList["public/**/*", "doc/**/*"]
108
+
109
+ # Pathmaps for controlling how public HTML files are copied into the .war
110
+ # config.pathmaps.public_html = ["%{public/,}p"]
111
+
108
112
  # Value of RAILS_ENV for the webapp -- default as shown below
109
113
  # config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
110
114