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 5a73481
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ references:
bundle_install: &bundle_install
run:
name: Install Bundler dependencies
command: bundle install --path ~/airbrake-ruby/vendor/bundle --jobs 15
command: |
bundle install --path ~/airbrake-ruby/vendor/bundle --jobs 15
bundle exec rake gems
gem install pkg/*.gem
rm -rf pkg/
unit: &unit
run:
name: Run unit tests
Expand All @@ -28,7 +32,7 @@ jobs:
- <<: *bundle_install
- run:
name: Run RuboCop linting
command: bundle exec rubocop --parallel
command: bundle exec rubocop --parallel --config=.rubocop.yml
"ruby-2.1":
docker:
- image: circleci/ruby:2.1
Expand Down
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
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
Exclude:
- 'pkg/**/*.rb'

Metrics/MethodLength:
Max: 25
Expand Down
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 5a73481

Please sign in to comment.