diff --git a/Rakefile b/Rakefile index 72080725..a8554ff2 100644 --- a/Rakefile +++ b/Rakefile @@ -17,7 +17,22 @@ if Gem.win_platform? end require 'rake/testtask' -require 'rake/extensiontask' +if /java/ === RUBY_PLATFORM + # require 'rake/javaextensiontask' + # Rake::JavaExtensionTask.new(:hamlit) do |ext| + # ext.ext_dir = 'ext/java' + # ext.lib_dir = 'lib/hamlit' + # end + + task :compile do + # dummy for now + end +else + require 'rake/extensiontask' + Rake::ExtensionTask.new(:hamlit) do |ext| + ext.lib_dir = 'lib/hamlit' + end +end Dir['benchmark/*.rake'].each { |b| import(b) } @@ -88,10 +103,6 @@ namespace :test do end end -Rake::ExtensionTask.new(:hamlit) do |ext| - ext.lib_dir = 'lib/hamlit' -end - desc 'bench task for CI' task bench: :compile do if ENV['SLIM_BENCH'] == '1' diff --git a/hamlit.gemspec b/hamlit.gemspec index 62bcaa34..1c72a7c1 100644 --- a/hamlit.gemspec +++ b/hamlit.gemspec @@ -17,9 +17,14 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sample)/}) } spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.extensions = ['ext/hamlit/extconf.rb'] spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.1.0' + + if /java/ === RUBY_PLATFORM + # spec.platform = 'java' + else + spec.extensions = ['ext/hamlit/extconf.rb'] + spec.required_ruby_version = '>= 2.1.0' + end spec.add_dependency 'temple', '>= 0.8.0' spec.add_dependency 'thor' diff --git a/lib/hamlit/attribute_builder.rb b/lib/hamlit/attribute_builder.rb index 68764f4d..b5f42f65 100644 --- a/lib/hamlit/attribute_builder.rb +++ b/lib/hamlit/attribute_builder.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true -require 'hamlit/hamlit' -require 'hamlit/object_ref' +unless /java/ === RUBY_PLATFORM # exclude JRuby + require 'hamlit/hamlit' +end require 'hamlit/utils' +require 'hamlit/object_ref' module Hamlit::AttributeBuilder BOOLEAN_ATTRIBUTES = %w[disabled readonly multiple checked autobuffer diff --git a/lib/hamlit/utils.rb b/lib/hamlit/utils.rb index 6097c690..16dabc48 100644 --- a/lib/hamlit/utils.rb +++ b/lib/hamlit/utils.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true -require 'hamlit/hamlit' +unless /java/ === RUBY_PLATFORM # exclude JRuby + require 'hamlit/hamlit' # depends on C-ext defines Hamlit::Utils first for now +end module Hamlit module Utils