require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'rake/packagetask' require 'rake/gempackagetask' require 'rake/contrib/sshpublisher' require 'rake/contrib/rubyforgepublisher' require 'xforge' PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_NAME = 'rscm' PKG_VERSION = '0.3.0' + PKG_BUILD PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" desc "Default Task" task :default => [ :all ] task :all => [:ant, :gem] # Run the unit tests # To run a specific test: rake test TEST=path/to/test fl = FileList.new('test/**/*_test.rb') fl.exclude('test/**/mooky*.rb') #fl.exclude('test/**/monotone*.rb') # Incomplete/unsupported for now - reactivate when more complete! fl.exclude('test/**/clearcase*.rb') # Incomplete/unsupported for now - reactivate when more complete! fl.exclude('test/**/darcs*.rb') # Incomplete/unsupported for now - reactivate when more complete! #fl.exclude('test/**/perforce*.rb') # Incomplete/unsupported for now - reactivate when more complete! #fl.exclude('test/**/p4client*.rb') # Incomplete/unsupported for now - reactivate when more complete! fl.exclude('test/**/starteam*.rb') # Too bloody hard to test without a StarTeam server license! Tested ad-hoc. Rake::TestTask.new { |t| t.libs << "test" t.test_files = fl t.verbose = true } rd = Rake::RDocTask.new { |rdoc| rdoc.title = 'RSCM - Ruby Source Control Management API' rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_files.include('README') rdoc.rdoc_files.include('CHANGELOG') rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.include('docs/**/*.rd') } task :ant do |t| if(!ENV['RSCM_STARTEAM']) puts "WARNING - NOT BUILDING STARTEAM SUPPORT SINCE 'RSCM_STARTEAM' IS NOT DEFINED." else ant = RUBY_PLATFORM == "i386-mswin32" ? "ant.bat" : system("which ant.sh") ? "ant.sh" : "ant" IO.popen("#{ant} -f ext/java/build.xml clean jar") do |io| io.each_line do |line| puts line end end end end PKG_FILES = FileList[ '[A-Z]*', 'lib/**/*', 'bin/**/*', 'test/**/*', 'testproject/**/*', 'doc/**/*', 'ext/rscm.jar' ] if ! defined?(Gem) puts "Package Target requires RubyGEMs" else spec = Gem::Specification.new do |s| #### Basic information. s.name = PKG_NAME s.version = PKG_VERSION s.summary = "RSCM - Ruby Source Control Management" s.description = <<-EOF RSCM is a Ruby library for various Source Control Management (SCM) systems. EOF #### Which files are to be included in this gem? Everything! (Except CVS directories.) s.files = PKG_FILES.to_a #### Load-time details: library and application (you will need one or both). s.require_path = 'lib' s.autorequire = 'rscm' #### Documentation and testing. s.has_rdoc = true s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a rd.options.each do |op| s.rdoc_options << op end #### Author and project details. s.author = "Aslak Hellesoy" s.email = "dev@damagecontrol.codehaus.org" s.homepage = "http://rscm.rubyforge.org" s.rubyforge_project = "rscm" end Rake::GemPackageTask.new(spec) do |pkg| pkg.need_zip = true pkg.need_tar = true end end task :release => [:publish_doc, :publish_files] task :publish_files => [:gem] do release_files = FileList[ "pkg/#{PKG_FILE_NAME}.gem", "CHANGES" ] Rake::XForge::Release.new(PKG_NAME) do |xf| # Never hardcode user name and password in the Rakefile! xf.user_name = ENV['RUBYFORGE_USER'] xf.password = ENV['RUBYFORGE_PASSWORD'] xf.files = release_files.to_a xf.release_name = "XForge #{PKG_VERSION}" end end task :publish_doc => [:rdoc] do publisher = Rake::RubyForgePublisher.new('rscm', 'aslak_hellesoy') end