warbler 1.3.0.beta1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History.txt +9 -0
  2. data/LICENSE.txt +1 -1
  3. data/Manifest.txt +22 -0
  4. data/README.txt +6 -3
  5. data/Rakefile +2 -2
  6. data/bin/warble +1 -1
  7. data/ext/JarMain.java +3 -2
  8. data/ext/WarMain.java +3 -2
  9. data/ext/WarblerJar.java +2 -1
  10. data/ext/WarblerJarService.java +2 -1
  11. data/lib/warbler.rb +1 -1
  12. data/lib/warbler/application.rb +17 -1
  13. data/lib/warbler/config.rb +12 -3
  14. data/lib/warbler/gems.rb +1 -1
  15. data/lib/warbler/jar.rb +17 -12
  16. data/lib/warbler/task.rb +6 -15
  17. data/lib/warbler/templates/bundler.erb +3 -0
  18. data/lib/warbler/templates/jar.erb +5 -0
  19. data/lib/warbler/templates/rack.erb +1 -1
  20. data/lib/warbler/templates/war.erb +1 -0
  21. data/lib/warbler/traits.rb +5 -3
  22. data/lib/warbler/traits/bundler.rb +52 -14
  23. data/lib/warbler/traits/gemspec.rb +6 -11
  24. data/lib/warbler/traits/jar.rb +4 -1
  25. data/lib/warbler/traits/merb.rb +2 -1
  26. data/lib/warbler/traits/nogemspec.rb +2 -1
  27. data/lib/warbler/traits/rack.rb +3 -1
  28. data/lib/warbler/traits/rails.rb +13 -8
  29. data/lib/warbler/traits/war.rb +12 -6
  30. data/lib/warbler/version.rb +2 -2
  31. data/lib/warbler/war.rb +7 -0
  32. data/lib/warbler_jar.jar +0 -0
  33. data/spec/drb_helper.rb +41 -0
  34. data/spec/sample_bundler/Gemfile.lock +10 -0
  35. data/spec/sample_bundler/config.ru +0 -0
  36. data/spec/sample_bundler/vendor/bundle/jruby/1.8/cache/rake-0.8.7.gem +0 -0
  37. data/spec/sample_bundler/vendor/bundle/jruby/1.8/gems/rake-0.8.7/lib/rake.rb +2506 -0
  38. data/spec/sample_bundler/vendor/bundle/jruby/1.8/specifications/rake-0.8.7.gemspec +31 -0
  39. data/spec/sample_bundler/vendor/bundle/ruby/1.8/cache/rake-0.8.7.gem +0 -0
  40. data/spec/sample_bundler/vendor/bundle/ruby/1.8/gems/rake-0.8.7/lib/rake.rb +2506 -0
  41. data/spec/sample_bundler/vendor/bundle/ruby/1.8/specifications/rake-0.8.7.gemspec +30 -0
  42. data/spec/sample_bundler/vendor/bundle/ruby/1.9.1/cache/rake-0.8.7.gem +0 -0
  43. data/spec/sample_bundler/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb +2506 -0
  44. data/spec/sample_bundler/vendor/bundle/ruby/1.9.1/specifications/rake-0.8.7.gemspec +30 -0
  45. data/spec/sample_jar/sample_jar.gemspec +0 -1
  46. data/spec/sample_war/config/environments/production.rb +3 -0
  47. data/spec/spec_helper.rb +32 -5
  48. data/spec/warbler/application_spec.rb +11 -2
  49. data/spec/warbler/bundler_spec.rb +136 -0
  50. data/spec/warbler/config_spec.rb +2 -2
  51. data/spec/warbler/gems_spec.rb +2 -2
  52. data/spec/warbler/jar_spec.rb +63 -108
  53. data/spec/warbler/task_spec.rb +29 -20
  54. data/spec/warbler/traits_spec.rb +3 -2
  55. data/spec/warbler/war_spec.rb +3 -2
  56. data/warble.rb +3 -0
  57. data/web.xml.erb +2 -2
  58. metadata +179 -177
