warbler 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4464dec04874d3dce2dd2ffd5b4c5ee82a0d475
4
- data.tar.gz: cb9ea2082c156117e3990ac48012c9db695c379a
3
+ metadata.gz: 98d05a82e2e4f5ccfc47ffc014a1b4baf1872510
4
+ data.tar.gz: 27f3d80a4e3231a1120e72a13173ebcd2cc7ce64
5
5
  SHA512:
6
- metadata.gz: 64e0e83ebff4d7b073f90009ce1c47627fbea84799919f7842ba03b1fe91dcd5d9d331506dc7bb0838dd0f09b39bac3bfec4868bec084730fc83e8befa88aca9
7
- data.tar.gz: 784b4e947ec1c06ec230f15d5cc566d33dc964a99c417c5d417f5a43af5c0f97f753a55b3b0b8b3715ac5c0505ea43cb98cb6d31823a78068b6cc3b0f1b5046e
6
+ metadata.gz: 1b220ad7086cb9ceef5db6e1fc80d863e150bf0e8d6e0a5aa9cfd5b26c225f0e036a73dbb6bee9c6e774535e79c0b9112fc8a1a1e054057b9059d5831f253c67
7
+ data.tar.gz: 02e5f1796a08654fe5416e20a95f5e87abef27bf3d77870dbec64233e06864ed96fd9f880d0e0184d399fa962cfa49818691d524e4da0cec2e85f99a56c0408f
data/History.txt CHANGED
@@ -1,3 +1,14 @@
1
+ == 1.4.4
2
+ - #271: LoadError while excute rake command with runnable .war archive
3
+ - #273: filtering support with `config.move_jars_to_webinf_lib`
4
+ - #270: don't swallow compiler errors with backticks
5
+ - #265: Compile feature only compiles application sources (not gems)
6
+ - #264: JBundler with compiled feature crashes with java.lang.ClassNotFoundException: org.jruby.Main
7
+ - #269: Argument list too long
8
+ - #236: Adds comment hinting at how to put a display name in web.xml.erb file.
9
+ - #275: for jruby-1.7.13 we do not want to force load bouncy-castle jars
10
+ - #276: unnecessary rubyzip dependency on "< 1.1"
11
+
1
12
  == 1.4.3
2
13
  - Fixed a bug w/ symlinks that was introduced around jruby-1.7.10
3
14
  - #258: Bytecode version option for compiled class files
data/README.rdoc CHANGED
@@ -238,7 +238,7 @@ itself continues to support Ruby 1.8. However, many gems are choosing
238
238
  to drop 1.8 support; one of these gems is
