#-- # Copyright (c) 2011 Engine Yard, Inc. # See the file LICENSE.txt included with the distribution for # software license details. #++ require "bundler/gem_tasks" require "rake/clean" desc "Compile and jar the agent extension class" begin require 'ant' jar_file = "lib/engineyard-visualvm/agent.jar" directory "pkg/classes" CLEAN << "pkg" file jar_file => FileList['ext/**/*.java', 'pkg/classes'] do rm_rf FileList['pkg/classes/**/*'] ant.javac :srcdir => "ext", :destdir => "pkg/classes", :source => "1.5", :target => "1.5", :debug => true, :classpath => "${java.class.path}:${sun.boot.class.path}", :includeantRuntime => false ant.jar :basedir => "pkg/classes", :destfile => jar_file, :includes => "**/*.class" do manifest do attribute :name => "Premain-Class", :value => "org.jruby.ext.jmx.Agent" end end end task :jar => jar_file rescue LoadError task :jar do puts "Run 'jar' with JRuby to re-compile the agent extension class" end end # Make sure jar gets compiled before the gem is built task :build => :jar task :default => :spec require 'rspec/core/rake_task' RSpec::Core::RakeTask.new task :spec => :jar # Override push to use engineyard key class Bundler::GemHelper def rubygem_push(path) if Gem.configuration.api_keys.key? :engineyard sh("gem push -k engineyard '#{path}'") Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org" else raise ":engineyard key not set in ~/.gem/credentials" end end end begin require 'childprocess' require 'jmx' task :acceptance => :build do sh "vagrant ssh_config > ssh_config.tmp" sh "vagrant up" at_exit { sh "vagrant halt"; rm_f "ssh_config.tmp" } @host, @port = 'localhost', 5900 ssh = ChildProcess.build("ssh", "-NL", "#{@port}:#{@host}:#{@port}", "-F", "ssh_config.tmp", "default") ssh.start at_exit { ssh.stop } require 'engineyard-visualvm' include EngineYard::VisualVM::Helpers server = JMX::MBeanServer.new jmx_service_url runtime_config_name = server.query_names('org.jruby:type=Runtime,name=*,service=Config').to_a.first puts "Found runtime #{runtime_config_name}" runtime_config = server[runtime_config_name] puts "Runtime version: #{runtime_config['VersionString']}" puts "OK" end rescue LoadError task :acceptance do fail "Run 'acceptance' with JRuby to actually run the test" end end