Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 555ba46e60
Fetching contributors…

Cannot retrieve contributors at this time

216 lines (172 sloc) 6.908 kb
COMPILE_TARGET = "release"
require "BuildUtils.rb"
require 'fileutils'
include FileTest
RESULTS_DIR = "results"
DIST_DIR = 'dist'
PRODUCT = "FluentNHibernate"
COPYRIGHT = 'Copyright 2008-2009 James Gregory and contributors (Paul Batum, Andrew Stewart, Hudson Akridge, Stuart Childs et al). All rights reserved.';
COMMON_ASSEMBLY_INFO = 'src/CommonAssemblyInfo.cs';
CLR_VERSION = "v3.5"
props = { :archive => "build" }
desc "Compiles, unit tests, generates the database, and then runs integration tests"
task :all => [:default]
desc "**Default**, compiles and runs tests"
task :default => [:use_nhib_21, :compile, :unit_test]
desc "Builds Fluent NHibernate against the NHibernate trunk libs (instead of the normal NHibernate 2.1GA)"
task :nhibtrunk =>[:use_nhib_trunk, :compile, :unit_test, :use_nhib_201]
desc "Switches NHibernate dependencies to NHibernate 2.1"
task :use_nhib_21 do
switch_nhib_libs('nhib2.1')
end
desc "Switches NHibernate dependencies to NHibernate trunk"
task :use_nhib_trunk do
switch_nhib_libs('trunk')
end
#### hidden task, don't call directly
def switch_nhib_libs(nhib_lib_dir)
puts "Switching NHibernate dependencies to #{nhib_lib_dir}"
# clear the nhib dir
Dir.foreach('tools/NHibernate') {|file|
relFile = File.join('tools/NHibernate',file)
File.delete(relFile) if File.file?(relFile)
}
# copy the source files over
Dir.foreach("tools/NHibernate/#{nhib_lib_dir}"){|file|
relFile = File.join("tools/NHibernate/#{nhib_lib_dir}",file)
copy(relFile, 'tools/NHibernate') if File.file?(relFile)
}
end
def get_version
return ENV['BUILD_NUMBER'].to_s unless ENV['BUILD_NUMBER'].nil?
return "1.0.0.0"
end
desc "Displays a list of tasks"
task :help do
taskHash = Hash[*(`rake.cmd -T`.split(/\n/).collect { |l| l.match(/rake (\S+)\s+\#\s(.+)/).to_a }.collect { |l| [l[1], l[2]] }).flatten]
indent = " "
puts "rake #{indent}#Runs the 'default' task"
taskHash.each_pair do |key, value|
if key.nil?
next
end
puts "rake #{key}#{indent.slice(0, indent.length - key.length)}##{value}"
end
end
desc "Update the version information for the build"
task :version do
builder = AsmInfoBuilder.new get_version(),
:product => PRODUCT,
:copyright => COPYRIGHT,
:company => 'http://fluentnhibernate.org',
:allow_partially_trusted_callers => true
buildNumber = builder.buildnumber
puts "The build number is #{buildNumber}"
builder.write COMMON_ASSEMBLY_INFO
end
desc "Prepares the working directory for a new build"
task :clean do
#TODO: do any other tasks required to clean/prepare the working directory
Dir.mkdir props[:archive] unless exists?(props[:archive])
end
desc "Compiles the app"
task :compile => [:clean, :version] do
MSBuildRunner.compile :compilemode => COMPILE_TARGET, :solutionfile => 'src/FluentNHibernate.sln', :clrversion => CLR_VERSION
outDir = "src/FluentNHibernate/bin/#{COMPILE_TARGET}"
Dir.glob(File.join(outDir, "*.{dll,pdb,xml}")){|file|
copy(file, props[:archive]) if File.file?(file)
}
end
desc "Runs unit tests"
task :unit_test => :compile do
runner = NUnitRunner.new :compilemode => COMPILE_TARGET, :source => 'src', :platform => 'x86'
runner.executeTests ['FluentNHibernate.Testing']
end
desc "Clear built zips"
task :clear_dist do
FileUtils.rm_rf DIST_DIR if File.exists? DIST_DIR
end
desc "Creates a source zip"
task :create_source_zip do
puts "Creating source zip"
Dir.mkdir DIST_DIR unless File.exists? DIST_DIR
version = get_version()
create_zip("#{DIST_DIR}/fluentnhibernate-source-#{version}.zip", './', /.git|build|dist|results|_ReSharper|bin|obj|.user|.suo|.resharper|.cache/)
end
desc "Create a binary zip"
task :create_binary_zip do
puts "Creating binary zip"
Dir.mkdir DIST_DIR unless File.exists? DIST_DIR
version = get_version()
create_zip("#{DIST_DIR}/fluentnhibernate-binary-#{version}.zip", 'build/')
end
desc "Creates binary and source zip files"
task :create_zips => [:create_source_zip, :create_binary_zip]
desc "Builds the API documentation and puts it in 'output'"
task :build_docs do
puts "Creating docs"
docu("src/FluentNHibernate/bin/#{COMPILE_TARGET}/FluentNHibernate.dll")
end
desc "Creates a zip of the API documentation"
task :create_zip_docs => :build_docs do
puts "Creating docs zip"
Dir.mkdir DIST_DIR unless File.exists? DIST_DIR
version = get_version()
create_zip("#{DIST_DIR}/fluentnhibernate-docs-#{version}.zip", 'output/')
end
class NCover
NCOVER_PATH = 'tools\\ncover\\ncover.console.exe'
NUNIT_PATH = 'tools\\nunit\\nunit-console.exe'
def initialize(args)
@categories = args[:categories]
@included_assemblies = args[:included_assemblies]
@included_types = args[:included_types]
@excluded_types = args[:excluded_types]
@excluded_methods = args[:excluded_methods]
end
def run
puts `#{get_ncover_cmd}`
end
private
def get_ncover_cmd
[NCOVER_PATH, get_nunit_cmd, get_ncover_args].join(' ')
end
def get_ncover_args
included_assemblies = ncover_concat(escape(@included_assemblies))
included_types = ncover_concat(escape(@included_types))
excluded_types = ncover_concat(escape(@excluded_types))
excluded_methods = ncover_concat(escape(@excluded_methods))
['//w src\\FluentNHibernate.Testing\\bin\\x86\\Debug',
"//ias #{included_assemblies}",
"//it #{included_types}",
"//et #{excluded_types}",
"//em #{excluded_methods}",
"//reg"].join(' ')
end
def get_nunit_cmd
[NUNIT_PATH, 'FluentNHibernate.Testing.dll', "/include=#{get_categories}"].join(' ')
end
def get_categories
escape(@categories).join(',')
end
def escape(array)
array.map { |i| "\"#{i}\"" }
end
def ncover_concat(array)
array.join(';')
end
end
desc "Coverage report for Inspection DSL"
task :coverage_for_inspection_dsl do
puts "Running coverage report for Inspection DSL"
ncover = NCover.new :categories => ['Inspection DSL'],
:included_assemblies => ['FluentNHiberate'],
:included_types => ['FluentNHibernate.Conventions.DslImplementation*',
'FluentNHibernate.Conventions.Inspections.*',
'FluentNHibernate.MappingModel.*'],
:excluded_types => ['FluentNHibernate.MappingMode.(Conventions|Output|).*'],
:excluded_methods => ['.*\.Add.*', # AddColumn etc...
'.*\.AcceptVisitor', # AcceptVisitor
'.*\.I.*Alteration\..*'] # Any IXAlteration explicit implementations
ncover.run
end
Jump to Line
Something went wrong with that request. Please try again.