#-*- mode: ruby -*-

properties( 'polyglot.dump.pom' => 'pom.xml',
            'jruby.version' => '@project.version@',
            'jruby.plugins.version' => '1.0.8',
            'jruby.home' => '${basedir}/../../../../..' )

phase :package do
  plugin :dependency do
    execute_goal( :copy,
                  :artifactItems => [ {
                    :groupId => 'org.jruby',
                    :artifactId => 'jruby-complete',
                    :version => '${jruby.version}'
                  } ] )
  end

  plugin( 'org.codehaus.mojo:exec-maven-plugin:1.2',
          :executable => 'java',
          :environmentVariables => {
            'PATH' => '${project.basedir}/bin${path.separator}${env.PATH}',
            'GEM_PATH' => '${jruby.home}/lib/ruby/gems/shared',
            'GEM_HOME' => '${jruby.home}/lib/ruby/gems/shared'
          },
          :basedir => '${jruby.home}' ) do

    # see if gem gets found inside the jar though it is on $PATH
    execute_goal( :exec, :id => 'gem help',
                  :arguments => [ '-Djruby.debug.scriptResolution=true', '-jar', '${project.build.directory}/dependency/jruby-complete-${jruby.version}.jar', '-S', 'gem', 'help' ] )

    execute_goal( :exec, :id => 'rake -T',
                  :arguments => [ '-jar', '${project.build.directory}/dependency/jruby-complete-${jruby.version}.jar', '-S', 'rake', '-T' ] )

    execute_goal( :exec, :id => 'rake test:mri',
                  :arguments => [ '-jar', '${project.build.directory}/dependency/jruby-complete-${jruby.version}.jar', '-S', 'rake', 'test:mri' ] )

  end
end
 
