|
1 | 1 | require 'bundler/gem_tasks'
|
| 2 | +require 'English' |
2 | 3 |
|
3 | 4 | require "#{File.expand_path(File.dirname(__FILE__))}/lib/git/version"
|
4 | 5 |
|
@@ -41,4 +42,41 @@ unless RUBY_PLATFORM == 'java'
|
41 | 42 | # default_tasks << :yardstick
|
42 | 43 | end
|
43 | 44 |
|
| 45 | +if RUBY_PLATFORM == 'java' && Gem.win_platform? |
| 46 | + # Reimplement the :build and :install task for JRuby on Windows |
| 47 | + # There is a bug in JRuby on Windows that makes the `build` task from `bundler/gem_tasks` fail. |
| 48 | + # Once https://github.com/jruby/jruby/issues/6516 is fixed, this block can be deleted. |
| 49 | + version = Git::VERSION |
| 50 | + pkg_name = 'git' |
| 51 | + gem_file = "pkg/#{pkg_name}-#{version}.gem" |
| 52 | + |
| 53 | + Rake::Task[:build].clear |
| 54 | + task :build do |
| 55 | + FileUtils.mkdir 'pkg' unless File.exist? 'pkg' |
| 56 | + `gem build #{pkg_name}.gemspec --output "#{gem_file}" --quiet` |
| 57 | + raise 'Gem build failed' unless $CHILD_STATUS.success? |
| 58 | + puts "#{pkg_name} #{version} built to #{gem_file}." |
| 59 | + end |
| 60 | + |
| 61 | + Rake::Task[:install].clear |
| 62 | + task :install => :build do |
| 63 | + `gem install #{gem_file} --quiet` |
| 64 | + raise 'Gem install failed' unless $CHILD_STATUS.success? |
| 65 | + puts "#{pkg_name} (#{version}) installed." |
| 66 | + end |
| 67 | + |
| 68 | + CLOBBER << gem_file |
| 69 | +end |
| 70 | + |
| 71 | +default_tasks << :build |
| 72 | + |
44 | 73 | task default: default_tasks
|
| 74 | + |
| 75 | +desc 'Build and install the git gem and run a sanity check' |
| 76 | +task :'test:gem' => :install do |
| 77 | + output = `ruby -e "require 'git'; g = Git.open('.'); puts g.log.size"`.chomp |
| 78 | + raise 'Gem test failed' unless $CHILD_STATUS.success? |
| 79 | + raise 'Expected gem test to return an integer' unless output =~ /^\d+$/ |
| 80 | + |
| 81 | + puts 'Gem Test Succeeded' |
| 82 | +end |
0 commit comments