lib/warbler/traits/war.rb in warbler-1.3.0.beta1 vs lib/warbler/traits/war.rb in warbler-1.3.0
- old
+ new
@@ -1,7 +1,8 @@
#--
-# Copyright (c) 2010 Engine Yard, Inc.
+# Copyright (c) 2010-2011 Engine Yard, Inc.
+# Copyright (c) 2007-2009 Sun Microsystems, Inc.
# This source code is available under the MIT license.
# See the file LICENSE.txt for details.
#++
require 'ostruct'
@@ -24,10 +25,11 @@
config.webxml = default_webxml_config
config.webinf_files = default_webinf_files
config.java_libs = default_jar_files
config.public_html = FileList["public/**/*"]
config.jar_extension = 'war'
+ config.init_contents << "#{config.warbler_templates}/war.erb"
end
def after_configure
update_gem_path(DEFAULT_GEM_PATH)
end
@@ -44,11 +46,10 @@
p
end
def default_webxml_config
c = WebxmlOpenStruct.new
- c.rails.env = ENV['RAILS_ENV'] || 'production'
c.public.root = '/'
c.jndi = nil
c.ignored = %w(jndi booter)
c
end
@@ -77,10 +78,11 @@
add_gemjar(jar) if config.features.include?("gemjar")
end
# Add public/static assets to the root of the war file.
def add_public_files(jar)
+ config.public_html.exclude *(config.excludes.to_a)
config.public_html.map {|f| jar.add_with_pathmaps(config, f, :public_html) }
end
# Add web.xml and other WEB-INF configuration files from
# config.webinf_files to the war file.
@@ -101,15 +103,15 @@
winstone_jar = File.expand_path("~/.m2/repository/#{winstone_path}")
unless File.exist?(winstone_jar)
# Not always covered in tests as these lines may not get
# executed every time if the jar is cached.
puts "Downloading #{winstone_type}.jar" #:nocov:
- mkdir_p File.dirname(t.name) #:nocov:
+ mkdir_p File.dirname(winstone_jar) #:nocov:
require 'open-uri' #:nocov:
maven_repo = ENV["MAVEN_REPO"] || "http://repo2.maven.org/maven2" #:nocov:
open("#{maven_repo}/#{winstone_path}") do |stream| #:nocov:
- File.open(t.name, "wb") do |f| #:nocov:
+ File.open(winstone_jar, "wb") do |f| #:nocov:
while buf = stream.read(4096) #:nocov:
f << buf #:nocov:
end #:nocov:
end #:nocov:
end #:nocov:
@@ -134,11 +136,14 @@
gem_jar.create("tmp/gems.jar")
end
# Helper class for holding arbitrary config.webxml values for injecting into +web.xml+.
class WebxmlOpenStruct < OpenStruct
- %w(java com org javax gem).each {|name| undef_method name if Object.methods.include?(name) }
+ %w(java com org javax gem).each do |name|
+ undef_method name if Object.methods.include?(name)
+ undef_method name.to_sym if Object.methods.include?(name.to_sym)
+ end
def initialize(key = 'webxml')
@key = key
@table = Hash.new {|h,k| h[k] = WebxmlOpenStruct.new(k) }
end
@@ -176,10 +181,11 @@
end
else
params[escape ? CGI::escapeHTML(k.to_s) : k.to_s] = escape ? CGI::escapeHTML(v.to_s) : v.to_s
end
end
- params.delete_if {|k,v| ['ignored', *ignored].include?(k.to_s) }
+ extra_ignored = Array === ignored ? ignored : []
+ params.delete_if {|k,v| ['ignored', *extra_ignored].include?(k.to_s) }
params
end
def to_s
"No value for '#@key' found"