Class: RakeDotNet::RDNPackageTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/rake_dotnet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params = {}) {|_self| ... } ⇒ RDNPackageTask

Returns a new instance of RDNPackageTask.

Yields:

  • (_self)

Yield Parameters:



974
975
976
977
978
979
980
981
982
983
984
985
# File 'lib/rake_dotnet.rb', line 974

def initialize(name, params={})
	@name = name
	@out_dir = params[:out_dir] || OUT_DIR
	@deps = params[:deps] || []
	@configuration = params[:configuration] || CONFIGURATION
	globs = params[:globs] || []
	@targets = FileList.new globs
	@add_to_main_task = params[:add_to_main_task] || true

	yield self if block_given?
	define
end

Instance Attribute Details

#targetsObject

Returns the value of attribute targets.



972
973
974
# File 'lib/rake_dotnet.rb', line 972

def targets
  @targets
end

Instance Method Details

#defineObject



987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/rake_dotnet.rb', line 987

def define
	out_pkg = File.join(@out_dir, 'pkg')
	out_pkg_name = File.join(out_pkg, @name)

	directory out_pkg
	directory out_pkg_name

	@deps.each do |d|
		task :package => d if @add_to_main_task
	end

	out_pkg_name_regex = RakeDotNet::regexify(out_pkg_name)

	rule(/#{out_pkg_name_regex}-#{@configuration}-v\d+\.\d+\.\d+\.\d+\.zip/) do |r|
		file_name = r.name.match(/(#{out_pkg_name_regex}).*/)[1].sub(out_pkg, '').sub('/','')
		version = r.name.match(/.*v(\d+\.\d+\.\d+\.\d+)\.zip/)[1]
		run_package(out_pkg, file_name, version)
	end

	directory @out_dir

	if @add_to_main_task
		desc "Generate zip'd packages for all package-tasks"
		task :package => [@out_dir, out_pkg, out_pkg_name] do
			version = Versioner.new.get
			Rake::Task["#{out_pkg_name}-#{@configuration}-v#{version}.zip"].invoke
		end
	end

	desc "Generate zip'd package for #{@name}"
	task "package_#{@name}".to_sym => [@out_dir, out_pkg, out_pkg_name] do
		version = Versioner.new.get
		Rake::Task["#{out_pkg_name}-#{@configuration}-v#{version}.zip"].invoke
	end

	desc "Delete all packages"
	task :clobber_package do
		rm_rf out_pkg
	end

	task :clobber => :clobber_package

	desc "Delete all packages and recreate them"
	task :repackage => [:clobber_package, :package]

	self
end

#run_package(root_dir, package_name, version) ⇒ Object



1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
# File 'lib/rake_dotnet.rb', line 1035

def run_package(root_dir, package_name, version)
	assembly_dir = File.join(root_dir, package_name)
	mkdir_p assembly_dir
	@targets.each do |t|
		f = Pathname.new(t)
		if f.directory?
			cp_r f, File.join(assembly_dir, "#{f.basename}-#{@configuration}-v#{version}")
		else
			cp f, assembly_dir
		end
	end
	versioned_assembly_dir = File.join(root_dir, "#{package_name}-#{@configuration}-v#{version}")
	mv assembly_dir, versioned_assembly_dir
	vzip = versioned_assembly_dir + '.zip'
	sz = SevenZipCmd.new(vzip)
	chdir versioned_assembly_dir do
		sz.run_add
	end
end