-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support building a deployable and self-executable WAR file of Squash #57
Changes from all commits
78f9d71
70c8f37
f7efd34
5a6d873
65b6de2
160d1af
07d58df
5f3c487
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ | |
node_modules | ||
doc/fdoc-html | ||
tmp/cache/* | ||
*.war | ||
public/assets | ||
bin/* | ||
config/database.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,3 +78,9 @@ group :test do | |
end | ||
|
||
gem 'sql_origin', groups: [:development, :test] | ||
|
||
# Warbler seems to bundle its own gemspec even when skipping | ||
# :development. The gemspec requires warbler/version which doesn't | ||
# exist so the whole thing blows up. Putting this in :default group | ||
# until I can figure out how to fix it. | ||
gem 'warbler', github: 'bjeanes/warbler', platform: :jruby, require: nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Squash uses JRuby at Square but we don't need Warbler; no reason we should have to install the gem. I'm facing a similar issue with Resque integration -- how can I avoid bundling the Resque gems for installs that don't use Resque? Bundler has no concept of an "optional" gem. I need to come up with a comprehensive solution to this problem before we integrate too many optional third-party tools. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes a lot of sense. I'll think about it too. If I were in your position, I would investigate what it would take to make Squash a Rails engine such that people can simply include it as a gem into their own mostly empty Rails app and set up customizations from there. I'm going to investigate vendoring Square and mounting the Rails app into a small Rack app as is... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah there were a lot of suggestions about making Squash some kind of giant gem that gets included into an otherwise empty app, but I think that kinda obfuscates the implementation a bit and disincentivizes contribution to the web app. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, the most recent commits added a decent (but not awesome) functionality for optional gems. Check it out! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Replace this with a random value (e.g. result of `head -c2048 /dev/urandom | openssl sha1`) | ||
secret_token: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
config_dir = ENV['CONFIG_DIR'] | ||
|
||
if config_dir && File.directory?(config_dir) | ||
Dir["#{config_dir}/**/*.yml"].sort.each do |config| | ||
Squash::Configuration << config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should no longer be necessary, thanks to the commit I just pushed to Configoro master. |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# Disable Rake-environment-task framework detection by uncommenting/setting to false | ||
Warbler.framework_detection = false | ||
|
||
# Warbler web application assembly configuration file | ||
Warbler::Config.new do |config| | ||
# Features: additional options controlling how the jar is built. | ||
# Currently the following features are supported: | ||
# - gemjar: package the gem repository in a jar file in WEB-INF/lib | ||
# - executable: embed a web server and make the war executable | ||
# - compiled: compile .rb files to .class files | ||
config.features = %w(executable runnable) | ||
|
||
# Application directories to be included in the webapp. | ||
config.dirs = %w(app bin config data db lib log script vendor tmp) | ||
|
||
# Additional files/directories to include, above those in config.dirs | ||
# config.includes = FileList["db"] | ||
|
||
# Additional files/directories to exclude | ||
config.excludes = FileList["spec", "test", "tmp/**/*", "log/*"] | ||
|
||
# Additional Java .jar files to include. Note that if .jar files are placed | ||
# in lib (and not otherwise excluded) then they need not be mentioned here. | ||
# JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include your | ||
# own versions if you directly set the value | ||
# config.java_libs += FileList["lib/java/*.jar"] | ||
|
||
# Loose Java classes and miscellaneous files to be included. | ||
# config.java_classes = FileList["target/classes/**.*"] | ||
|
||
# One or more pathmaps defining how the java classes should be copied into | ||
# the archive. The example pathmap below accompanies the java_classes | ||
# configuration above. See http://rake.rubyforge.org/classes/String.html#M000017 | ||
# for details of how to specify a pathmap. | ||
# config.pathmaps.java_classes << "%{target/classes/,}p" | ||
|
||
# Bundler support is built-in. If Warbler finds a Gemfile in the | ||
# project directory, it will be used to collect the gems to bundle | ||
# in your application. If you wish to explicitly disable this | ||
# functionality, uncomment here. | ||
# config.bundler = false | ||
|
||
# An array of Bundler groups to avoid including in the war file. | ||
# Defaults to ["development", "test", "assets"]. | ||
# config.bundle_without = [] | ||
|
||
# Other gems to be included. If you don't use Bundler or a gemspec | ||
# file, you need to tell Warbler which gems your application needs | ||
# so that they can be packaged in the archive. | ||
# For Rails applications, the Rails gems are included by default | ||
# unless the vendor/rails directory is present. | ||
# config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"] | ||
# config.gems << "tzinfo" | ||
|
||
# Uncomment this if you don't want to package rails gem. | ||
# config.gems -= ["rails"] | ||
|
||
# The most recent versions of gems are used. | ||
# You can specify versions of gems by using a hash assignment: | ||
# config.gems["rails"] = "2.3.10" | ||
|
||
# You can also use regexps or Gem::Dependency objects for flexibility or | ||
# finer-grained control. | ||
# config.gems << /^merb-/ | ||
# config.gems << Gem::Dependency.new("merb-core", "= 0.9.3") | ||
|
||
# Include gem dependencies not mentioned specifically. Default is | ||
# true, uncomment to turn off. | ||
# config.gem_dependencies = false | ||
|
||
# Array of regular expressions matching relative paths in gems to be | ||
# excluded from the war. Defaults to empty, but you can set it like | ||
# below, which excludes test files. | ||
config.gem_excludes = [/^(test|spec)\//] | ||
|
||
# Pathmaps for controlling how application files are copied into the archive | ||
# config.pathmaps.application = ["WEB-INF/%p"] | ||
|
||
# Name of the archive (without the extension). Defaults to the basename | ||
# of the project directory. | ||
config.jar_name = "squash" | ||
|
||
# Name of the MANIFEST.MF template for the war file. Defaults to a simple | ||
# MANIFEST.MF that contains the version of Warbler used to create the war file. | ||
# config.manifest_file = "config/MANIFEST.MF" | ||
|
||
# When using the 'compiled' feature and specified, only these Ruby | ||
# files will be compiled. Default is to compile all \.rb files in | ||
# the application. | ||
# config.compiled_ruby_files = FileList['app/**/*.rb'] | ||
|
||
# === War files only below here === | ||
|
||
# Path to the pre-bundled gem directory inside the war file. Default | ||
# is 'WEB-INF/gems'. Specify path if gems are already bundled | ||
# before running Warbler. This also sets 'gem.path' inside web.xml. | ||
# config.gem_path = "WEB-INF/vendor/bundler_gems" | ||
|
||
# Files for WEB-INF directory (next to web.xml). This contains | ||
# web.xml by default. If there is an .erb-File it will be processed | ||
# with webxml-config. You may want to exclude this file via | ||
# config.excludes. | ||
# config.webinf_files += FileList["jboss-web.xml"] | ||
|
||
# Files to be included in the root of the webapp. Note that files in public | ||
# will have the leading 'public/' part of the path stripped during staging. | ||
# config.public_html = FileList["public/**/*", "doc/**/*"] | ||
|
||
# Pathmaps for controlling how public HTML files are copied into the .war | ||
# config.pathmaps.public_html = ["%{public/,}p"] | ||
|
||
# Embedded webserver to use with the 'executable' feature. Currently supported | ||
# webservers are: | ||
# * <tt>winstone</tt> (default) - Winstone 0.9.10 from sourceforge | ||
# * <tt>jenkins-ci.winstone</tt> - Improved Winstone from Jenkins CI | ||
# * <tt>jetty</tt> - Embedded Jetty from Eclipse | ||
config.webserver = 'jetty' | ||
|
||
# Value of RAILS_ENV for the webapp -- default as shown below | ||
config.webxml.rails.env = 'production' | ||
|
||
# Application booter to use, one of :rack, :rails, or :merb (autodetected by default) | ||
config.webxml.booter = :rails | ||
|
||
# Set JRuby to run in 1.9 mode. | ||
config.webxml.jruby.compat.version = "1.9" | ||
|
||
# When using the :rack booter, "Rackup" script to use. | ||
# - For 'rackup.path', the value points to the location of the rackup | ||
# script in the web archive file. You need to make sure this file | ||
# gets included in the war, possibly by adding it to config.includes | ||
# or config.webinf_files above. | ||
# - For 'rackup', the rackup script you provide as an inline string | ||
# is simply embedded in web.xml. | ||
# The script is evaluated in a Rack::Builder to load the application. | ||
# Examples: | ||
# config.webxml.rackup.path = 'WEB-INF/hello.ru' | ||
# config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)} | ||
# config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru")) | ||
|
||
# Control the pool of Rails runtimes. Leaving unspecified means | ||
# the pool will grow as needed to service requests. It is recommended | ||
# that you fix these values when running a production server! | ||
# If you're using threadsafe! mode, you probably don't want to set these values, | ||
# since 1 runtime(default for threadsafe mode) will be enough. | ||
config.webxml.jruby.min.runtimes = 1 | ||
config.webxml.jruby.max.runtimes = 1 | ||
|
||
# JNDI data source name | ||
# config.webxml.jndi = 'jdbc/rails' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
if RUBY_PLATFORM == "java" | ||
desc "Build a WAR file of project using Warbler" | ||
task :war => "assets:precompile:all" do | ||
require 'warbler' | ||
Warbler::Task.new(:warble) | ||
Rake::Task["warble"].invoke | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to (eventually) account for bundling with
--binstubs
such that you can run any gem command from the WAR file by doing (for example):java -jar squash.war -S rails console
. See jruby/warbler#136