Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

260 lines (210 sloc) 8.112 kb
require 'fileutils'
require 'rexml/document'
require 'json'
require 'albacore'
PROPS = 'src/CommonAssemblyInfo.cs'
SLN = 'src/FluentNHibernate.sln'
CONFIG = 'config.json'
NUSPEC = 'src/FluentNHibernate.nuspec'
module Platform
def self.is_nix
!RUBY_PLATFORM.match("linux|darwin").nil?
end
def self.runtime(cmd)
command = cmd
if self.is_nix
runtime = (CLR_TOOLS_VERSION || "v4.0.30319")
command = "mono --runtime=#{runtime} #{cmd}"
end
command
end
def self.switch(arg)
sw = self.is_nix ? " -" : " /"
sw + arg
end
def self.config
JSON.parse(File.read(CONFIG))
end
end
NH_VERSION = Platform.config['build']['nh_precompiler_switch']
# Albacore.configure do |config|
# config.log_level = :verbose
# end
def get_version
ENV['BUILD_NUMBER'] || Platform.config['default_version_number']
end
task :default => ['ripple:restore', 'source:update_version', 'build:all']
namespace :ci do
task :run_ci_build => ['ripple:restore', 'build:all', 'docs:build', 'package:all' ]
end
namespace :ripple do
desc 'Restores NuGet package binaries'
task :restore do |cmd|
ripple = Platform.runtime("buildsupport/ripple.exe")
args = "restore"
sh "#{ripple} #{args}"
end
end
namespace :source do
desc 'Update assembly info with latest version number'
assemblyinfo :update_version do |info|
info.output_file = PROPS
commit_hash = `git log -1 --format="%H%"`
info.title = Platform.config['assembly_info']['title']
info.version = get_version
info.informational_version = Platform.config['assembly_info']['version']
info.company_name = 'http://fluentnhibernate.org'
info.product_name = 'FluentNHibernate'
info.description = commit_hash[0..(commit_hash.length - 3)]
info.copyright = "Copyright 2008-#{Time.new.year} James Gregory and contributors (Paul Batum, Hudson Akridge et al). All rights reserved."
info.namespaces = ['System.Security']
puts "The new version is #{info.version}"
end
task :nhibernate_version, :nhibernate_version do |t,args|
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
end
desc 'Compile the source'
msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msbuild, args|
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
nh_version_precompiler_switch = 'NH' + args.nhibernate_version.gsub('.', '')
puts 'Precompiler switch: ' + nh_version_precompiler_switch
msbuild.properties = {
configuration: :Release,
DefineConstants: nh_version_precompiler_switch,
WarningLevel: 0
}
msbuild.targets [:Clean, :Build]
msbuild.solution = SLN
msbuild.verbosity = :minimal
msbuild.parameters = ["/p:TargetFrameworkVersion=#{Platform.config['build']['msbuild_runtime']}"]
end
end
namespace :specs do
desc 'Run all tests and specs'
task :all => [:nunit, :mspec]
desc 'Run MSpec specs'
mspec :mspec do |mspec|
mspec.command = "src/packages/Machine.Specifications.0.5.15/tools/mspec#{Platform.config['tests']['mspec_exec_suffix']}.exe"
mspec.assemblies = [ 'src/FluentNHibernate.Specs/bin/Release/FluentNHibernate.Specs.dll' ]
end
desc 'Run NUnit tests'
nunit :nunit do |nunit|
nunit.command = 'src/packages/NUnit.2.5.7.10213/Tools/nunit-console-x86.exe'
nunit.assemblies = [ 'src/FluentNHibernate.Testing/bin/Release/FluentNHibernate.Testing.dll' ]
nunit.parameters = [ "/framework:#{Platform.config['tests']['nunit_framework_runtime']}" ]
end
end
namespace :build do
desc 'Run full build including tests'
task :all => ['source:update_version', 'source:compile', 'specs:all'] do
puts 'Copying output to build directory'
Dir.mkdir 'build' unless File.exist? 'build'
Dir.glob 'src/FluentNHibernate/bin/Release/*.{dll,pdb,xml}' do |path|
copy path, 'build' if File.file? path
end
puts 'Build complete'
end
end
namespace :docs do
desc 'Create API docs'
docu :build do |d|
d.command = 'tools/docu/docu.exe'
d.assemblies = [ 'build/FluentNHibernate.dll' ]
end
end
namespace :git do
desc "Tags the current release"
task :tag, :assembly_info do |asm, args|
args.with_defaults(:assembly_info => Platform.config['assembly_info']['version'])
sh "git tag \"v#{args.version}\""
end
desc "Updates the version and tags the release"
task :prep_release, :assembly_info do |task, args|
if !args.version.nil?
task(:update_version).invoke(args.version)
sh "git add #{CONFIG} #{NUSPEC}"
sh "git commit -m \"Updated version to #{args.version}\""
task(:tag).invoke(args.version)
end
end
end
namespace :package do
task :prepare_dist_directory do
FileUtils.rm_rf 'dist'
Dir.mkdir 'dist'
end
desc 'Create zip of source-tree'
zip :source => :prepare_dist_directory do |zip|
file_prefix = ENV['SourceDistFilename'] || 'fluentnhibernate-source'
zip.directories_to_zip = ['./']
zip.output_file = "#{file_prefix}-#{get_version}.zip"
zip.output_path = 'dist'
zip.exclusions = get_exclusions
end
def get_exclusions
exclusions = []
%w{build dist results output}.each {|x| exclusions << "#{x}" << "#{x}/**/**" }
%w{bin obj}.each {|x| exclusions << "**/#{x}" << "**/#{x}/**/**" }
[/_ReSharper/, /.user/, /.suo/, /.resharper/, /.cache/].each {|x| exclusions << x }
exclusions
end
desc 'Create zip of binaries'
zip :binaries => :prepare_dist_directory do |zip|
file_prefix = ENV['BinaryDistFilename'] || 'fluentnhibernate-binary'
zip.directories_to_zip = ['build']
zip.output_file = "#{file_prefix}-#{get_version}.zip"
zip.output_path = 'dist'
end
desc 'Create zip of API docs'
zip :docs => :prepare_dist_directory do |zip|
zip.directories_to_zip = ['output']
zip.output_file = "fluentnhibernate-docs-#{get_version}.zip"
zip.output_path = 'dist'
end
task :nuspec do |nu|
config = Platform.config['nuspec']
puts "Updating #{NUSPEC}"
update_xml NUSPEC do |xml|
xml.root.elements["metadata/id"].text = config['id']
xml.root.elements["metadata/title"].text = config['title']
xml.root.elements["metadata/version"].text = config['version']
xml.root.elements["metadata/dependencies/dependency[@id='NHibernate']"].attributes['version'] = config['nhibernate_version_interval']
xml.root.elements["metadata/authors"].text = "James Gregory and contributors"
xml.root.elements["metadata/owners"].text = "jagregory, chester89"
xml.root.elements["metadata/language"].text = "en-US"
xml.root.elements["metadata/description"].text = "Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate."
xml.root.elements["metadata/licenseUrl"].text = "http://github.com/jagregory/fluent-nhibernate/raw/master/LICENSE.txt"
xml.root.elements["metadata/projectUrl"].text = "http://fluentnhibernate.org"
xml.root.elements["metadata/tags"].text = "orm dal nhibernate conventions"
xml.root.elements["files/file[contains(@src, 'bin\\Release\\FluentNHibernate.*')]"].attributes['target'] = "lib\\#{config['binaries_folder']}"
end
end
nugetpack :nupack do |nu|
nu.command = 'tools/nuget/NuGet.exe'
nu.nuspec = NUSPEC
nu.base_folder = 'Release'
nu.output = 'dist'
end
desc 'Create nuget spec and package'
task :nuget => [:nuspec, :nupack]
desc 'Package everything (src, bin, docs, nuget)'
task :all => [:source, :binaries, :docs, :nuget]
end
def update_xml(xml_path)
#Open up the xml file
xml_file = File.new(xml_path)
xml = REXML::Document.new xml_file
#Allow caller to make the changes
yield xml
xml_file.close
#Save the changes
xml_file = File.open(xml_path, "w")
formatter = REXML::Formatters::Default.new(5)
formatter.write(xml, xml_file)
xml_file.close
end
task :sln do
Thread.new do
system "devenv #{SLN}"
end
end
Jump to Line
Something went wrong with that request. Please try again.