#-*- mode: ruby -*-

id 'none:base:0'
packaging :pom

snapshot_repository :id => 'jruby', :url => 'http://ci.jruby.org/snapshots/maven'

# TODO should be setup whenever a plugin uses gems
plugin_repository :id => 'rubygems-releases', :url => 'http://rubygems-proxy.torquebox.org/releases'

base_path = File.expand_path('..', File.dirname(__FILE__))
bc_version = File.read("#{base_path}/lib/jopenssl/version.rb")[/BOUNCY_CASTLE_VERSION\s?=\s?'(.*?)'/, 1]

properties( 'bc.version' => bc_version, # to satisfy maven
            'jruby.openssl.version' => '0.9.7', # to satisfy maven
            # use the gem-maven-plugin repo for the tests
            'gem.home' => '${basedir}/../pkg/rubygems',
            'gem.path' => '${basedir}/../pkg/rubygems',
            'tesla.dump.pom' => 'pom.xml',
            'tesla.dump.readonly' => true,
            'jruby.version' => '1.7.19', # for jruby-maven-plugins
            'jruby.plugins.version' => '1.0.9' )

jruby_plugin :gem, :gemHomes => { 'gem-maven-plugin' => '${gem.home}' } do
  execute_goal :initialize

  gem 'jar-dependencies', '0.1.8' # TODO change after 0.1.15 is out
  spec = Gem::Specification.load "#{base_path}/jruby-openssl.gemspec"
  spec.development_dependencies.each do |dev_spec|
    gem dev_spec.name, *dev_spec.requirements_list
  end

  # make sure we have those in the local repo
  # BUT not be part of the runit-classloader
  # otherwise jruby-1.7.x and jruby-1.6.x will not use those
  # required in the test_*.rb files
  jar  'org.bouncycastle', 'bcpkix-jdk15on', '${bc.version}'
  jar  'org.bouncycastle', 'bcprov-jdk15on', '${bc.version}'
  #spec.requirements.each do |req|
  #  req = req.sub('jar', '').split(',').each(&:strip!)
  #  jar req[0], req[1]
  #end

  gem 'jruby-openssl', '${jruby.openssl.version}'

end

jruby_plugin :runit do
  execute_goal( :test,
                :env => { 'BC_VERSION' => '${bc.version}' },
                :jrubySwitches => '-I../../lib',
                :runitDirectory => '../../src/test/ruby/**/test_*.rb',
                :versions => '${jruby.versions}',
                :modes => '${jruby.modes}' )
end

# vim: syntax=Ruby
