Use a more portable mechanism for deriving the platform

Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/6fce2250
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/6fce2250
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/6fce2250

Branch: refs/heads/master
Commit: 6fce2250a6c708367d99a1e44570d748b2beab28
Parents: 70109f9
Author: Peter Donald <[email protected]>
Authored: Fri Nov 28 21:05:04 2014 +1100
Committer: Peter Donald <[email protected]>
Committed: Fri Nov 28 21:05:04 2014 +1100

----------------------------------------------------------------------
 Rakefile       | 6 ++++--
 buildr.gemspec | 7 ++++---
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/6fce2250/Rakefile
----------------------------------------------------------------------
diff --git a/Rakefile b/Rakefile
index 29a43f3..8eb43b0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -31,8 +31,10 @@ end
 # Load the Gem specification for the current platform (Ruby or JRuby).
 def spec(platform = RUBY_PLATFORM[/java/] || 'ruby')
   @specs ||= ['ruby', 'java', 'x86-mswin32'].inject({}) { |hash, spec_platform|
-    $platform = spec_platform
-    hash.update(spec_platform=>Gem::Specification.load('buildr.gemspec'))
+    ENV['BUILDR_PLATFORM'] = spec_platform
+    hash.update(spec_platform=> Gem::Specification.load('buildr.gemspec'))
+    ENV['BUILDR_PLATFORM'] = nil
+    hash
   }
   @specs[platform]
 end

http://git-wip-us.apache.org/repos/asf/buildr/blob/6fce2250/buildr.gemspec
----------------------------------------------------------------------
diff --git a/buildr.gemspec b/buildr.gemspec
index 9e94dba..74d2c5d 100644
--- a/buildr.gemspec
+++ b/buildr.gemspec
@@ -18,9 +18,10 @@ unless defined?(Buildr::VERSION)
   $LOADED_FEATURES << 'buildr/version.rb'
 end
 
-# Rakefile needs to create spec for both platforms (ruby and java), using the
-# $platform global variable.  In all other cases, we figure it out from 
RUBY_PLATFORM.
-$platform ||= RUBY_PLATFORM[/java/] || 'ruby'
+# Rakefile needs to create spec for all platforms (ruby and java), using the
+# BUILDR_PLATFORM environment variable. In all other cases, we figure it out
+# from RUBY_PLATFORM.
+$platform = ENV['BUILDR_PLATFORM'] || Gem::Platform::CURRENT
 
 Gem::Specification.new do |spec|
   spec.name           = 'buildr'

Reply via email to