forked from nhibernate/fluent-nhibernate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RakeFile
260 lines (210 loc) · 7.92 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
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