data/History.txt CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  - Warbler can now package regular Ruby projects as executable jar
4
4
  files. See the README.txt file for details.
5
+ - WARBLER-18: Heed BUNDLE_GEMFILE in environment
6
+ - WARBLER-17: Allow config.excludes to work for files in public/
7
+ - GH#3, #12, #17: Properly bundle when BUNDLE_PATH is set or
8
+ --deployment flag is used
9
+ - JRUBY-5077, WARBLER-24: Gems from git repositories are now packaged
10
+ correctly
11
+ - GH#20: Ruby 1.9.2 support
12
+ - GH#8: Clean up compiled .class files after building war
13
+ - GH#15: Simplify detection of thread-safe Rails
5
14
 
6
15
  == 1.2.1
7
16
 
data/LICENSE.txt CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Warbler is provided under the terms of the MIT license.
4
4
 
5
- Warbler (c) 2010 Engine Yard, Inc.
5
+ Warbler (c) 2010-2011 Engine Yard, Inc.
6
6
  Warbler (c) 2007-2009 Sun Microsystems, Inc.
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person
data/Manifest.txt CHANGED
@@ -17,9 +17,12 @@ lib/warbler/gems.rb
17
17
  lib/warbler/jar.rb
18
18
  lib/warbler/task.rb
19
19
  lib/warbler/templates
20
+ lib/warbler/templates/bundler.erb
20
21
  lib/warbler/templates/config.erb
22
+ lib/warbler/templates/jar.erb
21
23
  lib/warbler/templates/rack.erb
22
24
  lib/warbler/templates/rails.erb
25
+ lib/warbler/templates/war.erb
23
26
  lib/warbler/traits
24
27
  lib/warbler/traits.rb
25
28
  lib/warbler/traits/bundler.rb
@@ -33,6 +36,24 @@ lib/warbler/traits/war.rb
33
36
  lib/warbler/version.rb
34
37
  lib/warbler/war.rb
35
38
  lib/warbler_jar.jar
39
+ spec/drb_helper.rb
40
+ spec/sample_bundler/Gemfile.lock
41
+ spec/sample_bundler/config.ru
42
+ spec/sample_bundler/vendor/bundle/jruby/1.8
43
+ spec/sample_bundler/vendor/bundle/jruby/1.8/cache/rake-0.8.7.gem
44
+ spec/sample_bundler/vendor/bundle/jruby/1.8/gems/rake-0.8.7
45
+ spec/sample_bundler/vendor/bundle/jruby/1.8/gems/rake-0.8.7/lib/rake.rb
46
+ spec/sample_bundler/vendor/bundle/jruby/1.8/specifications/rake-0.8.7.gemspec
47
+ spec/sample_bundler/vendor/bundle/ruby/1.8
48
+ spec/sample_bundler/vendor/bundle/ruby/1.8/cache/rake-0.8.7.gem
49
+ spec/sample_bundler/vendor/bundle/ruby/1.8/gems/rake-0.8.7
50
+ spec/sample_bundler/vendor/bundle/ruby/1.8/gems/rake-0.8.7/lib/rake.rb
51
+ spec/sample_bundler/vendor/bundle/ruby/1.8/specifications/rake-0.8.7.gemspec
52
+ spec/sample_bundler/vendor/bundle/ruby/1.9.1
53
+ spec/sample_bundler/vendor/bundle/ruby/1.9.1/cache/rake-0.8.7.gem
54
+ spec/sample_bundler/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7
55
+ spec/sample_bundler/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb
56
+ spec/sample_bundler/vendor/bundle/ruby/1.9.1/specifications/rake-0.8.7.gemspec
36
57
  spec/sample_jar/History.txt
37
58
  spec/sample_jar/Manifest.txt
38
59
  spec/sample_jar/README.txt
@@ -60,6 +81,7 @@ spec/sample_war/public/index.html
60
81
  spec/sample_war/public/robots.txt
61
82
  spec/spec_helper.rb
62
83
  spec/warbler/application_spec.rb
