Manually bootstrap JRuby after all.
After discussing this with @headius I've decided to do this the manual way anyway. Apparently the basic load service stuff is deprecated and not very reliable.
This commit is contained in:
parent
90fabe3f21
commit
fe74d60138
|
@ -0,0 +1,14 @@
|
|||
package org.liboga;
|
||||
|
||||
import org.jruby.Ruby;
|
||||
|
||||
public class Liboga
|
||||
{
|
||||
/**
|
||||
* Bootstraps the JRuby extension.
|
||||
*/
|
||||
public static void load(final Ruby runtime)
|
||||
{
|
||||
org.liboga.xml.Lexer.load(runtime);
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jruby.Ruby;
|
||||
import org.jruby.RubyModule;
|
||||
import org.jruby.RubyClass;
|
||||
import org.jruby.runtime.load.BasicLibraryService;
|
||||
import org.jruby.runtime.load.Library;
|
||||
|
||||
public class LibogaService implements BasicLibraryService
|
||||
{
|
||||
/**
|
||||
* Bootstraps the JRuby extension.
|
||||
*
|
||||
* In order to load this extension properly you have to make sure that the
|
||||
* lib/ directory is in the Ruby load path. If this is the case you can
|
||||
* load it as following:
|
||||
*
|
||||
* require 'liboga'
|
||||
*
|
||||
* Using absolute paths (e.g. with `require_relative`) requires you to
|
||||
* manually call this method:
|
||||
*
|
||||
* LibogaService.new.basicLoad(JRuby.runtime)
|
||||
*/
|
||||
public boolean basicLoad(final Ruby runtime) throws IOException
|
||||
{
|
||||
org.liboga.xml.Lexer.load(runtime);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
11
lib/oga.rb
11
lib/oga.rb
|
@ -6,14 +6,11 @@ require_relative 'oga/xml/lexer'
|
|||
require_relative 'oga/xml/parser'
|
||||
require_relative 'oga/xml/pull_parser'
|
||||
|
||||
# JRuby is dumb as a brick and can only load .jar files using require() when
|
||||
# ./lib is in the LOAD_PATH. require_relative, or any other form that uses
|
||||
# absolute paths, does not work.
|
||||
unless $:.include?(File.expand_path('../', __FILE__))
|
||||
$:.unshift(File.expand_path('../', __FILE__))
|
||||
end
|
||||
require_relative 'liboga'
|
||||
|
||||
require 'liboga'
|
||||
if RUBY_PLATFORM == 'java'
|
||||
org.liboga.Liboga.load(JRuby.runtime)
|
||||
end
|
||||
|
||||
require_relative 'oga/xml/node'
|
||||
require_relative 'oga/xml/element'
|
||||
|
|
Loading…
Reference in New Issue