Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:jruby/warbler

  • Loading branch information...
commit 0d7af94a6504755e76810a125aaf8a9d31b27d56 2 parents e9740b5 + e5e41e8
@nicksieger nicksieger authored
View
1  .gitignore
@@ -4,3 +4,4 @@ doc
.bundle
nbproject
target
+Gemfile.lock
View
29 .travis.yml
@@ -1,12 +1,25 @@
rvm:
- - 1.8.7
- - 1.9.2
- - jruby-18mode
- # NOTE: seems to be failing on Travis the same way as jruby-rack did, stack
- # seems to overflow when gems are loaded (does not happen locally :() :
- # SystemStackError: stack level too deep
- # ./spec/../lib/warbler/traits/bundler.rb:30:in `after_configure'
- #- jruby-19mode
+ - jruby
+ - jruby-head
branches:
only:
- master
+env:
+ - JRUBY_OPTS="--1.8 --server -Xcext.enabled=false -Xcompile.invokedynamic=false"
+ - JRUBY_OPTS="--1.9 --server -Xcext.enabled=false -Xcompile.invokedynamic=false"
+matrix:
+ include:
+ - rvm: 1.8.7
+ env: ''
+ - rvm: 1.9.2
+ env: ''
+ - rvm: 1.9.3
+ env: ''
+notifications:
+ irc:
+ channels:
+ - "irc.freenode.org#jruby"
+ on_success: change
+ on_failure: always
+ template:
+ - "%{repository} (%{branch}:%{commit} by %{author}): %{message} (%{build_url})"
View
6 Gemfile
@@ -7,9 +7,9 @@ gem "jruby-rack"
group :development do
gem "jruby-openssl", :platform => :jruby
- gem "rspec"
+ gem "rspec", ">= 2.8.0"
gem "diff-lcs"
- gem "rcov", ">= 0.9.8"
- gem "rdoc"
+ gem "rcov", ">= 0.9.8", :platform => :mri_18
+ gem "rdoc", ">= 2.4.2"
gem "childprocess", :platform => :mri
end
View
41 Gemfile.lock
@@ -1,41 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- bouncy-castle-java (1.5.0146.1)
- childprocess (0.2.2)
- ffi (~> 1.0.6)
- diff-lcs (1.1.2)
- ffi (1.0.11)
- jruby-jars (1.6.7)
- jruby-openssl (0.7.6.1)
- bouncy-castle-java (>= 1.5.0146.1)
- jruby-rack (1.1.4)
- rake (0.9.2.2)
- rcov (0.9.10)
- rcov (0.9.10-java)
- rdoc (3.9.2)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
- rubyzip (0.9.6.1)
-
-PLATFORMS
- java
- ruby
-
-DEPENDENCIES
- childprocess
- diff-lcs
- jruby-jars
- jruby-openssl
- jruby-rack
- rake
- rcov (>= 0.9.8)
- rdoc
- rspec
- rubyzip
View
2  LICENSE.txt
@@ -2,7 +2,7 @@
Warbler is provided under the terms of the MIT license.
-Warbler (c) 2010-2012 Engine Yard, Inc.
+Warbler (c) 2010-2013 Engine Yard, Inc.
Warbler (c) 2007-2009 Sun Microsystems, Inc.
Permission is hereby granted, free of charge, to any person
View
8 README.rdoc
@@ -1,4 +1,4 @@
-= Warbler
+= Warbler {<img src="https://travis-ci.org/jruby/warbler.png" />}[https://travis-ci.org/jruby/warbler]
Warbler is a gem to make a Java jar or war file out of any Ruby,
Rails, Merb, or Rack application. Warbler provides a minimal,
@@ -124,8 +124,8 @@ in the project will be included in the archive.
Applications that use Bundler[http://gembundler.com/], detected via
presence of a +Gemfile+, will have the gems packaged up into the
archive along with the Gemfile. The Bundler groups named
-+:development+ and +:test+ will be excluded by default, unless you
-specify with +config.bundle_without+ in +config/warble.rb+.
++:development+ +:test+ and +:assets+ will be excluded by default, unless
+you specify with +config.bundle_without+ in +config/warble.rb+.
Warbler supports Bundler for gems and git repositories, but not for
plain path components. Warbler will warn when a +:path+ component is
@@ -263,5 +263,5 @@ After that, simply run "rake".
Warbler is provided under the terms of the MIT license.
-Warbler (c) 2010-2012 Engine Yard, Inc.
+Warbler (c) 2010-2013 Engine Yard, Inc.
Warbler (c) 2007-2009 Sun Microsystems, Inc.
View
14 ext/JarMain.java
@@ -9,6 +9,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
+import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
@@ -57,7 +58,7 @@ public JarMain(String[] args) throws Exception {
}
private URL extractJar(String jarpath) throws Exception {
- InputStream jarStream = new URL("jar:" + path.replace(MAIN, jarpath)).openStream();
+ InputStream jarStream = new URI("jar", path.replace(MAIN, jarpath), null).toURL().openStream();
String jarname = jarpath.substring(jarpath.lastIndexOf("/") + 1, jarpath.lastIndexOf("."));
File jarFile = new File(extractRoot, jarname + ".jar");
jarFile.deleteOnExit();
@@ -128,7 +129,7 @@ public void run() {
public static void main(String[] args) {
try {
int exit = new JarMain(args).start();
- System.exit(exit);
+ if(isSystemExitEnabled()) System.exit(exit);
} catch (Exception e) {
Throwable t = e;
while (t.getCause() != null && t.getCause() != t) {
@@ -145,4 +146,13 @@ public static void main(String[] args) {
private static boolean isDebug() {
return System.getProperty("warbler.debug") != null;
}
+
+ /**
+ * if warbler.skip_system_exit system property is defined, we will not
+ * call System.exit in the normal flow. System.exit can cause problems
+ * for wrappers like procrun
+ */
+ private static boolean isSystemExitEnabled(){
+ return System.getProperty("warbler.skip_system_exit") == null; //omission enables System.exit use
+ }
}
View
3  ext/WarMain.java
@@ -5,6 +5,7 @@
* See the file LICENSE.txt for details.
*/
+import java.net.URI;
import java.net.URLClassLoader;
import java.net.URL;
import java.lang.reflect.Method;
@@ -77,7 +78,7 @@ public WarMain(String[] args) throws Exception {
}
private URL extractWebserver() throws Exception {
- InputStream jarStream = new URL("jar:" + path.replace(MAIN, WEBSERVER_JAR)).openStream();
+ InputStream jarStream = new URI("jar", path.replace(MAIN, WEBSERVER_JAR), null).toURL().openStream();
File jarFile = File.createTempFile("webserver", ".jar");
jarFile.deleteOnExit();
FileOutputStream outStream = new FileOutputStream(jarFile);
View
12 ext/WarblerJar.java
@@ -168,11 +168,21 @@ private static InputStream getStream(String jar, String entry) throws IOExceptio
return entryInJar(stream, entry);
}
+ private static String trimTrailingSlashes(String path) {
+ if (path.endsWith("/")) {
+ return path.substring(0, path.length() - 1);
+ } else {
+ return path;
+ }
+ }
+
private static InputStream entryInJar(InputStream jar, String entry) throws IOException {
+ entry = trimTrailingSlashes(entry);
+
ZipInputStream jstream = new ZipInputStream(jar);
ZipEntry zentry = null;
while ((zentry = jstream.getNextEntry()) != null) {
- if (zentry.getName().equals(entry)) {
+ if (trimTrailingSlashes(zentry.getName()).equals(entry)) {
return jstream;
}
jstream.closeEntry();
View
2  lib/warbler/config.rb
@@ -96,7 +96,7 @@ class Config
attr_accessor :bundler
# An array of Bundler groups to avoid including in the war file.
- # Defaults to ["development", "test"].
+ # Defaults to ["development", "test", "assets"].
attr_accessor :bundle_without
# Path to the pre-bundled gem directory inside the war file. Default is '/WEB-INF/gems'.
View
10 lib/warbler/jar.rb
@@ -44,8 +44,13 @@ def compile(config)
end
def run_javac(config, compiled_ruby_files)
+ if config.webxml && config.webxml.context_params.has_key?('jruby.compat.version')
+ compat_version = "--#{config.webxml.jruby.compat.version}"
+ else
+ compat_version = ''
+ end
# Need to use the version of JRuby in the application to compile it
- %x{java -classpath #{config.java_libs.join(File::PATH_SEPARATOR)} org.jruby.Main -S jrubyc \"#{compiled_ruby_files.join('" "')}\"}
+ %x{java -classpath #{config.java_libs.join(File::PATH_SEPARATOR)} org.jruby.Main #{compat_version} -S jrubyc \"#{compiled_ruby_files.join('" "')}\"}
end
def replace_compiled_ruby_files(config, compiled_ruby_files)
@@ -81,6 +86,9 @@ def create(config_or_path)
rm_f path
ensure_directory_entries
puts "Creating #{path}"
+ if Warbler::Config === config_or_path
+ @files.delete("#{config_or_path.jar_name}/#{path}")
+ end
create_jar path, @files
end
View
12 lib/warbler/task.rb
@@ -162,13 +162,13 @@ def define_config_task
def define_pluginize_task
task "pluginize" do
- if !Dir["vendor/plugins/warbler*"].empty? && ENV["FORCE"].nil?
- puts "I found an old nest in vendor/plugins; please trash it so I can make a new one"
- puts "(directory vendor/plugins/warbler* exists)"
+ if !Dir["lib/tasks/warbler*"].empty? && ENV["FORCE"].nil?
+ puts "I found an old nest in lib/tasks; please trash it so I can make a new one"
+ puts "(directory lib/tasks/warbler* exists)"
else
- rm_rf FileList["vendor/plugins/warbler*"], :verbose => false
- mkdir_p "vendor/plugins/warbler/tasks"
- File.open("vendor/plugins/warbler/tasks/warbler.rake", "w") do |f|
+ rm_rf FileList["lib/tasks/warbler*"], :verbose => false
+ mkdir_p "lib/tasks/warbler"
+ File.open("lib/tasks/warbler/warbler.rake", "w") do |f|
f.puts "require 'warbler'"
f.puts "Warbler::Task.new"
end
View
2  lib/warbler/traits/bundler.rb
@@ -23,7 +23,7 @@ def self.requires?(trait)
def before_configure
config.bundler = true
- config.bundle_without = ["development", "test"]
+ config.bundle_without = ["development", "test", "assets"]
end
def after_configure
View
2  lib/warbler/traits/gemspec.rb
@@ -49,7 +49,7 @@ def default_executable
if !@spec.executables.empty?
"bin/#{@spec.executables.first}"
else
- exe = Dir['bin/*'].first
+ exe = Dir['bin/*'].sort.first
raise "No executable script found" unless exe
warn "No default executable found in #{@spec_file}, using #{exe}"
exe
View
9 lib/warbler/traits/nogemspec.rb
@@ -33,8 +33,13 @@ def update_archive(jar)
end
def default_executable
- exes = Dir['bin/*']
- exe = exes.grep(/#{config.jar_name}/).first || exes.first
+ exes = Dir['bin/*'].sort
+ unless(exe = exes.grep(/#{config.jar_name}/).first)
+ exe = exes.first
+ if exe
+ warn "No executable matching config.jar_name found, using #{exe}"
+ end
+ end
raise "No executable script found" unless exe
exe
end
View
2  lib/warbler/version.rb
@@ -6,5 +6,5 @@
#++
module Warbler
- VERSION = "1.3.6"
+ VERSION = "1.3.7.dev"
end
View
2  spec/sample_war/Rakefile
@@ -6,6 +6,6 @@
require 'rake'
require 'rake/testtask'
-require 'rake/rdoctask'
+require 'rdoc/task'
#require 'tasks/rails'
View
8 spec/sample_war/lib/ruby_one_nine.rb
@@ -0,0 +1,8 @@
+class RubyOneNine
+
+ RUBY_ONE_NINE_HASH = {
+ test: 'some ruby 1.9 syntax',
+ another: -> { puts 'foo' },
+ }
+
+end
View
2  spec/spec_helper.rb
@@ -15,7 +15,7 @@
Warbler specs are destructive to application directories.} if File.directory?("app")
require 'rbconfig'
-RUBY_EXE = File.join Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']
+RUBY_EXE = File.join RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']
require 'fileutils'
require 'stringio'
View
10 spec/warbler/application_spec.rb
@@ -26,7 +26,7 @@
Warbler.application = nil
Warbler.framework_detection = @detection
@argv.reverse.each {|a| ARGV.unshift a}
- rm_rf FileList['vendor/plugins/warbler']
+ rm_rf FileList['lib/tasks/warbler']
end
it "should be able to list its tasks" do
@@ -67,17 +67,17 @@
end
end
- it "should refuse to pluginize if the vendor/plugins/warbler directory exists" do
- mkdir_p "vendor/plugins/warbler"
+ it "should refuse to pluginize if the lib/tasks/warbler directory exists" do
+ mkdir_p "lib/tasks/warbler"
ARGV.unshift "pluginize"
silence { Warbler::Application.new.run }
- File.exist?("vendor/plugins/warbler/tasks/warbler.rake").should_not be_true
+ File.exist?("lib/tasks/warbler/warbler.rake").should_not be_true
end
it "should define a pluginize task for adding the tasks to a Rails application" do
ARGV.unshift "pluginize"
silence { Warbler::Application.new.run }
- File.exist?("vendor/plugins/warbler/tasks/warbler.rake").should be_true
+ File.exist?("lib/tasks/warbler/warbler.rake").should be_true
end
it "should provide a means to load the project Rakefile" do
View
2  spec/warbler/bundler_spec.rb
@@ -96,7 +96,7 @@ def use_config(&block)
jar.add_init_file(config)
contents = jar.contents('META-INF/init.rb')
contents.should =~ /ENV\['BUNDLE_WITHOUT'\]/
- contents.should =~ /'development:test'/
+ contents.should =~ /'development:test:assets'/
end
it "adds BUNDLE_GEMFILE to init.rb" do
View
16 spec/warbler/task_spec.rb
@@ -109,6 +109,22 @@ def run_task(t)
end
end
+ it "should compile ruby 1.9 mode" do
+ config.features << "compiled"
+ config.webxml.jruby.compat.version = '1.9'
+ silence { run_task "warble" }
+
+ java_class_magic_number = [0xCA,0xFE,0xBA,0xBE].map { |magic_char| magic_char.chr }.join
+
+ Zip::ZipFile.open("#{config.jar_name}.war") do |zf|
+ java_class_header = zf.get_input_stream('WEB-INF/lib/ruby_one_nine.class') {|io| io.read }[0..3]
+ ruby_class_definition = zf.get_input_stream('WEB-INF/lib/ruby_one_nine.rb') {|io| io.read }
+
+ java_class_header.should == java_class_magic_number
+ ruby_class_definition.should == %{require __FILE__.sub(/.rb$/, '.class')}
+ end
+ end
+
it "should delete .class files after finishing the jar" do
config.features << "compiled"
silence { run_task "warble" }
View
2  warble.rb
@@ -41,7 +41,7 @@
# config.bundler = false
# An array of Bundler groups to avoid including in the war file.
- # Defaults to ["development", "test"].
+ # Defaults to ["development", "test", "assets"].
# config.bundle_without = []
# Other gems to be included. If you don't use Bundler or a gemspec
Please sign in to comment.
Something went wrong with that request. Please try again.