Rakefile
changeset 1 1d3cfd4837a8
child 5 804e1c2b9a40
equal deleted inserted replaced
0:1b096869b568 1:1d3cfd4837a8
       
     1 #!rake -*- ruby -*-
       
     2 #
       
     3 # Ruby-Ezmlm rakefile
       
     4 #
       
     5 # Based on Ben Bleything's Rakefile for Linen (URL?)
       
     6 #
       
     7 # Copyright (c) 2007 LAIKA, Inc.
       
     8 #
       
     9 # Mistakes:
       
    10 #  * Michael Granger <mgranger@laika.com>
       
    11 #
       
    12 
       
    13 BEGIN {
       
    14 	require 'pathname'
       
    15 	basedir = Pathname.new( __FILE__ ).dirname
       
    16 	libdir = basedir + 'lib'
       
    17 
       
    18 	$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
       
    19 }
       
    20 
       
    21 
       
    22 require 'rubygems'
       
    23 
       
    24 require 'rake'
       
    25 require 'tmpdir'
       
    26 require 'pathname'
       
    27 
       
    28 $dryrun = false
       
    29 
       
    30 # Pathname constants
       
    31 BASEDIR       = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
       
    32 BINDIR        = BASEDIR + 'bin'
       
    33 LIBDIR        = BASEDIR + 'lib'
       
    34 DOCSDIR       = BASEDIR + 'docs'
       
    35 VARDIR        = BASEDIR + 'var'
       
    36 WWWDIR        = VARDIR  + 'www'
       
    37 MANUALDIR     = DOCSDIR + 'manual'
       
    38 RDOCDIR       = DOCSDIR + 'rdoc'
       
    39 STATICWWWDIR  = WWWDIR  + 'static'
       
    40 PKGDIR        = BASEDIR + 'pkg'
       
    41 ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || '' )
       
    42 RAKE_TASKDIR  = BASEDIR + 'rake'
       
    43 
       
    44 TEXT_FILES    = %w( Rakefile README LICENSE ).
       
    45 	collect {|filename| BASEDIR + filename }
       
    46 
       
    47 SPECDIR       = BASEDIR + 'spec'
       
    48 SPEC_FILES    = Pathname.glob( SPECDIR + '**/*_spec.rb' ).
       
    49 	delete_if {|item| item =~ /\.svn/ }
       
    50 # Ideally, this should be automatically generated.
       
    51 SPEC_EXCLUDES = 'spec,monkeypatches,/Library/Ruby,/var/lib,/usr/local/lib'
       
    52 
       
    53 BIN_FILES     = Pathname.glob( BINDIR + '*').
       
    54 	delete_if {|item| item =~ /\.svn/ }
       
    55 LIB_FILES     = Pathname.glob( LIBDIR + '**/*.rb').
       
    56 	delete_if {|item| item =~ /\.svn/ }
       
    57 
       
    58 RELEASE_FILES = BIN_FILES + TEXT_FILES + LIB_FILES + SPEC_FILES
       
    59 
       
    60 require RAKE_TASKDIR + 'helpers.rb'
       
    61 
       
    62 ### Package constants
       
    63 PKG_NAME      = 'ruby-ezmlm'
       
    64 PKG_VERSION_FROM = LIBDIR + 'ezmlm.rb'
       
    65 PKG_VERSION   = find_pattern_in_file( /VERSION = '(\d+\.\d+\.\d+)'/, PKG_VERSION_FROM ).first
       
    66 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
       
    67 
       
    68 RELEASE_NAME  = "REL #{PKG_VERSION}"
       
    69 
       
    70 require RAKE_TASKDIR + 'svn.rb'
       
    71 require RAKE_TASKDIR + 'verifytask.rb'
       
    72 
       
    73 if Rake.application.options.trace
       
    74 	$trace = true
       
    75 	log "$trace is enabled"
       
    76 end
       
    77 
       
    78 if Rake.application.options.dryrun
       
    79 	$dryrun = true
       
    80 	log "$dryrun is enabled"
       
    81 	Rake.application.options.dryrun = false
       
    82 end
       
    83 
       
    84 ### Project Gemspec
       
    85 GEMSPEC = Gem::Specification.new do |gem|
       
    86 	pkg_build = get_svn_rev( BASEDIR ) || 0
       
    87 	
       
    88 	gem.name    	= PKG_NAME
       
    89 	gem.version 	= "%s.%s" % [ PKG_VERSION, pkg_build ]
       
    90 
       
    91 	gem.summary     = "A Ruby programmatic interface to ezmlm-idx"
       
    92 	gem.description = "Ruby-Ezmlm is a Ruby programmatic interface to ezmlm-idx " +
       
    93 		"mailing lists, message archives, and command-line tools."
       
    94 
       
    95 	gem.authors  	= "Michael Granger, Jeremiah Jordan"
       
    96 	gem.email  		= "opensource@laika.com"
       
    97 	gem.homepage 	= "http://opensource.laika.com/wiki/ruby-ezmlm"
       
    98 
       
    99 	gem.rubyforge_project = 'laika'
       
   100 
       
   101 	gem.has_rdoc 	= true
       
   102 
       
   103 	gem.files      	= RELEASE_FILES.
       
   104 		collect {|f| f.relative_path_from(BASEDIR).to_s }
       
   105 	gem.test_files 	= SPEC_FILES.
       
   106 		collect {|f| f.relative_path_from(BASEDIR).to_s }
       
   107 
       
   108   	gem.add_dependency( 'tmail', '>= 1.2.3.1' )
       
   109 end
       
   110 
       
   111 
       
   112 # Load task plugins
       
   113 Pathname.glob( RAKE_TASKDIR + '*.rb' ).each do |tasklib|
       
   114 	trace "Loading task lib #{tasklib}"
       
   115 	require tasklib
       
   116 end
       
   117 
       
   118 
       
   119 ### Default task
       
   120 task :default  => [:clean, :spec, 'coverage:verify', :package]
       
   121 
       
   122 
       
   123 ### Task: clean
       
   124 desc "Clean pkg, coverage, and rdoc; remove .bak files"
       
   125 task :clean => [ :clobber_rdoc, :clobber_package, :clobber_coverage ] do
       
   126 	files = FileList['**/*.bak']
       
   127 	files.clear_exclude
       
   128 	File.rm( files ) unless files.empty?
       
   129 	FileUtils.rm_rf( 'artifacts' )
       
   130 end
       
   131 
       
   132 
       
   133 ### Cruisecontrol task
       
   134 desc "Cruisecontrol build"
       
   135 task :cruise => [:clean, :coverage, :package] do |task|
       
   136 	raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
       
   137 	artifact_dir = ARTIFACTS_DIR.cleanpath
       
   138 	artifact_dir.mkpath
       
   139 	
       
   140 	$stderr.puts "Copying coverage stats..."
       
   141 	FileUtils.cp_r( 'coverage', artifact_dir )
       
   142 	
       
   143 	$stderr.puts "Copying packages..."
       
   144 	FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
       
   145 end
       
   146