forked from nhibernate/fluent-nhibernate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RakeFile
200 lines (166 loc) · 6.36 KB
/
RakeFile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
require 'fileutils'
gem 'albacore', '> 0.2.4'
require 'albacore'
require './tools/albacore/nuspec_patch'
NH_VERSION = '3.x'
def get_version
ENV['BUILD_NUMBER'] || '1.3.0.0'
end
task :default => 'build:all'
namespace :setup do
task :ensure_gemcutter_source do
puts 'Ensuring gemcutter.org is registered as a gem source'
unless `gem source -l`.include? 'http://gemcutter.org'
puts 'Setting Gemcutter as a gem source'
`gem source -a http://gemcutter.org`
end
end
task :install_mspec, :resharper_version, :vs_version do |t, args|
resharper_version = args[:resharper_version] || '5.1'
vs_version = args[:vs_version] || 10.0
puts 'Installing MSpec ReSharper runner'
plugins = "#{ENV['APPDATA']}/JetBrains/ReSharper/v#{resharper_version}/vs#{vs_version}/Plugins"
to_copy = ['Machine.Specifications', "Machine.Specifications.ReSharperRunner.#{resharper_version}"]
FileUtils.mkdir plugins unless File.exists? plugins
to_copy.each do |f|
FileUtils.cp "tools/mspec/#{f}.dll", plugins
FileUtils.cp "tools/mspec/#{f}.pdb", plugins
end
end
end
namespace :ci do
task :run_ci_build => [
'build:all',
'docs:build',
'package:all',
]
end
namespace :source do
desc 'Update assembly info with latest version number'
assemblyinfo :update_version do |asm|
asm.output_file = 'src/CommonAssemblyInfo.cs'
asm.version = get_version
asm.company_name = 'http://fluentnhibernate.org'
asm.product_name = 'FluentNHibernate'
asm.copyright = 'Copyright 2008-2011 James Gregory and contributors (Paul Batum, Hudson Akridge et al). All rights reserved.'
asm.namespaces = ['System.Security']
asm.custom_attributes :AllowPartiallyTrustedCallers => nil
puts "The build number is #{asm.version}"
end
task :nhibernate_version, :nhibernate_version do |t,args|
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
raise "Unknown NHibernate version #{args.nhibernate_version} (check your tools/NHibernate folder)" unless File.directory? "tools/NHibernate/#{args.nhibernate_version}"
# clear out existing selected nh version
files_to_delete = Dir["tools/NHibernate/*.*"].reject {|f| File.directory? f }
files_to_delete.each {|f| File.delete f }
# copy specific nh version files to the main directory
files_to_copy = Dir["tools/NHibernate/#{args.nhibernate_version}/*.*"]
files_to_copy.each {|f| FileUtils.copy f, "tools/NHibernate/" }
end
desc 'Compile the source'
msbuild :compile, [:nhibernate_version] => :nhibernate_version do |msb,args|
args.with_defaults :nhibernate_version => ENV['nhibernate_version'] || NH_VERSION
nh_version_precompiler_switch = 'NH' + args.nhibernate_version.gsub('.', '')
puts nh_version_precompiler_switch
msb.properties = { :configuration => :Release, :DefineConstants => nh_version_precompiler_switch }
msb.targets [:Clean, :Build]
msb.solution = 'src/FluentNHibernate.sln'
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 = 'tools/mspec/mspec.exe'
mspec.assemblies 'src/FluentNHibernate.Specs/bin/Release/FluentNHibernate.Specs.dll'
end
desc 'Run NUnit tests'
nunit :nunit do |nunit|
nunit.command = 'tools/nunit/nunit-console-x86.exe'
nunit.assemblies 'src/FluentNHibernate.Testing/bin/Release/FluentNHibernate.Testing.dll'
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 :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
nuspec do |nu|
nu.id = 'FluentNHibernate'
nu.version = get_version()
nu.authors = 'James Gregory and contributors'
nu.description = 'Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate.'
nu.title = 'Fluent NHibernate'
nu.language = 'en-US'
nu.licenseUrl = 'http://github.com/jagregory/fluent-nhibernate/raw/master/LICENSE.txt'
nu.projectUrl = 'http://fluentnhibernate.org'
nu.dependency 'NHibernate', '3.2.0.4000'
nu.working_directory = 'build'
nu.output_file = 'fluentnhibernate.nuspec'
nu.file 'FluentNHibernate.dll', 'lib'
nu.file 'FluentNHibernate.pdb', 'lib'
nu.tags = 'orm dal nhibernate conventions'
end
nugetpack do |nu|
nu.command = 'tools/nuget/NuGet.exe'
nu.nuspec = 'build/fluentnhibernate.nuspec'
nu.base_folder = 'build'
nu.output = 'dist'
end
desc 'Create nuget spec and package'
task :nuget => [:nuspec, :nugetpack]
desc 'Package everything (src, bin, docs, nuget)'
task :all => [:source, :binaries, :docs, :nuget]
end
task :sln do
Thread.new do
system "devenv src/FluentNHibernate.sln"
end
end