warbler 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/History.txt +4 -0
- data/README.txt +13 -10
- data/Rakefile +1 -0
- data/lib/warbler/application.rb +7 -0
- data/lib/warbler/config.rb +3 -3
- data/lib/warbler/task.rb +15 -0
- data/lib/warbler/version.rb +1 -1
- data/lib/warbler/war.rb +21 -1
- data/lib/warbler.rb +5 -0
- data/lib/warbler_war.jar +0 -0
- metadata +6 -2
data/Gemfile
CHANGED
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -39,7 +39,7 @@ Now you should be able to invoke "rake war" to create your war file.
|
|
39
39
|
|
40
40
|
=== Bundler
|
41
41
|
|
42
|
-
Applications that use Bundler
|
42
|
+
Applications that use Bundler[http://gembundler.com/], detected via
|
43
43
|
presence of a +Gemfile+, will have the gems packaged up into the war
|
44
44
|
file. The .bundle/environment.rb file will be included for you, and
|
45
45
|
rewritten to use the paths to the gems inside the war.
|
@@ -67,16 +67,18 @@ contents will be used as the rackup script for your Rack-based application.
|
|
67
67
|
You will probably need to specify framework and application gems in
|
68
68
|
config/warble.rb.
|
69
69
|
|
70
|
-
See
|
70
|
+
See {the examples in the jruby-rack project}[http://github.com/nicksieger/jruby-rack/tree/master/examples/]
|
71
71
|
of how to configure Warbler to package Camping and Sinatra apps.
|
72
72
|
|
73
73
|
=== Configuration auto-detect notes
|
74
74
|
|
75
|
-
*
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
* Warbler will load the "environment" Rake task in a Rails application
|
76
|
+
to try to detect some configuration. If you don't have database
|
77
|
+
access in the environment where you package your application, you
|
78
|
+
may wish to set `Warbler.framework_detection` to false at the top of
|
79
|
+
config.rb. In this case you may need to specify additional details
|
80
|
+
such as booter, gems and other settings that would normally be
|
81
|
+
gleaned from the application configuration.
|
80
82
|
* A more accurate way of detecting a Merb application's gems is
|
81
83
|
needed. Until then, you will have to specify them in
|
82
84
|
config/warble.rb. See below.
|
@@ -110,9 +112,10 @@ creates a suitable default file for you for use. However, if you need to
|
|
110
112
|
customize it in any way, you have two options.
|
111
113
|
|
112
114
|
1. If you just want a static web.xml file whose contents you manually
|
113
|
-
control, you may
|
114
|
-
<tt>
|
115
|
-
modify as needed. It will be copied into
|
115
|
+
control, you may unzip the one generated for you in
|
116
|
+
<tt>yourapp.war:WEB-INF/web.xml</tt> to <tt>config/web.xml</tt> and
|
117
|
+
modify as needed. It will be copied into subsequent copies of the
|
118
|
+
war file for you.
|
116
119
|
2. If you want to inject some dynamic information into the file, copy
|
117
120
|
the <tt>WARBLER_HOME/web.xml.erb</tt> to
|
118
121
|
<tt>config/web.xml.erb</tt>. Its contents will be evaluated for you
|
data/Rakefile
CHANGED
data/lib/warbler/application.rb
CHANGED
@@ -7,6 +7,9 @@
|
|
7
7
|
|
8
8
|
require 'rake'
|
9
9
|
|
10
|
+
# Extension of Rake::Application that allows the +warble+ command to
|
11
|
+
# report its name properly and inject its own tasks without a
|
12
|
+
# Rakefile.
|
10
13
|
class Warbler::Application < Rake::Application
|
11
14
|
def initialize
|
12
15
|
super
|
@@ -14,6 +17,7 @@ class Warbler::Application < Rake::Application
|
|
14
17
|
@project_loaded = false
|
15
18
|
end
|
16
19
|
|
20
|
+
# Sets the application name and loads Warbler's own tasks
|
17
21
|
def load_rakefile
|
18
22
|
@name = 'warble'
|
19
23
|
|
@@ -41,6 +45,7 @@ class Warbler::Application < Rake::Application
|
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
48
|
+
# Loads the project Rakefile in a separate application
|
44
49
|
def load_project_rakefile
|
45
50
|
return if @project_loaded
|
46
51
|
# Load any application rakefiles to aid in autodetecting applications
|
@@ -56,6 +61,8 @@ class Warbler::Application < Rake::Application
|
|
56
61
|
@project_loaded = true
|
57
62
|
end
|
58
63
|
|
64
|
+
# Run the application: The equivalent code for the +warble+ command
|
65
|
+
# is simply <tt>Warbler::Application.new.run</tt>.
|
59
66
|
def run
|
60
67
|
Rake.application = self
|
61
68
|
super
|
data/lib/warbler/config.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
require 'ostruct'
|
9
9
|
|
10
10
|
module Warbler
|
11
|
-
# Warbler assembly configuration.
|
11
|
+
# Warbler war file assembly configuration class.
|
12
12
|
class Config
|
13
13
|
TOP_DIRS = %w(app config lib log vendor)
|
14
14
|
FILE = "config/warble.rb"
|
@@ -69,8 +69,7 @@ module Warbler
|
|
69
69
|
# the Rails application
|
70
70
|
attr_accessor :war_name
|
71
71
|
|
72
|
-
# Name of
|
73
|
-
# by jar -cf....
|
72
|
+
# Name of a MANIFEST.MF template to use.
|
74
73
|
attr_accessor :manifest_file
|
75
74
|
|
76
75
|
# Files for WEB-INF directory (next to web.xml). Contains web.xml by default.
|
@@ -279,6 +278,7 @@ module Warbler
|
|
279
278
|
end
|
280
279
|
end
|
281
280
|
|
281
|
+
# Helper class for holding arbitrary config.webxml values for injecting into +web.xml+.
|
282
282
|
class WebxmlOpenStruct < OpenStruct
|
283
283
|
%w(java com org javax).each {|name| undef_method name if Object.methods.include?(name) }
|
284
284
|
|
data/lib/warbler/task.rb
CHANGED
@@ -13,6 +13,21 @@ require 'zip/zip'
|
|
13
13
|
module Warbler
|
14
14
|
# Warbler Rake task. Allows defining multiple configurations inside the same
|
15
15
|
# Rakefile by using different task names.
|
16
|
+
#
|
17
|
+
# To define multiple Warbler configurations in a single project, use
|
18
|
+
# code like the following in a Rakefile:
|
19
|
+
#
|
20
|
+
# Warbler::Task.new("war1", Warbler::Config.new do |config|
|
21
|
+
# config.war_name = "war1"
|
22
|
+
# # ...
|
23
|
+
# end
|
24
|
+
# Warbler::Task.new("war2", Warbler::Config.new do |config|
|
25
|
+
# config.war_name = "war2"
|
26
|
+
# # ...
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# With this setup, you can create two separate war files two
|
30
|
+
# different configurations by running <tt>rake war1 war2</tt>.
|
16
31
|
class Task < Rake::TaskLib
|
17
32
|
# Task name
|
18
33
|
attr_accessor :name
|
data/lib/warbler/version.rb
CHANGED
data/lib/warbler/war.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
module Warbler
|
2
|
+
# Class that holds the files that will be stored in the war file.
|
3
|
+
# The #files attribute contains a hash of pathnames inside the war
|
4
|
+
# file to their contents. Contents can be one of:
|
5
|
+
# * +nil+ representing a directory entry
|
6
|
+
# * Any object responding to +read+ representing an in-memory blob
|
7
|
+
# * A String filename pointing to a file on disk
|
2
8
|
class War
|
3
9
|
attr_reader :files
|
4
10
|
attr_reader :webinf_filelist
|
@@ -7,6 +13,8 @@ module Warbler
|
|
7
13
|
@files = {}
|
8
14
|
end
|
9
15
|
|
16
|
+
# Apply the information in a Warbler::Config object in order to
|
17
|
+
# look for files to put into this war file.
|
10
18
|
def apply(config)
|
11
19
|
find_webinf_files(config)
|
12
20
|
find_java_libs(config)
|
@@ -18,6 +26,8 @@ module Warbler
|
|
18
26
|
add_bundler_files(config)
|
19
27
|
end
|
20
28
|
|
29
|
+
# Create the war file. The single argument can either be a
|
30
|
+
# Warbler::Config or a filename of the war file to create.
|
21
31
|
def create(config_or_path)
|
22
32
|
war_path = config_or_path
|
23
33
|
if Warbler::Config === config_or_path
|
@@ -30,6 +40,8 @@ module Warbler
|
|
30
40
|
create_war war_path, @files
|
31
41
|
end
|
32
42
|
|
43
|
+
# Add web.xml and other WEB-INF configuration files from
|
44
|
+
# config.webinf_files to the war file.
|
33
45
|
def add_webxml(config)
|
34
46
|
config.webinf_files.each do |wf|
|
35
47
|
if wf =~ /\.erb$/
|
@@ -43,6 +55,7 @@ module Warbler
|
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
58
|
+
# Add a manifest file either from config or by making a default manifest.
|
46
59
|
def add_manifest(config)
|
47
60
|
if config.manifest_file
|
48
61
|
@files['META-INF/MANIFEST.MF'] = config.manifest_file
|
@@ -51,22 +64,27 @@ module Warbler
|
|
51
64
|
end
|
52
65
|
end
|
53
66
|
|
67
|
+
# Add java libraries to WEB-INF/lib.
|
54
68
|
def find_java_libs(config)
|
55
69
|
config.java_libs.map {|lib| add_with_pathmaps(config, lib, :java_libs) }
|
56
70
|
end
|
57
71
|
|
72
|
+
# Add java classes to WEB-INF/classes.
|
58
73
|
def find_java_classes(config)
|
59
74
|
config.java_classes.map {|f| add_with_pathmaps(config, f, :java_classes) }
|
60
75
|
end
|
61
76
|
|
77
|
+
# Add public/static assets to the root of the war file.
|
62
78
|
def find_public_files(config)
|
63
79
|
config.public_html.map {|f| add_with_pathmaps(config, f, :public_html) }
|
64
80
|
end
|
65
81
|
|
82
|
+
# Add gems to WEB-INF/gems
|
66
83
|
def find_gems_files(config)
|
67
84
|
config.gems.each {|gem, version| find_single_gem_files(config, gem, version) }
|
68
85
|
end
|
69
86
|
|
87
|
+
# Add a single gem to WEB-INF/gems
|
70
88
|
def find_single_gem_files(config, gem_pattern, version = nil)
|
71
89
|
if Gem::Specification === gem_pattern
|
72
90
|
spec = gem_pattern
|
@@ -100,6 +118,7 @@ module Warbler
|
|
100
118
|
spec.dependencies.each {|dep| find_single_gem_files(config, dep) } if config.gem_dependencies
|
101
119
|
end
|
102
120
|
|
121
|
+
# Add all application directories and files to WEB-INF.
|
103
122
|
def find_webinf_files(config)
|
104
123
|
config.dirs.select do |d|
|
105
124
|
exists = File.directory?(d)
|
@@ -114,6 +133,7 @@ module Warbler
|
|
114
133
|
@webinf_filelist.map {|f| add_with_pathmaps(config, f, :application) }
|
115
134
|
end
|
116
135
|
|
136
|
+
# Add Bundler Gemfile and .bundle/environment.rb to the war file.
|
117
137
|
def add_bundler_files(config)
|
118
138
|
if config.bundler
|
119
139
|
@files[apply_pathmaps(config, 'Gemfile', :application)] = 'Gemfile'
|
@@ -164,6 +184,6 @@ module Warbler
|
|
164
184
|
end
|
165
185
|
|
166
186
|
# Java-boosted war creation for JRuby; replaces #create_war with Java version
|
167
|
-
require 'warbler_war' if defined?(JRUBY_VERSION)
|
187
|
+
require 'warbler_war' if defined?(JRUBY_VERSION) && JRUBY_VERSION >= "1.5"
|
168
188
|
end
|
169
189
|
end
|
data/lib/warbler.rb
CHANGED
@@ -11,11 +11,16 @@ module Warbler
|
|
11
11
|
WARBLER_HOME = File.expand_path(File.dirname(__FILE__) + '/..') unless defined?(WARBLER_HOME)
|
12
12
|
|
13
13
|
class << self
|
14
|
+
# An instance of Warbler::Application used by the +warble+ command.
|
14
15
|
attr_accessor :application
|
16
|
+
# Set Warbler.framework_detection to false to disable
|
17
|
+
# auto-detection based on application configuration.
|
15
18
|
attr_accessor :framework_detection
|
16
19
|
attr_writer :project_application
|
17
20
|
end
|
18
21
|
|
22
|
+
# Warbler loads the project Rakefile in a separate Rake application
|
23
|
+
# from the one where the Warbler tasks are run.
|
19
24
|
def self.project_application
|
20
25
|
application.load_project_rakefile if application
|
21
26
|
@project_application || Rake.application
|
data/lib/warbler_war.jar
CHANGED
Binary file
|
metadata
CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- Nick Sieger
|
@@ -13,7 +14,7 @@ autorequire:
|
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-06 00:00:00 -05:00
|
17
18
|
default_executable:
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
@@ -155,6 +156,9 @@ post_install_message:
|
|
155
156
|
rdoc_options:
|
156
157
|
- --main
|
157
158
|
- README.txt
|
159
|
+
- -SHN
|
160
|
+
- -f
|
161
|
+
- darkfish
|
158
162
|
require_paths:
|
159
163
|
- lib
|
160
164
|
required_ruby_version: !ruby/object:Gem::Requirement
|