Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rewrote rakefile to use Albacore

Anyone using the rakefile to build will need to re-run InstallGems.bat to get the Albacore gem.
  • Loading branch information...
commit 189746cb76760385b32ebdd8fea9ea377a8200bf 1 parent ad70399
@jagregory jagregory authored
View
72 AlbacoreExtensions.rb
@@ -0,0 +1,72 @@
+require 'albacore'
+require 'albacore/support/albacore_helper'
+require 'rake/tasklib'
+
+# zip task modification - allow exclusions
+class ZipDirectory
+ attr_accessor :exclusions
+
+ def reject_file(f)
+ f == zip_name || is_excluded(f)
+ end
+
+ private
+ def is_excluded(f)
+ (@exclusions || []).any? do |e|
+ return true if e.respond_to? '~' and f =~ e
+ e == f
+ end
+ end
+end
+
+# docu task - remove once in Albacore master
+
+class Docu
+ include RunCommand
+
+ attr_accessor :path_to_command, :assemblies, :xml_files, :output_location
+
+ def initialize(path_to_command='docu.exe')
+ super()
+ @path_to_command = path_to_command
+ @assemblies = []
+ @xml_files = []
+ @output_location = ""
+ end
+
+ def execute
+ if @assemblies.empty?
+ fail_with_message 'Docu Failed. No assemblies specified'
+ return
+ end
+
+ command_params = get_command_parameters
+ success = run_command 'Docu', command_params.join(' ')
+
+ fail_with_message 'Docu Failed. See Build Log For Detail' unless success
+ end
+
+ private
+ def get_command_parameters
+ command_params = []
+ command_params << @assemblies.join(' ') unless @assemblies.nil?
+ command_params << @xml_files.join(' ') unless @xml_files.nil?
+ command_params << " --output=\"#{@output_location}\" " unless @output_location.empty?
+ command_params
+ end
+end
+
+def docu(name=:docu, *args, &block)
+ Albacore::DocuTask.new(name, *args, &block)
+end
+
+module Albacore
+ class DocuTask < Albacore::AlbacoreTask
+ def execute(task_args)
+ @docu = Docu.new
+ @block.call(@docu, *task_args) unless @block.nil?
+ @docu.execute
+ fail if @docu.failed
+ end
+ end
+end
View
135 BuildUtils.rb
@@ -1,135 +0,0 @@
-require 'rubygems'
-
-require 'erb'
-require 'activesupport'
-require 'find'
-require 'zip/zip'
-require 'fileutils'
-
-class NUnitRunner
- include FileTest
-
- def initialize(paths)
- @sourceDir = paths.fetch(:source, 'source')
- @resultsDir = paths.fetch(:results, 'results')
- @compilePlatform = paths.fetch(:platform, 'x86')
- @compileTarget = paths.fetch(:compilemode, 'debug')
-
- if ENV["teamcity.dotnet.nunitlauncher"] # check if we are running in TeamCity
- # We are not using the TeamCity nunit launcher. We use NUnit with the TeamCity NUnit Addin which needs tO be copied to our NUnit addins folder
- # http://blogs.jetbrains.com/teamcity/2008/07/28/unfolding-teamcity-addin-for-nunit-secrets/
- # The teamcity.dotnet.nunitaddin environment variable is not available until TeamCity 4.0, so we hardcode it for now
- @teamCityAddinPath = ENV["teamcity.dotnet.nunitaddin"] ? ENV["teamcity.dotnet.nunitaddin"] : 'c:/TeamCity/buildAgent/plugins/dotnetPlugin/bin/JetBrains.TeamCity.NUnitAddin-NUnit'
- cp @teamCityAddinPath + '-2.4.7.dll', 'tools/nunit/addins'
- end
-
- @nunitExe = File.join('tools', 'nunit', "nunit-console#{(@compilePlatform.nil? ? '' : "-#{@compilePlatform}")}.exe").gsub('/','\\') + ' /nothread'
- end
-
- def executeTests(assemblies)
- Dir.mkdir @resultsDir unless exists?(@resultsDir)
-
- assemblies.each do |assem|
- file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{(@compilePlatform.nil? ? '' : "#{@compilePlatform}/")}#{@compileTarget}/#{assem}.dll")
- sh "#{@nunitExe} \"#{file}\""
- end
- end
-end
-
-class MSBuildRunner
- def self.compile(attributes)
- version = attributes.fetch(:clrversion, 'v3.5')
- compileTarget = attributes.fetch(:compilemode, 'debug')
- solutionFile = attributes[:solutionfile]
-
- frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
- msbuildFile = File.join(frameworkDir, 'msbuild.exe')
-
- sh "#{msbuildFile} #{solutionFile} /maxcpucount /v:m /property:BuildInParallel=false /property:Configuration=#{compileTarget} /t:Rebuild"
- end
-end
-
-class AspNetCompilerRunner
- def self.compile(attributes)
-
- webPhysDir = attributes.fetch(:webPhysDir, '')
- webVirDir = attributes.fetch(:webVirDir, '')
-
- frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', 'v2.0.50727')
- aspNetCompiler = File.join(frameworkDir, 'aspnet_compiler.exe')
-
- sh "#{aspNetCompiler} -p #{webPhysDir} -v #{webVirDir}"
- end
-end
-
-class AsmInfoBuilder
- attr_reader :buildnumber, :parameterless_attributes
-
- def initialize(version, properties)
- @properties = properties
- @buildnumber = version
- @properties['Version'] = @properties['InformationalVersion'] = buildnumber;
- @parameterless_attributes = [:allow_partially_trusted_callers]
- end
-
- def write(file)
- template = %q{using System.Reflection;
-using System.Security;
-
-<% @properties.each do |k, v| %>
-<% if @parameterless_attributes.include? k %>
-[assembly: <%= k.to_s.camelize %>]
-<% else %>
-[assembly: Assembly<%= k.to_s.camelize %>("<%= v %>")]
-<% end %>
-<% end %>
- }.gsub(/^ /, '')
-
- erb = ERB.new(template, 0, "%<>")
-
- File.open(file, 'w') do |file|
- file.puts erb.result(binding)
- end
- end
-end
-
-class InstallUtilRunner
- def installServices(services, parameters)
- services.each do |service|
- params = ""
- parameters.each_pair {|key, value| params = params + "/" + key + "=" + value + " "}
- sh "tools/installutil /i #{params} #{service}"
- end
- end
-
- def uninstallServices(services)
- services.each do |service|
- begin
- sh "tools/installutil /u #{service}"
- rescue Exception => e
- puts 'IGNORING ERROR: ' + e
- end
- end
- end
-
-end
-
-def create_zip(filename, root, excludes=/^$/)
- File.delete(filename) if File.exists? filename
- Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zip|
- Find.find(root) do |path|
- next if path =~ excludes
-
- zip_path = path.gsub(root, '')
- zip.add(zip_path, path)
- end
- end
-end
-
-def docu(dll_name)
- FileUtils.rm_r('output') if File.exists? 'output'
-
- docu_exe = "tools/docu/docu.exe"
-
- `#{docu_exe} #{dll_name}`
-end
View
16 InstallGems.bat
@@ -1,11 +1,11 @@
-@ECHO *** Installing Rake
-@call gem install rake --include-dependencies
+@echo off
-@ECHO *** Installing ActiveRecord
-@call gem install activerecord --include-dependencies
+echo Setting up rake environment for building
-@ECHO *** Installing RubyZip
-@call gem install rubyzip --include-dependencies
+echo Installing Rake
+call gem install rake
-@ECHO *** Installing Rails
-@call gem install rails --include-dependencies
+call rake setup:ensure_gemcutter_source
+
+echo Installing Albacore
+call gem install albacore
View
268 RakeFile
@@ -1,223 +1,115 @@
-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
+require 'albacore'
+require 'AlbacoreExtensions.rb'
def get_version
- return ENV['BUILD_NUMBER'].to_s unless ENV['BUILD_NUMBER'].nil?
- return "1.0.0.0"
+ ENV['BUILD_NUMBER'] || '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
+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
- 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
+namespace :ci do
+ task :run_ci_build => [
+ 'build:all',
+ 'docs:build',
+ 'package:all',
+ ]
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}"
+namespace :source do
+ desc 'Update assembly info with latest version number'
+ assemblyinfotask :update_version do |asm|
+ asm.output_file = 'src/CommonAssemblyInfo.cs'
- 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()
+ asm.version = get_version
+ asm.company_name = 'http://fluentnhibernate.org'
+ asm.product_name = 'FluentNHibernate'
+ asm.copyright = 'Copyright 2008-2009 James Gregory and contributors (Paul Batum, Andrew Stewart, Hudson Akridge, Stuart Childs et al). All rights reserved.'
+ asm.namespaces = ['System.Security']
+ asm.custom_attributes :AllowPartiallyTrustedCallers => nil
+
+ puts "The build number is #{asm.version}"
+ end
- create_zip("#{DIST_DIR}/fluentnhibernate-source-#{version}.zip", './', /.git|build|dist|results|_ReSharper|bin|obj|.user|.suo|.resharper|.cache/)
+ desc 'Compile the source'
+ msbuildtask :compile do |msb|
+ msb.properties = { :configuration => :Release }
+ msb.targets [:Clean, :Build]
+ msb.solution = 'src/FluentNHibernate.sln'
+ end
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/')
+namespace :specs do
+ desc 'Run NUnit tests'
+ nunittask :run do |nunit|
+ nunit.path_to_command = 'tools/nunit/nunit-console-x86.exe'
+ nunit.assemblies << 'src/FluentNHibernate.Testing/bin/Release/FluentNHibernate.Testing.dll'
+ end
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")
+namespace :build do
+ desc 'Run full build including tests'
+ task :all => ['source:update_version', 'source:compile', 'specs:run'] 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
-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/')
+namespace :docs do
+ desc 'Create API docs'
+ docu :build do |d|
+ d.path_to_command = 'tools/docu/docu.exe'
+ d.assemblies << 'build/FluentNHibernate.dll'
+ end
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(' ')
+namespace :package do
+ task :prepare_dist_directory do
+ Dir.mkdir 'dist' unless File.exists? 'dist'
end
- def get_categories
- escape(@categories).join(',')
+ desc 'Create zip of source-tree'
+ ziptask :source => :prepare_dist_directory do |zip|
+ zip.directories_to_zip = ['./']
+ zip.output_file = "fluentnhibernate-source-#{get_version}.zip"
+ zip.output_path = 'dist'
+ zip.exclusions = [/.git/, /build/, /dist/, /results/, /_ReSharper/, /bin/, /obj/, /.user/, /.suo/, /.resharper/, /.cache/, /output/]
end
- def escape(array)
- array.map { |i| "\"#{i}\"" }
+ desc 'Create zip of binaries'
+ ziptask :binaries => :prepare_dist_directory do |zip|
+ zip.directories_to_zip = ['build']
+ zip.output_file = "fluentnhibernate-binary-#{get_version}.zip"
+ zip.output_path = 'dist'
end
- def ncover_concat(array)
- array.join(';')
+ desc 'Create zip of API docs'
+ ziptask :docs => :prepare_dist_directory do |zip|
+ zip.directories_to_zip = ['output']
+ zip.output_file = "fluentnhibernate-docs-#{get_version}.zip"
+ zip.output_path = 'dist'
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
+ task :all => [:source, :binaries, :docs]
end
-desc "Open solution in VS"
task :sln do
Thread.new do
system "devenv src/FluentNHibernate.sln"
end
-end
+end
View
6 src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F5DC3221-827E-4CB4-B61C-5F50EB4D32EA}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -17,14 +17,14 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
- <OutputPath>bin\x86\Debug\</OutputPath>
+ <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <OutputPath>bin\x86\Release\</OutputPath>
+ <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
Please sign in to comment.
Something went wrong with that request. Please try again.