84
+ spec/warbler/bundler_spec.rb
63
85
  spec/warbler/config_spec.rb
64
86
  spec/warbler/gems_spec.rb
65
87
  spec/warbler/jar_spec.rb
data/README.txt CHANGED
@@ -93,8 +93,7 @@ require paths, and the files to be included in the archive. For best
93
93
  results make sure your gemspec specifies all of the following
94
94
  attributes:
95
95
 
96
- * +default_executable+
97
- * +files+
96
+ * +executables+
98
97
  * +require_paths+
99
98
  * runtime dependencies added with +add_dependency+
100
99
 
@@ -111,6 +110,10 @@ archive along with the Gemfile. The Bundler groups named
111
110
  +:development+ and +:test+ will be excluded by default, unless you
112
111
  specify with +config.bundle_without+ in +config/warble.rb+.
113
112
 
113
+ Warbler supports Bundler for gems and git repositories, but not for
114
+ plain path components. Warbler will warn when a +:path+ component is
115
+ found in the +Gemfile+ and will refuse to include it in the archive.
116
+
114
117
  == War Files
115
118
 
116
119
  === Rails applications
@@ -248,5 +251,5 @@ After that, simply run "rake".
248
251
 
249
252
  Warbler is provided under the terms of the MIT license.
250
253
 
251
- Warbler (c) 2010 Engine Yard, Inc.
254
+ Warbler (c) 2010-2011 Engine Yard, Inc.
252
255
  Warbler (c) 2007-2009 Sun Microsystems, Inc.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
3
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
4
4
  # This source code is available under the MIT license.
5
5
  # See the file LICENSE.txt for details.
@@ -20,7 +20,7 @@ MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "Gemfile",
20
20
  ].to_a.reject{|f| f=~%r{spec/sample/(MANIFEST|link|web.xml)}}.sort.uniq
21
21
 
22
22
  begin
23
- File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
23
+ File.open("Manifest.txt", "wb") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
24
24
  require 'hoe'
25
25
  require File.dirname(__FILE__) + '/lib/warbler/version'
26
26
  hoe = Hoe.spec("warbler") do |p|
data/bin/warble CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  #--
4
- # Copyright (c) 2010 Engine Yard, Inc.
4
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
5
5
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
6
6
  # This source code is available under the MIT license.
7
7
  # See the file LICENSE.txt for details.
data/ext/JarMain.java CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Copyright (c) 2010 Engine Yard, Inc.
2
+ * Copyright (c) 2010-2011 Engine Yard, Inc.
3
+ * Copyright (c) 2007-2009 Sun Microsystems, Inc.
3
4
  * This source code is available under the MIT license.
4
5
  * See the file LICENSE.txt for details.
5
6
  */
