Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

coordinate building of gems for 3 different platforms

  • Loading branch information...
commit ebf77c78b2fc4e4fd753eeb78c65890ff07474a1 1 parent 4164d12
@copiousfreetime authored
Showing with 38 additions and 15 deletions.
  1. +6 −1 gemspec.rb
  2. +18 −3 tasks/distribution.rake
  3. +14 −11 tasks/extension.rake
View
7 gemspec.rb
@@ -57,4 +57,9 @@
Hitimes::GEM_SPEC_MINGW32.platform = ::Gem::Platform.new( "i386-mingw32" )
Hitimes::GEM_SPEC_MINGW32.extensions = []
-Hitimes::SPECS = [ Hitimes::GEM_SPEC, Hitimes::GEM_SPEC_MSWIN32, Hitimes::GEM_SPEC_MINGW32 ]
+Hitimes::GEM_SPEC_JAVA = Hitimes::GEM_SPEC.clone
+Hitimes::GEM_SPEC_JAVA.platform = ::Gem::Platform.new( 'java' )
+Hitimes::GEM_SPEC_JAVA.extensions = []
+
+Hitimes::SPECS = [ Hitimes::GEM_SPEC, Hitimes::GEM_SPEC_MSWIN32, Hitimes::GEM_SPEC_MINGW32, Hitimes::GEM_SPEC_JAVA ]
+
View
21 tasks/distribution.rake
@@ -36,11 +36,16 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
puts Hitimes::GEM_SPEC_WIN.to_ruby
end
+ desc "dump gemspec for java"
+ task :gemspec_java do
+ puts Hitimes::GEM_SPEC_JAVA.to_ruby
+ end
+
desc "reinstall gem"
task :reinstall => [:uninstall, :repackage, :install]
desc "package up a windows gem"
- task :package_win => :clean do
+ task :package_win => :clean do
Configuration.for("extension").cross_rbconfig.keys.each do |rbconfig|
v = rbconfig.split("-").last
s = v.sub(/\.\d$/,'')
@@ -58,15 +63,25 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
end
end
+ if RUBY_PLATFORM == "java" then
+ desc "package up a jruby gem"
+ task :package_java => "ext:build_java" do
+ Hitimes::GEM_SPEC_JAVA.files += FileList["lib/hitimes/java/*.jar"]
+ Gem::Builder.new( Hitimes::GEM_SPEC_JAVA ).build
+ mv Dir["*.gem"].first, "pkg"
+ end
+ end
+
task :clobber do
rm_rf "lib/hitimes/1.8"
rm_rf "lib/hitimes/1.9"
+ rm_rf "lib/hitimes/*.jar"
end
- task :prep => [:clean, :package, :package_win]
+ task :prep => [:clean, :package, :package_win, :package_java ]
desc "distribute copiously"
- task :copious => [:clean, :package, :package_win ] do
+ task :copious => [:clean, :package, :package_win, :package_java ] do
gems = Hitimes::SPECS.collect { |s| "#{s.full_name}.gem" }
Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
'/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
View
25 tasks/extension.rake
@@ -8,7 +8,7 @@ require 'pathname'
if ext_config = Configuration.for_if_exist?('extension') then
namespace :ext do
desc "Build the extension(s)"
- task :build => :clean do
+ task :build => :clobber do
ext_config.configs.each do |extension|
path = Pathname.new(extension)
parts = path.split
@@ -26,17 +26,20 @@ if ext_config = Configuration.for_if_exist?('extension') then
end
end
- desc "Build the jruby extension"
- task :build_jruby => :clean do
- path = "ext/java"
- Dir.chdir( path ) do |d|
- #java_ext = "lib/hitimes/java/#{RUBY_VERSION.sub(/\.\d$/,'')}/hitimes_ext.#{Config::CONFIG['DLEXT']}"
- java_ext = "lib/hitimes/hitimes.jar"
+ if RUBY_PLATFORM == "java" then
+ desc "Build the jruby extension"
+ task :build_java => [ :clobber, "lib/hitimes/hitimes.jar" ]
+
+ file "lib/hitimes/hitimes.jar" => FileList["ext/java/src/hitimes/*.java"] do |t|
jruby_home = Config::CONFIG['prefix']
- classpath = "#{jruby_home}/lib/jruby.jar"
- FileUtils.mkdir_p "../../#{File.dirname( java_ext )}"
- sh "javac -g -cp #{classpath} hitimes/*.java"
- sh "jar cf ../../#{java_ext} hitimes/*.class"
+ jruby_jar = File.join( jruby_home, 'lib', 'jruby.jar' )
+
+ mkdir_p 'pkg/classes'
+ sh "javac -classpath #{jruby_jar} -d pkg/classes #{t.prerequisites.join(' ')}"
+
+ dest_dir = File.dirname(t.name)
+ mkdir_p dest_dir
+ sh "jar cf #{t.name} -C pkg/classes ."
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.