Skip to content

Commit 5aaea6d

Browse files
authored
Move JRuby's ext and loader script (#39)
The strscan.rb file is only needed by JRuby, which does not have an extension file format that loads itself. As noted in #35 having this file present on TruffleRuby prevents their built-in strscan.rb from loading, so the file was moved to lib/jruby/strscan.rb with lib/jruby added as a require path. However this results in both lib/strscan.rb and lib/jruby/strscan.rb getting copied into JRuby's stdlib when the default gem is installed, leading to the confusing situation in #38. This PR moves the jruby-specific strscan.rb under the jruby extension, renaming that directory to be explicitly for JRuby, and adding that new ext/jruby/lib path to the require paths so there's no nesting of require paths to copy files multiple times. * ext/java => ext/jruby * lib/jruby/strscan.rb => ext/jruby/lib/strscan.rb * Changes to Rakefile and gemspec for new locations Fixes #38
1 parent 2efdb8e commit 5aaea6d

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if RUBY_ENGINE == "jruby"
2121
require 'maven/ruby/maven'
2222
ext.source_version = '1.8'
2323
ext.target_version = '1.8'
24-
ext.ext_dir = 'ext/java'
24+
ext.ext_dir = 'ext/jruby'
2525
end
2626
elsif RUBY_ENGINE == "ruby"
2727
require 'rake/extensiontask'
@@ -32,8 +32,8 @@ end
3232

3333
desc "Run test"
3434
task :test do
35-
require_path = RUBY_ENGINE == 'jruby' ? "lib/jruby" : "lib"
36-
ENV["RUBYOPT"] = "-I#{require_path} -rbundler/setup"
35+
extra_require_path = RUBY_ENGINE == 'jruby' ? "ext/jruby/lib" : "lib"
36+
ENV["RUBYOPT"] = "-I#{extra_require_path} -rbundler/setup"
3737
ruby("run-test.rb")
3838
end
3939

ext/java/org/jruby/ext/strscan/RubyStringScanner.java renamed to ext/jruby/org/jruby/ext/strscan/RubyStringScanner.java

File renamed without changes.

ext/java/org/jruby/ext/strscan/StringScannerLibrary.java renamed to ext/jruby/org/jruby/ext/strscan/StringScannerLibrary.java

File renamed without changes.

strscan.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
1717
s.description = "Provides lexical scanning operations on a String."
1818

1919
if RUBY_ENGINE == 'jruby'
20-
s.require_paths = %w{lib/jruby lib}
21-
s.files = %w{lib/strscan.jar lib/jruby/strscan.rb}
20+
s.require_paths = %w{ext/jruby/lib lib}
21+
s.files = %w{lib/strscan.jar ext/jruby/lib/strscan.rb}
2222
s.platform = "java"
2323
else
2424
s.require_paths = %w{lib}

0 commit comments

Comments
 (0)