@@ -29,7 +30,7 @@ public class JarMain implements Runnable {
29
30
  this.args = args;
30
31
  URL mainClass = getClass().getResource(MAIN);
31
32
  this.path = mainClass.toURI().getSchemeSpecificPart();
32
- this.jarfile = mainClass.getFile().replace("!" + MAIN, "").replace("file:", "");
33
+ this.jarfile = this.path.replace("!" + MAIN, "").replace("file:", "");
33
34
  this.debug = isDebug();
34
35
  this.extractRoot = File.createTempFile("jruby", "extract");
35
36
  this.extractRoot.delete();
data/ext/WarMain.java CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Copyright (c) 2010 Engine Yard, Inc.
2
+ * Copyright (c) 2010-2011 Engine Yard, Inc.
3
+ * Copyright (c) 2007-2009 Sun Microsystems, Inc.
3
4
  * This source code is available under the MIT license.
4
5
  * See the file LICENSE.txt for details.
5
6
  */
@@ -26,7 +27,7 @@ public class WarMain implements Runnable {
26
27
  this.args = args;
27
28
  URL mainClass = getClass().getResource(MAIN);
28
29
  this.path = mainClass.toURI().getSchemeSpecificPart();
29
- this.warfile = mainClass.getFile().replace("!" + MAIN, "").replace("file:", "");
30
+ this.warfile = this.path.replace("!" + MAIN, "").replace("file:", "");
30
31
  this.debug = isDebug();
31
32
  this.webroot = File.createTempFile("winstone", "webroot");
32
33
  this.webroot.delete();
data/ext/WarblerJar.java CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Copyright (c) 2010 Engine Yard, Inc.
2
+ * Copyright (c) 2010-2011 Engine Yard, Inc.
3
+ * Copyright (c) 2007-2009 Sun Microsystems, Inc.
3
4
  * This source code is available under the MIT license.
4
5
  * See the file LICENSE.txt for details.
5
6
  */
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Copyright (c) 2010 Engine Yard, Inc.
2
+ * Copyright (c) 2010-2011 Engine Yard, Inc.
3
+ * Copyright (c) 2007-2009 Sun Microsystems, Inc.
3
4
  * This source code is available under the MIT license.
4
5
  * See the file LICENSE.txt for details.
5
6
  */
data/lib/warbler.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
3
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
4
4
  # This source code is available under the MIT license.
5
5
  # See the file LICENSE.txt for details.
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
3
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
4
4
  # This source code is available under the MIT license.
5
5
  # See the file LICENSE.txt for details.
@@ -67,4 +67,20 @@ class Warbler::Application < Rake::Application
67
67
  Rake.application = self
68
68
  super
69
69
  end
70
+
71
+ # Remap the version option to display Warbler version.
72
+ def standard_rake_options
73
+ super.map do |opt|
74
+ if opt.first == '--version'
75
+ ['--version', '-V', "Display the program version.",
76
+ lambda { |value|
77
+ puts "Warbler version #{Warbler::VERSION}"
78
+ exit
79
+ }
80
+ ]
81
+ else
82
+ opt
83
+ end
84
+ end
85
+ end
70
86
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
3
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
4
4
  # This source code is available under the MIT license.
5
5
  # See the file LICENSE.txt for details.
@@ -184,15 +184,24 @@ module Warbler
184
184
  @gem_path[1..-1]
185
185
  end
186
186
 
187
+ def define_tasks
188
+ task "gemjar" do
189
+ self.features << "gemjar"
190
+ end
191
+ task "executable" do
192
+ self.features << "executable"
193
+ end
194
+ end
195
+
187
196
  # Deprecated
188
197
  def war_name
189
- warn "config.war_name deprecated; replace with config.jar_name" #:nocov:
198
+ $stderr.puts "config.war_name deprecated; replace with config.jar_name" #:nocov:
190
199
  jar_name #:nocov:
191
200
  end
192
201
 
193
202
  # Deprecated
194
203
  def war_name=(w)
195
- warn "config.war_name deprecated; replace with config.jar_name" #:nocov:
204
+ $stderr.puts "config.war_name deprecated; replace with config.jar_name" #:nocov:
196
205
  self.jar_name = w #:nocov:
197
206
  end
198
207
 
data/lib/warbler/gems.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
3
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
4
4
  # This source code is available under the MIT license.
5
5
  # See the file LICENSE.txt for details.
data/lib/warbler/jar.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
+ # Copyright (c) 2007-2009 Sun Microsystems, Inc.
3
4
  # This source code is available under the MIT license.
4
5
  # See the file LICENSE.txt for details.
5
6
  #++
@@ -24,6 +25,11 @@ module Warbler
24
25
  @files = {}
25
26
  end
26
27
 
28
+ def contents(entry)
29
+ file = files[entry]
30
+ file.respond_to?(:read) ? file.read : File.open(file) {|f| f.read }
31
+ end
32
+
27
33
  def compile(config)
28
34
  # Compiling all Ruby files we can find -- do we need to allow an
29
35
  # option to configure what gets compiled?
@@ -125,16 +131,15 @@ module Warbler
125
131
  spec = matched.last
126
132
  end
127
133
 
128
- # skip gems with no load path
129
- return if spec.loaded_from == ""
134
+ full_gem_path = Pathname.new(spec.full_gem_path)
135
+
136
+ # skip gems whose full_gem_path does not exist
137
+ ($stderr.puts "warning: skipping #{spec.name} (#{full_gem_path.to_s} does not exist)" ; return) unless full_gem_path.exist?
130
138
 
131
- add_with_pathmaps(config, spec.loaded_from, :gemspecs)
132
- spec.files.each do |f|
133
- f = f[2..-1] if f =~ /^\.\//
139
+ @files[apply_pathmaps(config, "#{spec.full_name}.gemspec", :gemspecs)] = StringIO.new(spec.to_ruby)
140
+ FileList["#{full_gem_path.to_s}/**/*"].each do |src|
141
+ f = Pathname.new(src).relative_path_from(full_gem_path).to_s
134
142
  next if config.gem_excludes && config.gem_excludes.any? {|rx| f =~ rx }
135
- src = File.join(spec.full_gem_path, f)
136
- # some gemspecs may have incorrect file listings
137
- next unless File.exist?(src)
138
143
  @files[apply_pathmaps(config, File.join(spec.full_name, f), :gems)] = src
139
144
  end
140
145
 
@@ -145,7 +150,7 @@ module Warbler
145
150
  def find_application_files(config)
146
151
  config.dirs.select do |d|
147
152
  exists = File.directory?(d)
148
- warn "warning: application directory `#{d}' does not exist or is not a directory; skipping" unless exists
153
+ $stderr.puts "warning: application directory `#{d}' does not exist or is not a directory; skipping" unless exists
149
154
  exists
150
155
  end.each do |d|
151
156
  @files[apply_pathmaps(config, d, :application)] = nil
@@ -214,7 +219,7 @@ module Warbler
214
219
  if src.respond_to?(:read)
215
220
  zipfile.get_output_stream(entry) {|f| f << src.read }
216
221
  elsif src.nil? || File.directory?(src)
217
- warn "directory symlinks are not followed unless using JRuby; #{entry} contents not in archive" \
222
+ $stderr.puts "directory symlinks are not followed unless using JRuby; #{entry} contents not in archive" \
218
223
  if File.symlink?(entry) && !defined?(JRUBY_VERSION)
219
224
  zipfile.mkdir(entry)
220
225
  elsif File.symlink?(src)
@@ -241,7 +246,7 @@ module Warbler
241
246
  class War < Jar
242
247
  def initialize(*)
243
248
  super
244
- warn "Warbler::War is deprecated. Please replace all occurrences with Warbler::Jar."
249
+ $stderr.puts "Warbler::War is deprecated. Please replace all occurrences with Warbler::Jar."
245
250
  end
246
251
  end
247
252
  end
data/lib/warbler/task.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
3
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
4
4
  # This source code is available under the MIT license.
5
5
  # See the file LICENSE.txt for details.
@@ -45,7 +45,7 @@ module Warbler
45
45
  end
46
46
  @config ||= Config.new
47
47
  unless @config.kind_of? Config
48
- warn "Warbler::Config not provided by override in initializer or #{Config::FILE}; using defaults"
48
+ $stderr.puts "Warbler::Config not provided by override in initializer or #{Config::FILE}; using defaults"
49
49
  @config = Config.new
50
50
  end
51
51
  @name = name || @config.jar_extension
@@ -66,11 +66,10 @@ module Warbler
66
66
  define_files_task
67
67
  define_jar_task
68
68
  define_debug_task
69
- define_gemjar_task
70
69
  define_config_task
71
70
  define_pluginize_task
72
- define_executable_task
73
71
  define_version_task
72
+ define_extra_tasks
74
73
  end
75
74
  end
76
75
 
@@ -81,7 +80,7 @@ module Warbler
81
80
  @config.features.each do |feature|
82
81
  t = "#@name:#{feature}"
83
82
  unless Rake.application.lookup(t)
84
- warn "unknown feature `#{feature}', ignoring"
83
+ $stderr.puts "unknown feature `#{feature}', ignoring"
85
84
  next
86
85
  end
87
86
  Rake::Task[t].invoke
@@ -141,10 +140,8 @@ module Warbler
141
140
  end
142
141
  end
143
142
 
144
- def define_gemjar_task
145
- task "gemjar" do
146
- @config.features << "gemjar"
147
- end
143
+ def define_extra_tasks
144
+ @config.define_tasks
148
145
  end
149
146
 
150
147
  def define_config_task
@@ -177,12 +174,6 @@ module Warbler
177
174
  end
178
175
  end
179
176
 
180
- def define_executable_task
181
- task "executable" do
182
- @config.features << "executable"
183
- end
184
- end
185
-
186
177
  def define_version_task
187
178
  task "version" do
188
179
  puts "Warbler version #{Warbler::VERSION}"
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_WITHOUT'] = '<%= config.bundle_without.join(':') %>'
2
+ ENV['BUNDLE_GEMFILE'] = '<%= config.bundler[:gemfile].basename %>'
3
+ <% if config.bundler[:frozen] %>ENV['BUNDLE_FROZEN'] = '1'<% end %>
@@ -0,0 +1,5 @@
1
+ <% if config.relative_gem_path.empty? %>
2
+ ENV['GEM_HOME'] ||= File.expand_path('../..', __FILE__)
3
+ <% else %>
4
+ ENV['GEM_HOME'] ||= File.expand_path('../../<%= config.relative_gem_path %>', __FILE__)
5
+ <% end %>
@@ -1 +1 @@
1
- ENV['RACK_ENV'] = '<%= (params = config.webxml.context_params; params['rack.env'] || params['rails.env']) %>'
1
+ ENV['RACK_ENV'] = '<%= (params = config.webxml.context_params; params['rack.env']) %>'
@@ -0,0 +1 @@
1
+ ENV['GEM_HOME'] ||= $servlet_context.getRealPath('<%= config.gem_path %>')
@@ -1,5 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
+ # Copyright (c) 2007-2009 Sun Microsystems, Inc.
3
4
  # This source code is available under the MIT license.
4
5
  # See the file LICENSE.txt for details.
5
6
  #++
@@ -87,8 +88,9 @@ module Warbler
87
88
  if config.gem_path != default_gem_path
88
89
  config.gem_path = "/#{config.gem_path}" unless config.gem_path =~ %r{^/}
89
90
  sub_gem_path = config.gem_path[1..-1]
90
- config.pathmaps.gemspecs.each {|p| p.sub!(default_gem_path[1..-1], sub_gem_path)}
91
- config.pathmaps.gems.each {|p| p.sub!(default_gem_path[1..-1], sub_gem_path)}
91
+ config.pathmaps.marshal_dump.keys.each do |pm|
92
+ config.pathmaps.send(pm).each {|p| p.sub!(default_gem_path[1..-1], sub_gem_path)}
93
+ end
92
94
  config.webxml["gem"]["path"] = config.gem_path if config.webxml
93
95
  end
94
96
  end
@@ -1,5 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2010 Engine Yard, Inc.
2
+ # Copyright (c) 2010-2011 Engine Yard, Inc.
3
+ # Copyright (c) 2007-2009 Sun Microsystems, Inc.
3
4
  # This source code is available under the MIT license.
4
5
  # See the file LICENSE.txt for details.
5
6
  #++
@@ -12,7 +13,7 @@ module Warbler
12
13
  include Trait
13
14
 
14
15
  def self.detect?
15
- File.exist?("Gemfile")
16
+ File.exist?(ENV['BUNDLE_GEMFILE'] || "Gemfile")
16
17
  end
17
18
 
18
19
  def self.requires?(trait)
@@ -31,26 +32,63 @@ module Warbler
31
32
  def add_bundler_gems
32
33
  config.gems.clear
33
34
  config.gem_dependencies = false # Bundler takes care of these
34
-
35
+ config.bundler = {}
36
+ ENV['BUNDLE_WITHOUT'] ||= config.bundle_without.join(':')
35
37
  require 'bundler'
36
- gemfile = Pathname.new("Gemfile").expand_path
37
- root = gemfile.dirname
38
- lockfile = root.join('Gemfile.lock')
39
- definition = ::Bundler::Definition.build(gemfile, lockfile, nil)
40
- groups = definition.groups - config.bundle_without.map {|g| g.to_sym}
41
- definition.specs_for(groups).each {|spec| config.gems << spec }
42
- config.init_contents << StringIO.new("ENV['BUNDLE_WITHOUT'] = '#{config.bundle_without.join(':')}'\n")
38
+ ::Bundler.setup.requested_specs.each do |spec|
39
+ # Bundler HAX -- fixup bad #loaded_from attribute in fake
40
+ # bundler gemspec from bundler/source.rb
41
+ if spec.name == "bundler"
42
+ full_gem_path = Pathname.new(spec.full_gem_path)
43
+ tries = 2
44
+ (full_gem_path = full_gem_path.dirname; tries -= 1) while tries > 0 && !full_gem_path.join('bundler.gemspec').exist?
45
+ spec.loaded_from = full_gem_path.to_s
46
+ end
47
+
48
+ case spec.source
49
+ when ::Bundler::Source::Git
50
+ config.bundler[:git_specs] ||= []
51
+ config.bundler[:git_specs] << spec
52
+ when ::Bundler::Source::Path
53
+ $stderr.puts("warning: Bundler `path' components are not currently supported.",
54
+ "The `#{spec.full_name}' component was not bundled.",
55
+ "Your application may fail to boot!")
56
+ else
57
+ config.gems << spec
58
+ end
59
+ end
60
+ config.bundler[:gemfile] = ::Bundler.default_gemfile
61
+ config.bundler[:lockfile] = ::Bundler.default_lockfile
62
+ config.bundler[:frozen] = ::Bundler.settings[:frozen]
63
+ config.excludes += [::Bundler.settings[:path]] if ::Bundler.settings[:path]
64
+ config.init_contents << "#{config.warbler_templates}/bundler.erb"
43
65
  end
44
66
 
45
67
  def update_archive(jar)
46
68
  add_bundler_files(jar) if config.bundler
47
69
  end
48
70
 
49
- # Add Bundler Gemfiles to the archive.
71
+ # Add Bundler Gemfiles and git repositories to the archive.
50
72
  def add_bundler_files(jar)
51
- jar.files[jar.apply_pathmaps(config, 'Gemfile', :application)] = 'Gemfile'
52
- if File.exist?('Gemfile.lock')
53
- jar.files[jar.apply_pathmaps(config, 'Gemfile.lock', :application)] = 'Gemfile.lock'
73
+ pwd = Pathname.new(Dir.pwd)
74
+ gemfile = config.bundler[:gemfile].relative_path_from(pwd).to_s
75
+ lockfile = config.bundler[:lockfile].relative_path_from(pwd).to_s
76
+ jar.files[jar.apply_pathmaps(config, gemfile, :application)] = config.bundler[:gemfile].to_s
77
+ if File.exist?(lockfile)
78
+ jar.files[jar.apply_pathmaps(config, lockfile, :application)] = config.bundler[:lockfile].to_s
79
+ end
80
+ if config.bundler[:git_specs]
81
+ pathmap = "#{config.relative_gem_path}/bundler/gems/%p"
82
+ pathmap.sub!(%r{^/+}, '')
83
+ config.pathmaps.git = [pathmap]
84
+ config.bundler[:git_specs].each do |spec|
85
+ full_gem_path = Pathname.new(spec.full_gem_path)
86
+ FileList["#{full_gem_path.to_s}/**/*"].each do |src|
87
+ f = Pathname.new(src).relative_path_from(full_gem_path).to_s
88
+ next if config.gem_excludes && config.gem_excludes.any? {|rx| f =~ rx }
89
+ jar.files[jar.apply_pathmaps(config, File.join(full_gem_path.basename, f), :git)] = src
90
+ end
91
+ end
54
92
  end
55
93
  end
56
94
  end