Skip to content

Commit

Permalink
Build this gem on JRuby properly
Browse files Browse the repository at this point in the history
The current approach doesn't work with JRuby. The patch that aimed to fix the
issue didn't actually work (duh):
#408

The problem is that I run `gem build *.gemspec` using CRuby, so the JRuby check
inside the gemspec always has the same outcome. This change builds gems
properly, with `rake gems`.
  • Loading branch information
kyrylo committed Feb 11, 2019
1 parent f6da2cc commit 7702650
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Gemfile.lock
.bundle
doc
.yardoc
pkg
44 changes: 43 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
require 'rake/clean'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
require 'rubygems/package_task'

RSpec::Core::RakeTask.new(:spec)
task default: :spec

# rubocop:disable Security/Eval
def modify_base_gemspec
eval(File.read('airbrake-ruby.gemspec')).tap { |s| yield s }
end
# rubocop:enable Security/Eval

namespace :ruby do
spec = modify_base_gemspec do |s|
s.platform = Gem::Platform::RUBY
s.add_dependency('rbtree3', '~> 0.5')
end

Gem::PackageTask.new(spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
end
end

namespace :jruby do
spec = modify_base_gemspec do |s|
s.add_dependency('rbtree-jruby', '~> 0.2')
s.platform = 'java'
end

Gem::PackageTask.new(spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
end
end

desc 'Build all platform gems at once'
task gems: %w[clean ruby:gem jruby:gem]

desc 'Build and push platform gems'
task pushgems: :gems do
chdir("#{File.dirname(__FILE__)}/pkg") do
Dir['*.gem'].each { |gem| sh "gem push #{gem}" }
end
end
9 changes: 0 additions & 9 deletions airbrake-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require './lib/airbrake-ruby/version'

java = RUBY_PLATFORM =~ /java/

Gem::Specification.new do |s|
s.name = 'airbrake-ruby'
s.version = Airbrake::AIRBRAKE_RUBY_VERSION.dup
Expand All @@ -27,13 +25,6 @@ DESC
s.test_files = Dir.glob('spec/**/*')

s.required_ruby_version = '>= 2.1'
s.platform = java ? 'java' : Gem::Platform::RUBY

if java
s.add_dependency 'rbtree-jruby', '~> 0.2.1'
else
s.add_dependency 'rbtree3', '~> 0.5.0'
end

s.add_development_dependency 'rspec', '~> 3'
s.add_development_dependency 'rake', '~> 10'
Expand Down

0 comments on commit 7702650

Please sign in to comment.