summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile55
1 files changed, 51 insertions, 4 deletions
diff --git a/Rakefile b/Rakefile
index 79957ab..06d82c5 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,11 +1,18 @@
# -*- ruby -*-
+require 'psych'
require 'rubygems'
require 'hoe'
+def java?
+ RUBY_PLATFORM =~ /java/
+end
+
class Hoe
remove_const :RUBY_FLAGS
- RUBY_FLAGS = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
+ flags = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
+ flags = "--1.9 " + flags if java?
+ RUBY_FLAGS = flags
end
gem 'rake-compiler', '>= 0.4.1'
@@ -27,12 +34,52 @@ $hoe = Hoe.spec 'psych' do
extra_dev_deps << ['minitest', '~> 5.0']
self.spec_extras = {
- :extensions => ["ext/psych/extconf.rb"],
:required_ruby_version => '>= 1.9.2'
}
- Rake::ExtensionTask.new "psych", spec do |ext|
- ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
+ if java?
+ require './lib/psych/versions.rb'
+ extra_deps << ['jar-dependencies', '>= 0.1.7']
+
+ # the jar declaration for jar-dependencies
+ self.spec_extras[ 'requirements' ] = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}"
+ self.spec_extras[ 'platform' ] = 'java'
+ # TODO: clean this section up.
+ require "rake/javaextensiontask"
+ Rake::JavaExtensionTask.new("psych", spec) do |ext|
+ require 'maven/ruby/maven'
+ # uses Mavenfile to write classpath into pkg/classpath
+ # and tell maven via system properties the snakeyaml version
+ Maven::Ruby::Maven.new.exec( 'dependency:build-classpath', "-Djruby.version=#{JRUBY_VERSION}", "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}")#, '--quiet' )
+ ext.source_version = '1.7'
+ ext.target_version = '1.7'
+ ext.classpath = File.read('pkg/classpath')
+ ext.ext_dir = 'ext/java'
+ end
+ else
+ self.spec_extras[:extensions] = ["ext/psych/extconf.rb"]
+ Rake::ExtensionTask.new "psych", spec do |ext|
+ ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
+ end
+ end
+end
+
+def gem_build_path
+ File.join 'pkg', $hoe.spec.full_name
+end
+
+def add_file_to_gem relative_path
+ target_path = File.join gem_build_path, relative_path
+ target_dir = File.dirname(target_path)
+ mkdir_p target_dir unless File.directory?(target_dir)
+ rm_f target_path
+ safe_ln relative_path, target_path
+ $hoe.spec.files.concat [relative_path]
+end
+
+if java?
+ task gem_build_path => [:compile] do
+ add_file_to_gem 'lib/psych.jar'
end
end