warbler_updated 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/History.txt +411 -0
- data/LICENSE.txt +27 -0
- data/Mavenfile +32 -0
- data/README.rdoc +280 -0
- data/Rakefile +63 -0
- data/bin/warble +11 -0
- data/ext/JarMain.java +334 -0
- data/ext/WarMain.java +375 -0
- data/ext/WarblerJar.java +199 -0
- data/ext/WarblerJarService.java +18 -0
- data/lib/warbler/application.rb +104 -0
- data/lib/warbler/bundler_helper.rb +22 -0
- data/lib/warbler/config.rb +265 -0
- data/lib/warbler/executable_helper.rb +25 -0
- data/lib/warbler/gems.rb +77 -0
- data/lib/warbler/jar.rb +348 -0
- data/lib/warbler/pathmap_helper.rb +20 -0
- data/lib/warbler/platform_helper.rb +26 -0
- data/lib/warbler/rake_helper.rb +30 -0
- data/lib/warbler/scripts/rails.rb +5 -0
- data/lib/warbler/task.rb +185 -0
- data/lib/warbler/templates/bundler.erb +19 -0
- data/lib/warbler/templates/config.erb +1 -0
- data/lib/warbler/templates/jar.erb +11 -0
- data/lib/warbler/templates/jbundler.erb +2 -0
- data/lib/warbler/templates/rack.erb +5 -0
- data/lib/warbler/templates/rails.erb +1 -0
- data/lib/warbler/templates/war.erb +19 -0
- data/lib/warbler/traits/bundler.rb +157 -0
- data/lib/warbler/traits/gemspec.rb +79 -0
- data/lib/warbler/traits/jar.rb +58 -0
- data/lib/warbler/traits/jbundler.rb +48 -0
- data/lib/warbler/traits/nogemspec.rb +47 -0
- data/lib/warbler/traits/rack.rb +33 -0
- data/lib/warbler/traits/rails.rb +91 -0
- data/lib/warbler/traits/war.rb +260 -0
- data/lib/warbler/traits.rb +124 -0
- data/lib/warbler/version.rb +10 -0
- data/lib/warbler/war.rb +8 -0
- data/lib/warbler/web_server.rb +125 -0
- data/lib/warbler/zip_support.rb +13 -0
- data/lib/warbler.rb +40 -0
- data/lib/warbler_jar.jar +0 -0
- data/warble.rb +188 -0
- data/warbler.gemspec +37 -0
- data/web.xml.erb +57 -0
- metadata +188 -0
@@ -0,0 +1,260 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010-2012 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
6
|
+
#++
|
7
|
+
|
8
|
+
require 'ostruct'
|
9
|
+
|
10
|
+
module Warbler
|
11
|
+
module Traits
|
12
|
+
# The War trait sets up the layout and generates web.xml for the war project.
|
13
|
+
class War
|
14
|
+
include Trait
|
15
|
+
include RakeHelper
|
16
|
+
include PathmapHelper
|
17
|
+
|
18
|
+
DEFAULT_GEM_PATH = '/WEB-INF/gems'
|
19
|
+
|
20
|
+
def self.detect?
|
21
|
+
Traits::Rails.detect? || Traits::Rack.detect?
|
22
|
+
end
|
23
|
+
|
24
|
+
def before_configure
|
25
|
+
config.gem_path = DEFAULT_GEM_PATH
|
26
|
+
config.pathmaps = default_pathmaps
|
27
|
+
config.webxml = default_webxml_config
|
28
|
+
config.webinf_files = default_webinf_files
|
29
|
+
config.java_libs = default_jar_files
|
30
|
+
config.public_html = FileList["public/**/{.[!.],.??*,*}"] # include dotfiles
|
31
|
+
config.jar_extension = 'war'
|
32
|
+
config.init_contents << "#{config.warbler_templates}/war.erb"
|
33
|
+
end
|
34
|
+
|
35
|
+
def after_configure
|
36
|
+
update_gem_path(DEFAULT_GEM_PATH)
|
37
|
+
end
|
38
|
+
|
39
|
+
def default_pathmaps
|
40
|
+
p = OpenStruct.new
|
41
|
+
p.public_html = ["%{public/,}p"]
|
42
|
+
p.java_libs = ["WEB-INF/lib/%f"]
|
43
|
+
p.java_classes = ["WEB-INF/classes/%p"]
|
44
|
+
p.application = ["WEB-INF/%p"]
|
45
|
+
p.webinf = ["WEB-INF/%{.erb$,}f"]
|
46
|
+
p.gemspecs = ["#{config.relative_gem_path}/specifications/%f"]
|
47
|
+
p.gems = ["#{config.relative_gem_path}/gems/%p"]
|
48
|
+
p
|
49
|
+
end
|
50
|
+
|
51
|
+
def default_webxml_config
|
52
|
+
c = WebxmlOpenStruct.new
|
53
|
+
c.public.root = '/'
|
54
|
+
c.jndi = nil
|
55
|
+
c.ignored = %w(jndi booter)
|
56
|
+
c
|
57
|
+
end
|
58
|
+
|
59
|
+
def default_webinf_files
|
60
|
+
webxml = if File.exist?("config/web.xml")
|
61
|
+
"config/web.xml"
|
62
|
+
elsif File.exist?("config/web.xml.erb")
|
63
|
+
"config/web.xml.erb"
|
64
|
+
else
|
65
|
+
"#{WARBLER_HOME}/web.xml.erb"
|
66
|
+
end
|
67
|
+
FileList[webxml]
|
68
|
+
end
|
69
|
+
|
70
|
+
def default_jar_files
|
71
|
+
require 'jruby-jars' unless defined? JRubyJars.core_jar_path
|
72
|
+
require 'jruby-rack' unless defined? JRubyJars.jruby_rack_jar_path
|
73
|
+
FileList[JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path, JRubyJars.jruby_rack_jar_path]
|
74
|
+
end
|
75
|
+
|
76
|
+
def update_archive(jar)
|
77
|
+
add_public_files(jar)
|
78
|
+
add_webxml(jar)
|
79
|
+
move_jars_to_webinf_lib(jar, config.move_jars_to_webinf_lib)
|
80
|
+
add_runnables(jar) if config.features.include?("runnable")
|
81
|
+
add_executables(jar) if config.features.include?("executable")
|
82
|
+
add_gemjar(jar) if config.features.include?("gemjar")
|
83
|
+
end
|
84
|
+
|
85
|
+
# Add public/static assets to the root of the war file.
|
86
|
+
def add_public_files(jar)
|
87
|
+
config.public_html.exclude( *(config.excludes.to_a) )
|
88
|
+
config.public_html.map {|f| jar.add_with_pathmaps(config, f, :public_html) }
|
89
|
+
end
|
90
|
+
|
91
|
+
# Add web.xml and other WEB-INF configuration files from
|
92
|
+
# config.webinf_files to the war file.
|
93
|
+
def add_webxml(jar)
|
94
|
+
config.webinf_files.each do |wf|
|
95
|
+
if wf =~ /\.erb$/
|
96
|
+
jar.files[apply_pathmaps(config, wf, :webinf)] = jar.expand_erb(wf, config)
|
97
|
+
else
|
98
|
+
jar.files[apply_pathmaps(config, wf, :webinf)] = wf
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def add_runnables(jar, main_class = 'WarMain')
|
104
|
+
main_class = main_class.sub('.class', '') # handles WarMain.class
|
105
|
+
unless config.manifest_file
|
106
|
+
manifest = Warbler::Jar::DEFAULT_MANIFEST.chomp + "Main-Class: #{main_class}\n"
|
107
|
+
jar.files['META-INF/MANIFEST.MF'] = StringIO.new(manifest)
|
108
|
+
end
|
109
|
+
[ 'JarMain', 'WarMain', main_class ].uniq.each do |klass|
|
110
|
+
jar.files["#{klass}.class"] = jar.entry_in_jar(WARBLER_JAR, "#{klass}.class")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_executables(jar)
|
115
|
+
webserver = WEB_SERVERS[config.webserver.to_s]
|
116
|
+
webserver.add(jar)
|
117
|
+
add_runnables jar, webserver.main_class || 'WarMain'
|
118
|
+
end
|
119
|
+
|
120
|
+
def add_gemjar(jar)
|
121
|
+
gem_jar = Warbler::Jar.new
|
122
|
+
gem_path = Regexp::quote(config.relative_gem_path)
|
123
|
+
gems = jar.files.select{|k,v| k =~ %r{#{gem_path}/} }
|
124
|
+
gems.each do |k,v|
|
125
|
+
gem_jar.files[k.sub(%r{#{gem_path}/}, '')] = v
|
126
|
+
end
|
127
|
+
jar.files["WEB-INF/lib/gems.jar"] = "tmp/gems.jar"
|
128
|
+
jar.files.reject!{|k,v| k =~ /#{gem_path}/ || k == "WEB-INF/tmp/gems.jar"}
|
129
|
+
mkdir_p "tmp"
|
130
|
+
gem_jar.add_manifest
|
131
|
+
gem_jar.create("tmp/gems.jar")
|
132
|
+
end
|
133
|
+
|
134
|
+
def move_jars_to_webinf_lib(jar, selector = nil)
|
135
|
+
return unless selector # default is false
|
136
|
+
selector = /.*/ if selector == true # move all if not a RegExp given
|
137
|
+
default_jar_paths = default_jar_files
|
138
|
+
default_jars = default_jar_paths.map { |file| File.basename(file) }
|
139
|
+
jar.files.keys.select { |k| k =~ /^WEB-INF\/.*\.jar$/ }.each do |k|
|
140
|
+
if k.start_with?('WEB-INF/lib/') # .jar already in WEB-INF/lib
|
141
|
+
if default_jars.include? k.sub('WEB-INF/lib/', '')
|
142
|
+
# exclude default jar (if it's not matched by selector) :
|
143
|
+
jar.files.delete(k) unless selector =~ File.basename(k)
|
144
|
+
end
|
145
|
+
next
|
146
|
+
end
|
147
|
+
next unless selector =~ File.basename(k)
|
148
|
+
# default jars might end up mapped twice as they're part of gems
|
149
|
+
next if default_jar_paths.include?(jar.files[k])
|
150
|
+
name = k.sub('WEB-INF', '')[1..-1].gsub(/[\/\\]/, '-')
|
151
|
+
jar.files["WEB-INF/lib/#{name}"] = jar.files[k]
|
152
|
+
jar.files[k] = empty_jar
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def empty_jar
|
157
|
+
@empty_jar ||= begin
|
158
|
+
t = Tempfile.new(["empty", "jar"])
|
159
|
+
path = t.path
|
160
|
+
t.close!
|
161
|
+
ZipSupport.create(path) do |zipfile|
|
162
|
+
zipfile.mkdir("META-INF")
|
163
|
+
zipfile.get_output_stream("META-INF/MANIFEST.MF") {|f| f << ::Warbler::Jar::DEFAULT_MANIFEST }
|
164
|
+
end
|
165
|
+
at_exit { File.delete(path) }
|
166
|
+
path
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Helper class for holding arbitrary config.webxml values for injecting into +web.xml+.
|
171
|
+
class WebxmlOpenStruct < OpenStruct
|
172
|
+
|
173
|
+
%w(java com org javax gem).each do |name|
|
174
|
+
class_eval "def #{name}; method_missing(:#{name}); end"
|
175
|
+
end
|
176
|
+
|
177
|
+
def initialize(key = 'webxml')
|
178
|
+
@key = key
|
179
|
+
@table = Hash.new { |h, k|
|
180
|
+
new_ostruct_member!(k)
|
181
|
+
h[k] = WebxmlOpenStruct.new(k)
|
182
|
+
}
|
183
|
+
|
184
|
+
@servlet_filter_async = nil # true/false
|
185
|
+
end
|
186
|
+
|
187
|
+
def servlet_filter; @servlet_filter ||= 'org.jruby.rack.RackFilter' end
|
188
|
+
attr_writer :servlet_filter
|
189
|
+
|
190
|
+
def servlet_filter_name; @servlet_filter_name ||= 'RackFilter' end
|
191
|
+
attr_writer :servlet_filter_name
|
192
|
+
|
193
|
+
def servlet_filter_url_pattern; @servlet_filter_url_pattern ||= '/*' end
|
194
|
+
attr_writer :servlet_filter_url_pattern
|
195
|
+
|
196
|
+
attr_accessor :servlet_filter_async
|
197
|
+
|
198
|
+
def servlet_context_listener
|
199
|
+
case booter
|
200
|
+
when :rack
|
201
|
+
'org.jruby.rack.RackServletContextListener'
|
202
|
+
when :rails
|
203
|
+
'org.jruby.rack.rails.RailsServletContextListener'
|
204
|
+
else # default (due compatibility)
|
205
|
+
'org.jruby.rack.rails.RailsServletContextListener'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def servlet_context_listeners
|
210
|
+
@servlet_context_listeners ||= [ servlet_context_listener ]
|
211
|
+
end
|
212
|
+
|
213
|
+
def servlet_context_params(escape = true)
|
214
|
+
require 'cgi'; params = {}
|
215
|
+
@table.each do |k,v|
|
216
|
+
case v
|
217
|
+
when WebxmlOpenStruct
|
218
|
+
v.context_params.each do |nk,nv|
|
219
|
+
params["#{escape ? CGI::escapeHTML(k.to_s) : k.to_s}.#{nk}"] = nv
|
220
|
+
end
|
221
|
+
else
|
222
|
+
params[escape ? CGI::escapeHTML(k.to_s) : k.to_s] = escape ? CGI::escapeHTML(v.to_s) : v.to_s
|
223
|
+
end
|
224
|
+
end
|
225
|
+
extra_ignored = Array === ignored ? ignored : []
|
226
|
+
params.delete_if { |k,_| ['ignored', *extra_ignored].include?(k.to_s) }
|
227
|
+
params
|
228
|
+
end
|
229
|
+
# @deprecated
|
230
|
+
alias_method :context_params, :servlet_context_params
|
231
|
+
|
232
|
+
def to_s
|
233
|
+
"No value for '#@key' found"
|
234
|
+
end
|
235
|
+
|
236
|
+
private
|
237
|
+
|
238
|
+
def method_missing(mid, *args)
|
239
|
+
len = args.length
|
240
|
+
if mname = mid[/.*(?==\z)/m]
|
241
|
+
if len != 1
|
242
|
+
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
|
243
|
+
end
|
244
|
+
self[mname] = args[0]
|
245
|
+
elsif len == 0
|
246
|
+
@table[mid]
|
247
|
+
else
|
248
|
+
err = NoMethodError.new "undefined method `#{mid}' for #{self}", mid, args
|
249
|
+
err.set_backtrace caller(1)
|
250
|
+
raise err
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def respond_to_missing?(mid, include_private = false)
|
255
|
+
@table.key?(mid.to_s.chomp('=').to_sym) || super
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010-2012 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
6
|
+
#++
|
7
|
+
|
8
|
+
require 'stringio'
|
9
|
+
require 'tsort'
|
10
|
+
|
11
|
+
module Warbler
|
12
|
+
# Traits are project configuration characteristics that correspond
|
13
|
+
# to the framework or project layout. Each trait corresponds to a
|
14
|
+
# class in Warbler::Traits that contains baked-in knowledge about
|
15
|
+
# the kind of project and how it should be packed into the jar or
|
16
|
+
# war file.
|
17
|
+
module Traits
|
18
|
+
attr_accessor :traits
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@traits = auto_detect_traits
|
22
|
+
end
|
23
|
+
|
24
|
+
def auto_detect_traits
|
25
|
+
TraitsDependencyArray.new(Traits.constants.map {|t| Traits.const_get(t)}).tsort.select {|tc| tc.detect? }
|
26
|
+
end
|
27
|
+
|
28
|
+
def before_configure
|
29
|
+
trait_objects.each {|t| t.before_configure }
|
30
|
+
end
|
31
|
+
|
32
|
+
def after_configure
|
33
|
+
trait_objects.each {|t| t.after_configure }
|
34
|
+
end
|
35
|
+
|
36
|
+
def trait_objects
|
37
|
+
@trait_objects ||= @traits.map {|klass| klass.new(self) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_archive(jar)
|
41
|
+
trait_objects.each {|t| t.update_archive(jar) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def dump_traits
|
45
|
+
@trait_objects = nil
|
46
|
+
@traits.collect! {|t| t.name }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Each trait class includes this module to receive shared functionality.
|
51
|
+
module Trait
|
52
|
+
module ClassMethods
|
53
|
+
def requirements
|
54
|
+
[]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.included(base)
|
59
|
+
base.extend ClassMethods
|
60
|
+
end
|
61
|
+
|
62
|
+
attr_reader :config
|
63
|
+
def initialize(config)
|
64
|
+
@config = config
|
65
|
+
end
|
66
|
+
|
67
|
+
def before_configure
|
68
|
+
end
|
69
|
+
|
70
|
+
def after_configure
|
71
|
+
end
|
72
|
+
|
73
|
+
def update_archive(jar)
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_init_load_path(path)
|
77
|
+
config.init_contents << StringIO.new("$LOAD_PATH.unshift File.expand_path(File.join('..', '..', '#{path}'), __FILE__)\n")
|
78
|
+
# with __FILE__ = "uri:classloader:/META-INF/init.rb"
|
79
|
+
# ... will end up as "uri:classloader://xxx-gem/lib"
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_main_rb(jar, bin_path, params = nil)
|
83
|
+
binary = "".dup
|
84
|
+
binary << "ARGV.unshift('#{params}')\n" if params
|
85
|
+
binary << "load '#{bin_path}'"
|
86
|
+
jar.files['META-INF/main.rb'] = StringIO.new(binary)
|
87
|
+
end
|
88
|
+
|
89
|
+
def update_gem_path(default_gem_path)
|
90
|
+
if config.gem_path != default_gem_path
|
91
|
+
config.gem_path = "/#{config.gem_path}" unless config.gem_path =~ %r{^/}
|
92
|
+
sub_gem_path = config.gem_path[1..-1]
|
93
|
+
config.pathmaps.marshal_dump.keys.each do |pm|
|
94
|
+
config.pathmaps.send(pm).each {|p| p.sub!(default_gem_path[1..-1], sub_gem_path)}
|
95
|
+
end
|
96
|
+
config.webxml["gem"]["path"] = config.gem_path if config.webxml
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def jruby_jars
|
101
|
+
require 'jruby-jars'
|
102
|
+
FileList[JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class TraitsDependencyArray < Array
|
107
|
+
include TSort
|
108
|
+
|
109
|
+
alias tsort_each_node each
|
110
|
+
def tsort_each_child(node, &block)
|
111
|
+
node.requirements.each(&block)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
require 'warbler/traits/jar'
|
118
|
+
require 'warbler/traits/war'
|
119
|
+
require 'warbler/traits/rails'
|
120
|
+
require 'warbler/traits/rack'
|
121
|
+
require 'warbler/traits/bundler'
|
122
|
+
require 'warbler/traits/jbundler'
|
123
|
+
require 'warbler/traits/gemspec'
|
124
|
+
require 'warbler/traits/nogemspec'
|
data/lib/warbler/war.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
module Warbler
|
2
|
+
class WebServer
|
3
|
+
class Artifact < Struct.new(:repo, :group_id, :artifact_id, :version)
|
4
|
+
|
5
|
+
def path_fragment
|
6
|
+
@path_fragment ||= "#{group_id.gsub('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.jar"
|
7
|
+
end
|
8
|
+
|
9
|
+
def cached_path
|
10
|
+
@cached_path ||= File.join(local_repository, path_fragment)
|
11
|
+
end
|
12
|
+
|
13
|
+
def download_url
|
14
|
+
@download_url ||= "#{repo}/#{path_fragment}" #:nocov:
|
15
|
+
end
|
16
|
+
|
17
|
+
def local_path
|
18
|
+
unless File.exist?(cached_path)
|
19
|
+
puts "Downloading #{artifact_id}-#{version}.jar" #:nocov:
|
20
|
+
FileUtils.mkdir_p File.dirname(cached_path) #:nocov:
|
21
|
+
require 'open-uri' #:nocov:
|
22
|
+
begin
|
23
|
+
open(download_url) do |stream| #:nocov:
|
24
|
+
File.open(cached_path, "wb") do |f| #:nocov:
|
25
|
+
while buf = stream.read(4096) #:nocov:
|
26
|
+
f << buf #:nocov:
|
27
|
+
end #:nocov:
|
28
|
+
end #:nocov:
|
29
|
+
end #:nocov:
|
30
|
+
rescue => e
|
31
|
+
e.message.concat " - #{download_url}"
|
32
|
+
raise e
|
33
|
+
end
|
34
|
+
end
|
35
|
+
cached_path
|
36
|
+
end
|
37
|
+
|
38
|
+
@@local_repository = nil
|
39
|
+
|
40
|
+
def local_repository
|
41
|
+
@@local_repository ||= begin
|
42
|
+
m2_home = File.join(user_home, '.m2')
|
43
|
+
if File.exist?(settings = File.join(m2_home, 'settings.xml'))
|
44
|
+
local_repo = detect_local_repository(settings)
|
45
|
+
end
|
46
|
+
if local_repo.nil? && mvn_home = ENV['M2_HOME'] || ENV['MAVEN_HOME']
|
47
|
+
if File.exist?(settings = File.join(mvn_home, 'conf/settings.xml'))
|
48
|
+
local_repo = detect_local_repository(settings)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
local_repo || File.join(m2_home, 'repository')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def user_home
|
58
|
+
ENV[ 'HOME' ] || begin
|
59
|
+
user_home = Dir.home if Dir.respond_to?(:home)
|
60
|
+
unless user_home
|
61
|
+
user_home = ENV_JAVA[ 'user.home' ] if Object.const_defined?(:ENV_JAVA)
|
62
|
+
end
|
63
|
+
user_home
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def detect_local_repository(settings); require 'rexml/document'
|
68
|
+
doc = REXML::Document.new( File.read( settings ) )
|
69
|
+
if local_repo = doc.root.elements['localRepository']
|
70
|
+
if ( local_repo = local_repo.first )
|
71
|
+
local_repo = local_repo.value
|
72
|
+
local_repo = nil if local_repo.empty?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
local_repo
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def add(jar)
|
81
|
+
jar.files["WEB-INF/webserver.jar"] = @artifact.local_path
|
82
|
+
end
|
83
|
+
|
84
|
+
def main_class
|
85
|
+
'WarMain.class'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class JettyServer < WebServer
|
90
|
+
def initialize
|
91
|
+
@artifact = Artifact.new(ENV["MAVEN_REPO"] || "https://repo1.maven.org/maven2",
|
92
|
+
"org.eclipse.jetty", "jetty-runner",
|
93
|
+
ENV["WEBSERVER_VERSION"] || "9.2.9.v20150224")
|
94
|
+
end
|
95
|
+
|
96
|
+
def add(jar)
|
97
|
+
super
|
98
|
+
jar.files["WEB-INF/webserver.xml"] ||= StringIO.new(<<-CONFIG)
|
99
|
+
<?xml version="1.0"?>
|
100
|
+
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
101
|
+
|
102
|
+
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
103
|
+
</Configure>
|
104
|
+
CONFIG
|
105
|
+
|
106
|
+
jar.files["WEB-INF/webserver.properties"] ||= StringIO.new(<<-PROPS)
|
107
|
+
mainclass = org.eclipse.jetty.runner.Runner
|
108
|
+
args = args0,args1,args2,args3,args4,args5,args6
|
109
|
+
props = jetty.home
|
110
|
+
args0 = --host
|
111
|
+
args1 = {{host}}
|
112
|
+
args2 = --port
|
113
|
+
args3 = {{port}}
|
114
|
+
args4 = --config
|
115
|
+
args5 = {{config}}
|
116
|
+
args6 = {{warfile}}
|
117
|
+
jetty.home = {{webroot}}
|
118
|
+
PROPS
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
WEB_SERVERS = Hash.new { |hash,_| hash['jetty'] }
|
123
|
+
WEB_SERVERS['jetty'] = JettyServer.new
|
124
|
+
|
125
|
+
end
|
data/lib/warbler.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010-2012 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
6
|
+
#++
|
7
|
+
|
8
|
+
# Warbler is a lightweight, flexible, Rake-based system for packaging
|
9
|
+
# your Ruby applications into .jar or .war files.
|
10
|
+
module Warbler
|
11
|
+
WARBLER_HOME = File.expand_path(File.dirname(__FILE__) + '/..') unless defined?(WARBLER_HOME)
|
12
|
+
WARBLER_JAR = "#{WARBLER_HOME}/lib/warbler_jar.jar" unless defined?(WARBLER_JAR)
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# An instance of Warbler::Application used by the +warble+ command.
|
16
|
+
attr_accessor :application
|
17
|
+
# Set Warbler.framework_detection to false to disable
|
18
|
+
# auto-detection based on application configuration.
|
19
|
+
attr_accessor :framework_detection
|
20
|
+
attr_writer :project_application
|
21
|
+
end
|
22
|
+
|
23
|
+
# Warbler loads the project Rakefile in a separate Rake application
|
24
|
+
# from the one where the Warbler tasks are run.
|
25
|
+
def self.project_application
|
26
|
+
application.load_project_rakefile if application
|
27
|
+
@project_application || Rake.application
|
28
|
+
end
|
29
|
+
self.framework_detection = true
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'warbler/version'
|
33
|
+
require 'warbler/executable_helper'
|
34
|
+
require 'warbler/rake_helper'
|
35
|
+
require 'warbler/pathmap_helper'
|
36
|
+
require 'warbler/platform_helper'
|
37
|
+
require 'warbler/bundler_helper'
|
38
|
+
require 'warbler/task'
|
39
|
+
require 'warbler/application'
|
40
|
+
require 'warbler/web_server'
|
data/lib/warbler_jar.jar
ADDED
Binary file
|