forked from nhibernate/fluent-nhibernate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RakeFile
223 lines (178 loc) · 6.86 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
desc "Open solution in VS"
task :sln do
Thread.new do
system "devenv src/FluentNHibernate.sln"
end
end