239
239
  {rubyzip}(https://github.com/rubyzip/rubyzip), which Warbler relies
240
240
  on. If you need to use Warbler in a 1.8 environment, you will need to
241
- lock the `rubyzip` gem to a version before 1.0.0.
241
+ lock the <tt>rubyzip</tt> gem to a version before 1.0.0.
242
242
 
243
243
  == Troubleshooting
244
244
 
data/ext/WarMain.java CHANGED
@@ -308,10 +308,18 @@ public class WarMain extends JarMain {
308
308
 
309
309
  protected void initJRubyScriptingEnv(Object scriptingContainer, final URL[] jars) throws Exception {
310
310
  String jrubyStdlibJar = "";
311
+ String bcpkixJar = "";
312
+ String bcprovJar = "";
311
313
  for (URL url : jars) {
312
314
  if (url.toString().matches("file:/.*jruby-stdlib-.*jar")) {
313
315
  jrubyStdlibJar = url.toString();
314
316
  debug("using jruby-stdlib: " + jrubyStdlibJar);
317
+ } else if (url.toString().matches("file:/.*bcpkix-jdk15on-.*jar")) {
318
+ bcpkixJar = url.toString();
319
+ debug("using bcpkix: " + bcpkixJar);
320
+ } else if (url.toString().matches("file:/.*bcprov-jdk15on-.*jar")) {
321
+ bcprovJar = url.toString();
322
+ debug("using bcprov: " + bcprovJar);
315
323
  }
316
324
  }
317
325
 
@@ -322,14 +330,9 @@ public class WarMain extends JarMain {
322
330
  "$: << \"" + jrubyStdlibJar + "!/META-INF/jruby.home/lib/ruby/#{ruby}/site_ruby\"\n" +
323
331
  "$: << \"" + jrubyStdlibJar + "!/META-INF/jruby.home/lib/ruby/shared\"\n" +
324
332
  "$: << \"" + jrubyStdlibJar + "!/META-INF/jruby.home/lib/ruby/#{ruby}\"\n" +
325
- "if jruby_major_version >= 1.7\n" +
326
- " if jruby_minor_version >= 5\n" +
327
- " require 'bcpkix-jdk15on-1.47.jar'\n" +
328
- " require 'bcprov-jdk15on-1.47.jar'\n" +
329
- " else\n" +
330
- " require 'bcpkix-jdk15on-147.jar'\n" +
331
- " require 'bcprov-jdk15on-147.jar'\n" +
332
- " end\n" +
333
+ "if jruby_major_version >= 1.7 and jruby_minor_version < 13\n" +
334
+ " require \"" + bcpkixJar + "\".gsub('file:', '') unless \"" + bcpkixJar + "\".empty?\n" +
335
+ " require \"" + bcprovJar + "\".gsub('file:', '') unless \"" + bcprovJar + "\".empty?\n" +
333
336
  "end");
334
337
 
335
338
  invokeMethod(scriptingContainer, "setHomeDirectory", "classpath:/META-INF/jruby.home");
data/integration/pom.xml CHANGED
@@ -18,9 +18,9 @@
18
18
  <properties>
19
19
  <version.jruby-maven-plugins>1.0.0-rc</version.jruby-maven-plugins>
20
20
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21
- <jruby.version>1.7.12</jruby.version>
21
+ <jruby.version>1.7.13</jruby.version>
22
22
  <!-- prereleased gems ARE snapshots -->
23
- <warbler.version>1.4.3-SNAPSHOT</warbler.version>
23
+ <warbler.version>1.4.4-SNAPSHOT</warbler.version>
24
24
  <gem.home>${session.executionRootDirectory}/target/rubygems</gem.home>
25
25
  <gem.path>${session.executionRootDirectory}/target/rubygems</gem.path>
26
26
  </properties>
@@ -146,16 +146,13 @@
146
146
  <jrubyVersion>${jruby.version}</jrubyVersion>
147
147
  </configuration>
148
148
  <executions>
149
-
150
149
  <execution>
151
150
  <id>bundle-install</id>
152
-
153
- <goals><goal>jruby</goal></goals>
151
+ <goals><goal>jruby</goal></goals>
154
152
  <configuration>
155
153
  <args>-C ${basedir}/src/main/ruby -S ${gem.home}/bin/bundle install</args>
156
154
  </configuration>
157
155
  </execution>
158
-
159
156
  <execution>
160
157
  <id>create-war</id>
161
158
  <goals><goal>jruby</goal></goals>
@@ -116,6 +116,10 @@ module Warbler
116
116
  # compile all .rb files in the application.
117
117
  attr_accessor :compiled_ruby_files
118
118
 
119
+ # Determines if ruby files in supporting gems will be compiled.
120
+ # Ignored unless compile feature is used.
121
+ attr_accessor :compile_gems
122
+
119
123
  # Warbler writes an "init" file into the war at this location. JRuby-Rack and possibly other
120
124
  # launchers may use this to initialize the Ruby environment.
121
125
  attr_accessor :init_filename
@@ -204,6 +208,7 @@ module Warbler
204
208
  @script_files = []
205
209
  @warbler_scripts = "#{WARBLER_HOME}/lib/warbler/scripts"
206
210
  @move_jars_to_webinf_lib = false
211
+ @compile_gems = false
207
212
 
208
213
  before_configure
209
214
  yield self if block_given?
data/lib/warbler/jar.rb CHANGED
@@ -36,13 +36,20 @@ module Warbler
36
36
  end
37
37
 
38
38
  def compile(config)
39
+ find_gems_files(config)
39
40
  # Compiling all Ruby files we can find -- do we need to allow an
40
41
  # option to configure what gets compiled?
41
- return if config.compiled_ruby_files.nil? || config.compiled_ruby_files.empty?
42
+ return if (config.compiled_ruby_files.nil? || config.compiled_ruby_files.empty?) && files.empty?
42
43
 
43
- compiled_ruby_files = config.compiled_ruby_files - config.excludes.to_a
44
- run_javac(config, compiled_ruby_files)
45
- replace_compiled_ruby_files(config, compiled_ruby_files)
44
+ if config.compile_gems
45
+ ruby_files = gather_all_rb_files(config)
46
+ run_javac(config, ruby_files.values)
47
+ replace_compiled_ruby_files_and_gems(config, ruby_files)
48
+ else
49
+ compiled_ruby_files = config.compiled_ruby_files - config.excludes.to_a
50
+ run_javac(config, compiled_ruby_files)
51
+ replace_compiled_ruby_files(config, compiled_ruby_files)
52
+ end
46
53
  end
47
54
 
48
55
  def run_javac(config, compiled_ruby_files)
@@ -51,16 +58,20 @@ module Warbler
51
58
  else
52
59
  compat_version = ''
53
60
  end
54
- # Need to use the version of JRuby in the application to compile it
55
- javac_cmd = %Q{java -classpath #{config.java_libs.join(File::PATH_SEPARATOR)} #{java_version(config)} org.jruby.Main #{compat_version} -S jrubyc \"#{compiled_ruby_files.join('" "')}\"}
56
- if which('env')
57
- system %Q{env -i #{javac_cmd}}
58
- else
59
- system javac_cmd
61
+
62
+ compiled_ruby_files.each_slice(2500) do |slice|
63
+ # Need to use the version of JRuby in the application to compile it
64
+ javac_cmd = %Q{java -classpath #{config.java_libs.join(File::PATH_SEPARATOR)} #{java_version(config)} org.jruby.Main #{compat_version} -S jrubyc \"#{slice.join('" "')}\"}
65
+ if which('env')
66
+ system %Q{env -i #{javac_cmd}}
67
+ else
68
+ system javac_cmd
69
+ end
70
+ raise "Compile failed" if $?.exitstatus > 0
60
71
  end
61
- raise "Compile failed" if $?.exitstatus > 0
72
+ @compiled = true
62
73
  end
63
-
74
+
64
75
  def java_version(config)
65
76
  config.bytecode_version ? "-Djava.specification.version=#{config.bytecode_version}" : ''
66
77
  end
@@ -75,6 +86,55 @@ module Warbler
75
86
  end
76
87
  end
77
88
 
89
+ def replace_compiled_ruby_files_and_gems(config, compiled_ruby_files)
90
+ # Exclude the rb files and recreate them. This
91
+ # prevents the original contents being used.
92
+ config.excludes += compiled_ruby_files.keys
93
+
94
+ compiled_ruby_files.each do |inside_jar, file_system_location|
95
+ # The gems are already inside the gems folder inside the jar, however when using the :gems pathmap, they will
96
+ # get put into the gems/gems folder, to prevent this we chop off the first gems folder directory
97
+ inside_jar = inside_jar.dup
98
+ if inside_jar.split(File::SEPARATOR).first == 'gems'
99
+ inside_jar = inside_jar.split(File::SEPARATOR)[1..-1].join(File::SEPARATOR)
100
+ pathmap = :gems
101
+ else
102
+ pathmap = :application
103
+ end
104
+ files[apply_pathmaps(config, inside_jar, pathmap)] = StringIO.new("load __FILE__.sub(/\.rb$/, '.class')")
105
+ files[apply_pathmaps(config, inside_jar.sub(/\.rb$/, '.class'), pathmap)] = file_system_location.sub(/\.rb$/, '.class')
106
+ end
107
+ end
108
+
109
+ #
110
+ def gather_all_rb_files(config)
111
+ FileUtils.mkdir_p('tmp')
112
+ # Gather all the files in the files list and copy them to the tmp directory
113
+ gems_to_compile = files.select {|k, f| !f.is_a?(StringIO) && f =~ /\.rb$/ }
114
+ # 1.8.7 Support, convert back to hash
115
+ if gems_to_compile.is_a?(Array)
116
+ gems_to_compile = gems_to_compile.inject({}) {|h,z| h.merge!(z[0] => z[1]) }
117
+ end
118
+ gems_to_compile.each do |jar_file, rb|
119
+ FileUtils.mkdir_p(File.dirname(File.join('tmp', jar_file)))
120
+ new_rb = File.join('tmp', jar_file)
121
+ FileUtils.copy(rb, new_rb)
122
+ gems_to_compile[jar_file] = new_rb
123
+ end
124
+ # Gather all the application files which the user wrote (not dependencies)
125
+ main_files_to_compile = config.compiled_ruby_files - config.excludes.to_a
126
+ main_files_to_compile.each do |f|
127
+ FileUtils.mkdir_p(File.dirname(File.join('tmp', f)))
128
+ FileUtils.copy(f, File.join('tmp', f))
129
+ end
130
+ main_files_to_compile = main_files_to_compile.inject({}) {|h,f| h.merge!(f => f) }
131
+ files.keys.each do |k|
132
+ # Update files list to point to the temporary file
133
+ files[k] = gems_to_compile[k] || main_files_to_compile[k] || files[k]
134
+ end
135
+ main_files_to_compile.merge(gems_to_compile)
136
+ end
137
+
78
138
  # Apply the information in a Warbler::Config object in order to
79
139
  # look for files to put into this war file.
80
140
  def apply(config)
@@ -133,7 +193,9 @@ module Warbler
133
193
 
134
194
  # Add gems to WEB-INF/gems
135
195
  def find_gems_files(config)
136
- config.gems.specs(config.gem_dependencies).each {|spec| find_single_gem_files(config, spec) }
196
+ unless @compiled and config.compile_gems
197
+ config.gems.specs(config.gem_dependencies).each {|spec| find_single_gem_files(config, spec) }
198
+ end
137
199
  end
138
200
 
139
201
  # Add a single gem to WEB-INF/gems
@@ -97,6 +97,11 @@ module Warbler
97
97
  config.webxml["gem"]["path"] = config.gem_path if config.webxml
98
98
  end
99
99
  end
100
+
101
+ def jruby_jars
102
+ require 'jruby-jars'
103
+ FileList[JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path]
104
+ end
100
105
  end
101
106
  end
102
107
 
@@ -51,8 +51,7 @@ module Warbler
51
51
  end
52
52
 
53
53
  def default_jar_files
54
- require 'jruby-jars'
55
- FileList[JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path]
54
+ jruby_jars
56
55
  end
57
56
  end
58
57
  end
@@ -37,11 +37,10 @@ module Warbler
37
37
  else
38
38
  raise 'jbundler support needs jruby to create a local config: jruby -S jbundle install'
39
39
  end
40
- # use only the jars from jbundler
41
- config.java_libs.clear
42
- JBUNDLER_CLASSPATH.each do |jar|
43
- config.java_libs << jar
44
- end
40
+ # use only the jars from jbundler and jruby
41
+ config.java_libs += jruby_jars
42
+ config.java_libs += JBUNDLER_CLASSPATH
43
+ config.java_libs.uniq! {|lib| lib.split(File::SEPARATOR).last }
45
44
  config.init_contents << "#{config.warbler_templates}/jbundler.erb"
46
45
  end
47
46
  end
@@ -76,7 +76,7 @@ module Warbler
76
76
  def update_archive(jar)
77
77
  add_public_files(jar)
78
78
  add_webxml(jar)
79
- move_jars_to_webinf_lib(jar) if config.move_jars_to_webinf_lib
79
+ move_jars_to_webinf_lib(jar, config.move_jars_to_webinf_lib)
80
80
  add_runnables(jar) if config.features.include?("runnable")
81
81
  add_executables(jar) if config.features.include?("executable")
82
82
  add_gemjar(jar) if config.features.include?("gemjar")
@@ -110,7 +110,7 @@ module Warbler
110
110
  jar.files["#{klass}.class"] = jar.entry_in_jar(WARBLER_JAR, "#{klass}.class")
111
111
  end
112
112
  end
113
-
113
+
114
114
  def add_executables(jar)
115
115
  webserver = WEB_SERVERS[config.webserver.to_s]
116
116
  webserver.add(jar)
@@ -131,10 +131,21 @@ module Warbler
131
131
  gem_jar.create("tmp/gems.jar")
132
132
  end
133
133
 
134
- def move_jars_to_webinf_lib(jar)
135
- jar.files.keys.select {|k| k =~ /^WEB-INF\/.*\.jar$/ }.each do |k|
136
- next if k =~ /^WEB-INF\/lib\/([^\/]+)\.jar$/ # skip jars already in WEB-INF/lib
137
- jar.files["WEB-INF/lib/#{k.sub('WEB-INF','')[1..-1].gsub(/[\/\\]/,'-')}"] = jar.files[k]
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_jars = default_jar_files.map { |file| File.basename(file) }
138
+ jar.files.keys.select { |k| k =~ /^WEB-INF\/.*\.jar$/ }.each do |k|
139
+ if k.start_with?('WEB-INF/lib/') # .jar already in WEB-INF/lib
140
+ if default_jars.include? k.sub('WEB-INF/lib/', '')
141
+ # exclude default jar (if it's not matched by selector) :
142
+ jar.files.delete(k) unless selector =~ File.basename(k)
143
+ end
144
+ next
145
+ end
146
+ next unless selector =~ File.basename(k)
147
+ name = k.sub('WEB-INF', '')[1..-1].gsub(/[\/\\]/, '-')
148
+ jar.files["WEB-INF/lib/#{name}"] = jar.files[k]
138
149
  jar.files[k] = empty_jar
139
150
  end
140
151
  end
@@ -155,7 +166,7 @@ module Warbler
155
166
 
156
167
  # Helper class for holding arbitrary config.webxml values for injecting into +web.xml+.
157
168
  class WebxmlOpenStruct < OpenStruct
158
-
169
+
159
170
  %w(java com org javax gem).each do |name|
160
171
  class_eval "def #{name}; method_missing(:#{name}); end"
161
172
  end
@@ -6,5 +6,5 @@
6
6
  #++
7
7
 
8
8
  module Warbler
9
- VERSION = "1.4.3"
9
+ VERSION = "1.4.4"
10
10
  end
data/lib/warbler_jar.jar CHANGED
Binary file
data/pom.xml CHANGED
@@ -4,7 +4,7 @@
4
4
  <modelVersion>4.0.0</modelVersion>
5
5
  <groupId>rubygems</groupId>
6
6
  <artifactId>warbler</artifactId>
7
- <version>1.4.3-SNAPSHOT</version>
7
+ <version>1.4.4-SNAPSHOT</version>
8
8
  <packaging>gem</packaging>
9
9
  <name>Warbler chirpily constructs .war files of your Rails applications.</name>
10
10
  <description>Warbler is a gem to make a Java jar or war file out of any Ruby,
data/spec/spec_helper.rb CHANGED
@@ -75,7 +75,7 @@ module ExampleGroupHelpers
75
75
 
76
76
  def cleanup_temp_files(*except_files)
77
77
  after(:each) do
78
- FileUtils.rm_rf FileList[*(["log", ".bundle", "tmp/war"] - except_files)]
78
+ FileUtils.rm_rf FileList[*(["log", ".bundle", "tmp"] - except_files)]
79
79
  FileUtils.rm_f FileList[*(["*.war", "*.foobar", "**/config.ru", "*web.xml*", "config/web.xml*",
80
80
  "config/warble.rb", "file.txt", 'manifest', '*Gemfile*', 'MANIFEST.MF*', 'init.rb*',
81
81
  '**/*.class'] - except_files)]
@@ -94,7 +94,7 @@ module ExampleGroupHelpers
94
94
  ready, error = nil, nil
95
95
  300.times do # timeout 30 secs (300 * 0.1)
96
96
  begin
97
- break if ready = drbclient.ready?
97
+ break if ready = drbclient.ready?
98
98
  rescue DRb::DRbConnError => e
99
99
  error = e; sleep 0.1
100
100
  end
@@ -134,7 +134,7 @@ module ExampleGroupHelpers
134
134
  before :each do
135
135
  webserver = double('server').as_null_object
136
136
  webserver.stub(:main_class).and_return 'WarMain.class'
137
- webserver.stub(:add).and_return do |jar|
137
+ webserver.stub(:add) do |jar|
138
138
  jar.files['WEB-INF/webserver.jar'] = StringIO.new
139
139
  end
140
140
  Warbler::WEB_SERVERS['test'] = webserver
@@ -45,10 +45,10 @@ describe Warbler::Application do
45
45
  end
46
46
 
47
47
  it "should copy a fresh config file into place" do
48
- File.exists?("config/warble.rb").should_not be_true
48
+ File.exists?("config/warble.rb").should_not be true
49
49
  ARGV.unshift "config"
50
50
  silence { Warbler::Application.new.run }
51
- File.exists?("config/warble.rb").should be_true
51
+ File.exists?("config/warble.rb").should be true
52
52
  end
53
53
 
54
54
  it "should refuse to copy over an existing config file" do
@@ -71,13 +71,13 @@ describe Warbler::Application do
71
71
  mkdir_p "lib/tasks/warbler"
72
72
  ARGV.unshift "pluginize"
73
73
  silence { Warbler::Application.new.run }
74
- File.exist?("lib/tasks/warbler/warbler.rake").should_not be_true
74
+ File.exist?("lib/tasks/warbler/warbler.rake").should_not be true
75
75
  end
76
76
 
77
77
  it "should define a pluginize task for adding the tasks to a Rails application" do
78
78
  ARGV.unshift "pluginize"
79
79
  silence { Warbler::Application.new.run }
80
- File.exist?("lib/tasks/warbler/warbler.rake").should be_true
80
+ File.exist?("lib/tasks/warbler/warbler.rake").should be true
81
81
  end
82
82
 
83
83
  it "should provide a means to load the project Rakefile" do
@@ -6,6 +6,7 @@
6
6
  #++
7
7
 
8
8
  require File.expand_path('../../spec_helper', __FILE__)
9
+ require 'open3'
9
10
 
10
11
  describe Warbler::Jar, "with Bundler" do
11
12
  use_fresh_rake_application
@@ -79,8 +80,13 @@ describe Warbler::Jar, "with Bundler" do
79
80
  end
80
81
  jar.apply(config)
81
82
  jar.create('foo.war')
82
- `java -jar foo.war -S rake -T`
83
- $?.exitstatus.should == 0
83
+ if RUBY_VERSION >= '1.9'
84
+ stdin, stdout, stderr, wait_thr = Open3.popen3('java -jar foo.war -S rake -T')
85
+ wait_thr.value.success?.should be(true), stderr.readlines.join
86
+ else
87
+ `java -jar foo.war -S rake -T`
88
+ $?.exitstatus.should == 0
89
+ end
84
90
  end
85
91
  end
86
92
 
@@ -156,7 +162,7 @@ describe Warbler::Jar, "with Bundler" do
156
162
 
157
163
  it "includes the bundler gem" do
158
164
  jar.apply(config)
159
- config.gems.detect{|k,v| k.name == 'bundler'}.should_not be_nil
165
+ config.gems.detect{|k,v| k.name == 'bundler'}.should_not be nil
160
166
  file_list(/bundler-/).should_not be_empty
161
167
  end
162
168
 
@@ -23,7 +23,7 @@ describe Warbler::Config do
23
23
  config = Warbler::Config.new
24
24
  config.includes.should be_empty
25
25
  config.jar_name.size.should > 0
26
- config.override_gem_home.should be_true
26
+ config.override_gem_home.should be true
27
27
  end
28
28
  end
29
29
 
@@ -43,7 +43,7 @@ describe Warbler::Config do
43
43
  config.webxml.should be_kind_of(OpenStruct)
44
44
  config.pathmaps.should be_kind_of(OpenStruct)
45
45
  config.pathmaps.public_html.should == ["%{public/,}p"]
46
- config.override_gem_home.should be_true
46
+ config.override_gem_home.should be true
47
47
  end
48
48
 
49
49
  it "should allow configuration through an initializer block" do
@@ -176,6 +176,34 @@ describe Warbler::Jar do
176
176
  file_list(%r{^sample_jar/lib/sample_jar\.class$}).should be_empty
177
177
  jar.contents('sample_jar/lib/sample_jar.rb').should_not =~ /load __FILE__\.sub/
178
178
  end
179
+
180
+ it "compiles included gems when compile_gems is true" do
181
+ config.compile_gems = true
182
+ config.compiled_ruby_files = %w(lib/sample_jar.rb)
183
+ jar.compile(config)
184
+ jar.apply(config)
185
+ file_list(%r{sample_jar.*\.rb$}).size.should == 2
186
+ if RUBY_VERSION >= '1.9'
187
+ file_list(%r{gems.*\.class$}).size.should == 73
188
+ else
189
+ # 1.8.7 uses an older version of rubyzip and so the number of files compiled changes
190
+ file_list(%r{gems.*\.class$}).size.should == 32
191
+ end
192
+ end
193
+
194
+ it "does not compile included gems by default" do
195
+ config.compiled_ruby_files = %w(lib/sample_jar.rb)
196
+ jar.compile(config)
197
+ jar.apply(config)
198
+ file_list(%r{sample_jar.*\.rb$}).size.should == 2
199
+ if RUBY_VERSION >= '1.9'
200
+ file_list(%r{gems.*\.class$}).size.should == 0
201
+ else
202
+ # 1.8.7 uses an older version of rubyzip and so the number of files compiled changes
203
+ file_list(%r{gems.*\.class$}).size.should == 0
204
+ end
205
+ end
206
+
179
207
  end
180
208
 
181
209
  context "with a gemspec without a default executable" do
@@ -443,7 +471,7 @@ describe Warbler::Jar do
443
471
  mkdir_p "config"
444
472
  File.open("config/web.xml.erb", "w") {|f| f << "Hi <%= webxml.public.root %>" }
445
473
  jar.apply(config)
446
- jar.files["WEB-INF/web.xml"].should_not be_nil
474
+ jar.files["WEB-INF/web.xml"].should_not be nil
447
475
  jar.files["WEB-INF/web.xml"].read.should == "Hi /"
448
476
  end
449
477
 
@@ -594,6 +622,36 @@ describe Warbler::Jar do
594
622
  file_list(%r{WEB-INF/app/sample.jar}).should_not be_empty
595
623
  end
596
624
  end
625
+
626
+ context "with move_jars_to_webinf_lib set to regexp" do
627
+ before :each do
628
+ use_config do |config|
629
+ config.move_jars_to_webinf_lib = /sample/
630
+ end
631
+ end
632
+
633
+ before :each do
634
+ touch FileList["app/another.jar", "app/sample2.jar"]
635
+ end
636
+ after :each do
637
+ rm_f FileList["app/another.jar", "app/sample2.jar"]
638
+ end
639
+
640
+ it "moves jar files that match to WEB-INF/lib" do
641
+ jar.apply(config)
642
+ file_list(%r{WEB-INF/lib/app-sample.jar}).should_not be_empty
643
+ file_list(%r{WEB-INF/lib/app-sample2.jar}).should_not be_empty
644
+ file_list(%r{WEB-INF/lib/.*?another.jar}).should be_empty
645
+ end
646
+
647
+ it "removes default jars not matched by filter from WEB-INF/lib" do
648
+ jar.apply(config)
649
+ file_list(%r{WEB-INF/lib/jruby-rack.*\.jar}).should be_empty
650
+ file_list(%r{WEB-INF/lib/jruby-core.*\.jar}).should be_empty
651
+ end
652
+
653
+ end
654
+
597
655
  end
598
656
 
599
657
  context "with the executable feature" do
@@ -995,4 +1053,3 @@ describe Warbler::Jar do
995
1053
  end
996
1054
  end
997
1055
  end
998
-
@@ -70,7 +70,7 @@ describe Warbler::Jar, "with JBundler" do
70
70
  it "does not include the jbundler gem (as it is in the development group)" do
71
71
  pending( "needs JRuby to work" ) unless defined? JRUBY_VERSION
72
72
  jar.apply(config)
73
- config.gems.detect{|k,v| k.name == 'jbundler'}.should be_nil
73
+ config.gems.detect{|k,v| k.name == 'jbundler'}.should be nil
74
74
  file_list(/jbundler-/).should be_empty
75
75
  end
76
76
 
@@ -138,7 +138,7 @@ describe Warbler::Task do
138
138
  class_file_bytes = zf.get_input_stream('WEB-INF/lib/ruby_one_nine.class') {|io| io.read }
139
139
  java_class_header = class_file_bytes[0..3]
140
140
  bytecode_version = class_file_bytes[6..7]
141
-
141
+
142
142
  java_class_header.should == java_class_magic_number
143
143
  bytecode_version.should == java6_version_bytes
144
144
  end
@@ -147,13 +147,13 @@ describe Warbler::Task do
147
147
  it "should delete .class files after finishing the jar" do
148
148
  config.features << "compiled"
149
149
  silence { run_task "warble" }
150
- File.exist?('app/helpers/application_helper.class').should be_false
150
+ File.exist?('app/helpers/application_helper.class').should be false
151
151
  end
152
152
 
153
153
  context "where symlinks are available" do
154
154
  begin
155
155
  FileUtils.ln_s "README.txt", "r.txt.symlink", :verbose => false
156
-
156
+
157
157
  it "should process symlinks by storing a file in the archive that has the same contents as the source" do
158
158
  File.open("config/special.txt", "wb") {|f| f << "special"}
159
159
  Dir.chdir("config") { FileUtils.ln_s "special.txt", "link.txt" }
@@ -169,9 +169,9 @@ describe Warbler::Task do
169
169
  Dir.chdir("lib") { FileUtils.ln_s "tasks", "rakelib" }
170
170
  silence { run_task "warble" }
171
171
  Warbler::ZipSupport.open("#{config.jar_name}.war") do |zf|
172
- zf.find_entry("WEB-INF/lib/tasks/utils.rake").should_not be_nil
173
- zf.find_entry("WEB-INF/lib/rakelib/").should_not be_nil
174
- zf.find_entry("WEB-INF/lib/rakelib/utils.rake").should_not be_nil if defined?(JRUBY_VERSION)
172
+ zf.find_entry("WEB-INF/lib/tasks/utils.rake").should_not be nil
173
+ zf.find_entry("WEB-INF/lib/rakelib/").should_not be nil
174
+ zf.find_entry("WEB-INF/lib/rakelib/utils.rake").should_not be nil if defined?(JRUBY_VERSION)
175
175
  end
176
176
  end
177
177
 
@@ -181,7 +181,7 @@ describe Warbler::Task do
181
181
  end
182
182
 
183
183
  context "with a Bundler Gemfile" do
184
-
184
+
185
185
  run_out_of_process_with_drb if DRB = true
186
186
 
187
187
  after do
@@ -194,18 +194,18 @@ describe Warbler::Task do
194
194
 
195
195
  it "includes gems from the Gemfile" do
196
196
  File.open("Gemfile", "w") {|f| f << "gem 'rspec'"}
197
-
197
+
198
198
  if DRB
199
199
  drbclient.run_task "warble"
200
200
  config = drbclient.config
201
201
  else
202
- silence { run_task "warble" }
202
+ silence { run_task "warble" }
203
203
  end
204
-
204
+
205
205
  Warbler::ZipSupport.open("#{config.jar_name}.war") do |zf|
206
206
  rspec = config.gems.keys.detect { |spec| spec.name == 'rspec' }
207
- rspec.should_not be_nil, "expected rspec gem among: #{config.gems.keys.join(' ')}"
208
- zf.find_entry("WEB-INF/gems/specifications/rspec-#{rspec.version}.gemspec").should_not be_nil
207
+ rspec.should_not be(nil), "expected rspec gem among: #{config.gems.keys.join(' ')}"
208
+ zf.find_entry("WEB-INF/gems/specifications/rspec-#{rspec.version}.gemspec").should_not be nil
209
209
  end
210
210
  end
211
211
  end
data/warble.rb CHANGED
@@ -88,7 +88,11 @@ Warbler::Config.new do |config|
88
88
  # files will be compiled. Default is to compile all \.rb files in
89
89
  # the application.
90
90
  # config.compiled_ruby_files = FileList['app/**/*.rb']
91
-
91
+
92
+ # Determines if ruby files in supporting gems will be compiled.
93
+ # Ignored unless compile feature is used.
94
+ # config.compile_gems = false
95
+
92
96
  # When set it specify the bytecode version for compiled class files
93
97
  # config.bytecode_version = "1.6"
94
98
 
@@ -97,15 +101,18 @@ Warbler::Config.new do |config|
97
101
  # GEM_HOME if it is set.
98
102
  # config.override_gem_home = true
99
103
 
100
- # Allows for specifing custom executables
104
+ # Allows for specifing custom executables
101
105
  # config.executable = ["rake", "bin/rake"]
102
-
106
+
103
107
  # Sets default (prefixed) parameters for the executables
104
108
  # config.executable_params = "do:something"
105
109
 
106
110
  # If set to true, moves jar files into WEB-INF/lib. Prior to version 1.4.2 of Warbler this was done
107
111
  # by default. But since 1.4.2 this config defaults to false. It may need to be set to true for
108
112
  # web servers that do not explode the WAR file.
113
+ # Alternatively, this option can be set to a regular expression, which will
114
+ # act as a jar selector -- only jar files that match the pattern will be
115
+ # included in the archive.
109
116
  # config.move_jars_to_webinf_lib = false
110
117
 
111
118
  # === War files only below here ===
data/warbler.gemspec CHANGED
@@ -6,15 +6,14 @@ Gem::Specification.new do |gem|
6
6
  gem.name = "warbler"
7
7
  gem.version = Warbler::VERSION
8
8
  gem.platform = Gem::Platform::RUBY
9
- gem.homepage = "http://caldersphere.rubyforge.org/warbler"
9
+ gem.homepage = "https://github.com/jruby/warbler"
10
10
  gem.license = 'MIT'
11
11
  gem.authors = ["Nick Sieger"]
12
12
  gem.email = "nick@nicksieger.com"
13
13
  gem.summary = "Warbler chirpily constructs .war files of your Rails applications."
14
14
  gem.description = %q{Warbler is a gem to make a Java jar or war file out of any Ruby,
15
- Rails, Merb, or Rack application. Warbler provides a minimal,
16
- flexible, Ruby-like way to bundle up all of your application files for
17
- deployment to a Java environment.}
15
+ Rails, or Rack application. Warbler provides a minimal, flexible, Ruby-like way to
16
+ bundle up all of your application files for deployment to a Java environment.}
18
17
 
19
18
  gem.files = `git ls-files`.split("\n")
20
19
  gem.test_files = `git ls-files -- {test,spec,features,integration}/*`.split("\n")
@@ -22,13 +21,12 @@ deployment to a Java environment.}
22
21
  gem.require_paths = ["lib"]
23
22
 
24
23
  gem.rdoc_options = ["--main", "README.rdoc", "-H", "-f", "darkfish"]
25
- gem.rubyforge_project = "caldersphere"
26
24
 
27
25
  gem.add_runtime_dependency 'rake', [">= 0.9.6"]
28
26
  # restrict it for maven not to find jruby-9000.dev
29
27
  gem.add_runtime_dependency 'jruby-jars', [">= 1.5.6", '< 2.0']
30
28
  gem.add_runtime_dependency 'jruby-rack', [">= 1.0.0"]
31
- gem.add_runtime_dependency 'rubyzip', [">= 0.9", "< 1.1"]
29
+ gem.add_runtime_dependency 'rubyzip', [">= 0.9", "< 1.2"]
32
30
  gem.add_development_dependency 'jbundler', "~> 0.5.5"
33
31
  gem.add_development_dependency 'ruby-maven', '~> 3.1.1.0'
34
32
  gem.add_development_dependency 'rspec', "~> 2.10"
data/web.xml.erb CHANGED
@@ -2,6 +2,8 @@
2
2
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
3
3
  "http://java.sun.com/dtd/web-app_2_3.dtd">
4
4
  <web-app>
5
+ <!-- <display-name>Uncomment and put name :here: for Tomcat Dashboard</display-name> -->
6
+
5
7
  <% webxml.context_params.each do |k,v| %>
6
8
  <context-param>
7
9
  <param-name><%= k %></param-name>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-24 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '0.9'
68
68
  - - <
69
69
  - !ruby/object:Gem::Version
70
- version: '1.1'
70
+ version: '1.2'
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '>='
@@ -75,7 +75,7 @@ dependencies:
75
75
  version: '0.9'
76
76
  - - <
77
77
  - !ruby/object:Gem::Version
78
- version: '1.1'
78
+ version: '1.2'
79
79
  prerelease: false
80
80
  type: :runtime
81
81
  - !ruby/object:Gem::Dependency
@@ -136,9 +136,8 @@ dependencies:
136
136
  type: :development
137
137
  description: |-
138
138
  Warbler is a gem to make a Java jar or war file out of any Ruby,
139
- Rails, Merb, or Rack application. Warbler provides a minimal,
140
- flexible, Ruby-like way to bundle up all of your application files for
141
- deployment to a Java environment.
139
+ Rails, or Rack application. Warbler provides a minimal, flexible, Ruby-like way to
140
+ bundle up all of your application files for deployment to a Java environment.
142
141
  email: nick@nicksieger.com
143
142
  executables:
144
143
  - warble
@@ -362,7 +361,7 @@ files:
362
361
  - warble.rb
363
362
  - warbler.gemspec
364
363
  - web.xml.erb
365
- homepage: http://caldersphere.rubyforge.org/warbler
364
+ homepage: https://github.com/jruby/warbler
366
365
  licenses:
367
366
  - MIT
368
367
  metadata: {}
@@ -386,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
385
  - !ruby/object:Gem::Version
387
386
  version: '0'
388
387
  requirements: []
389
- rubyforge_project: caldersphere
388
+ rubyforge_project:
390
389
  rubygems_version: 2.2.2
391
390
  signing_key:
392
391
  specification_version: 4