iron_hammer 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ $hoe = Hoe.spec 'iron_hammer' do
14
14
  self.rubyforge_name = self.name
15
15
  self.extra_deps = [['rubyzip2','>= 2.0.1'],
16
16
  ['builder', '>= 2.1.2']]
17
- self.version = '1.0.4'
17
+ self.version = '1.0.5'
18
18
  end
19
19
 
20
20
  require 'newgem/tasks'
@@ -1,6 +1,8 @@
1
1
  require 'iron_hammer'
2
2
  require 'iron_hammer/utils/topological_sort'
3
3
 
4
+ CLEAN.include('Libraries/*')
5
+
4
6
  namespace :iron do
5
7
  namespace :ivy do
6
8
  def all_dependencies
@@ -43,7 +45,7 @@ namespace :iron do
43
45
  end
44
46
 
45
47
  desc 'Generates ivy-<project_name>.xml for all projects of the solution'
46
- task :generate => :update_version do
48
+ task :generate do
47
49
  puts "Generating ivy files for projects"
48
50
  @anvil.projects.each do |project|
49
51
  builder = IvyBuilder.new project
@@ -51,18 +53,6 @@ namespace :iron do
51
53
  end
52
54
  end
53
55
 
54
- desc 'updates version of AssemblyInfo based on build_number environment variable'
55
- task :update_version do
56
- @anvil.projects.each do |project|
57
- old_version = project.version
58
- project.version = old_version.gsub /\.\d+$/, ".#{build_number}"
59
- end
60
- end
61
-
62
- def build_number
63
- ENV['BUILD_NUMBER'] || '0'
64
- end
65
-
66
56
  desc 'Retrieves all project dependencies from ivy repository and modify project csproj to reference them'
67
57
  task :retrieve do
68
58
  builder = IvyBuilder.new(SolutionProject.new(@anvil.solution.name, all_dependencies))
@@ -0,0 +1,113 @@
1
+ class ProjectVersion
2
+ include Comparable
3
+
4
+ attr_accessor :major
5
+ attr_accessor :minor
6
+ attr_accessor :revision
7
+ attr_accessor :build
8
+
9
+ def self.parse v
10
+ splitted = v.split '.'
11
+ version = ProjectVersion.new
12
+ version.major = splitted[0].to_i
13
+ version.minor = splitted[1].to_i
14
+ version.revision = splitted[2].to_i
15
+ version.build = splitted[3].to_i
16
+ version
17
+ end
18
+
19
+ def <=> other
20
+ return @major <=> other.major unless @major == other.major
21
+ return @minor <=> other.minor unless @minor == other.minor
22
+ return @revision <=> other.revision unless @revision == other.revision
23
+ return @build <=> other.build
24
+ end
25
+
26
+ def self.greatest_from projects
27
+ greatest = parse '1.0.0.0'
28
+ @anvil.projects.each do |project|
29
+ current = parse project.version
30
+ greatest = current if current > greatest
31
+ end
32
+ greatest
33
+ end
34
+
35
+ def to_s
36
+ "#{@major}.#{@minor}.#{@revision}.#{@build}"
37
+ end
38
+ end
39
+
40
+ namespace :iron do
41
+ namespace :version do
42
+ desc 'back to 1.0.0.*'
43
+ task :reset do
44
+ @anvil.projects.each do |project|
45
+ old_version = ProjectVersion.parse project.version
46
+ old_version.major = 1
47
+ old_version.minor = 0
48
+ old_version.revision = 0
49
+ project.version = v.to_s
50
+ end
51
+ end
52
+
53
+ desc 'changes a reference to a dll in all csprojs to a version'
54
+ task :change_to, :reference, :version do |t, args|
55
+ Dir['*/*.csproj'].each do |arg|
56
+ f = File.open(arg)
57
+ working_file = f.read
58
+ working_file.gsub!(/Include=(\"|\')#{args.reference}, Version=\d+\.\d+\.\d+\.\d+,/, "Include=\\1#{args.reference}, Version=#{args.version},")
59
+ f = File.new(arg, "w")
60
+ f.print(working_file)
61
+ f.close
62
+ end
63
+ end
64
+
65
+ desc 'updates version of AssemblyInfo based on BUILD_NUMBER environment variable'
66
+ task :update_build do
67
+ @anvil.projects.each do |project|
68
+ old_version = project.version
69
+ project.version = old_version.gsub /\.\d+$/, ".#{build_number}"
70
+ end
71
+ end
72
+
73
+ def build_number
74
+ ENV['BUILD_NUMBER'] || '0'
75
+ end
76
+
77
+ namespace :bump do
78
+ desc 'bumps the major version'
79
+ task :major do
80
+ old_version = ProjectVersion.greatest_from @anvil.projects
81
+ old_version.major += 1
82
+ old_version.minor = 0
83
+ old_version.revision = 0
84
+
85
+ @anvil.projects.each do |project|
86
+ project.version = old_version.to_s
87
+ end
88
+ end
89
+
90
+ desc 'bumps the minor version'
91
+ task :minor do
92
+ old_version = ProjectVersion.greatest_from @anvil.projects
93
+ old_version.minor += 1
94
+ old_version.revision = 0
95
+
96
+ @anvil.projects.each do |project|
97
+ project.version = old_version.to_s
98
+ end
99
+ end
100
+
101
+ desc 'bumps the revision version'
102
+ task :revision do
103
+ old_version = ProjectVersion.greatest_from @anvil.projects
104
+ old_version.revision += 1
105
+
106
+ @anvil.projects.each do |project|
107
+ project.version = old_version.to_s
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+
@@ -8,18 +8,24 @@ CLEAN.include("ivy*.xml")
8
8
  require 'iron_hammer/tasks/analyze'
9
9
  require 'iron_hammer/tasks/ivy'
10
10
  require 'iron_hammer/tasks/test'
11
+ require 'iron_hammer/tasks/version'
11
12
 
12
13
  namespace :iron do
13
14
 
14
15
  @anvil = Anvil.load_from(ENV['SolutionDir'] || '.')
15
- @hammer = Hammer.new(
16
- (defined?(VISUAL_STUDIO_PATH) ? {:visual_studio_path => VISUAL_STUDIO_PATH} : {}).merge(
17
- :configuration => ENV['Configuration']
18
- ))
16
+
17
+ @options = {}
18
+ @options[:visual_studio_path] = VISUAL_STUDIO_PATH if defined?(VISUAL_STUDIO_PATH)
19
+ @options[:dot_net_path] = DOT_NET_PATH if defined?(DOT_NET_PATH)
20
+ @options[:fxcop_path] = FXCOP_PATH if defined?(FXCOP_PATH)
21
+ @options[:configuration] = ENV['Configuration']
22
+
23
+ @hammer = Hammer.new @options
24
+
19
25
  FileUtils.mkdir 'TestResults' unless (File.exists?('TestResults') && File.directory?('TestResults'))
20
26
 
21
27
  desc 'Executes the default lifecycle'
22
- task :default => [:clean, "ivy:retrieve", "ivy:update_version", :build, "test:unit", "ivy:publish"]
28
+ task :default => [:clean, "ivy:retrieve", "version:update_build", :build, "test:unit", "ivy:publish"]
23
29
 
24
30
  desc 'Builds the solution'
25
31
  task :build => [:clean] do
@@ -45,7 +45,7 @@ module IronHammer
45
45
  "java -jar #{@ivy_jar}
46
46
  -ivy #{ivy_file}
47
47
  -settings #{@ivy_settings}
48
- -retrieve Libraries/[artifact].[ext]".gsub(/\s+/, ' ')
48
+ -retrieve Libraries/[artifact]-[revision].[ext]".gsub(/\s+/, ' ')
49
49
  end
50
50
 
51
51
  def publish ivy_file
@@ -67,9 +67,15 @@ module IronHammer
67
67
  doc = REXML::Document.new xml
68
68
  references = doc.get_elements(ProjectFile::REFERENCE_PATH)
69
69
  references.each do |reference|
70
+ artifact = artifact_for reference
71
+ artifact.scan(/-(.*)\.(dll|exe)/) do |version, extension|
72
+ includes = reference.attribute('Include').value
73
+ includes.gsub!(/Version=(.*?)(,|$)/, "Version=#{version}\\2")
74
+ reference.add_attribute('Include', includes)
75
+ end
70
76
  reference.elements['SpecificVersion'] = REXML::Element.new('SpecificVersion').add_text('false')
71
77
  reference.elements['HintPath'] = REXML::Element.new('HintPath').
72
- add_text([relative, 'Libraries', "#{artifact_for reference}"].flatten.patheticalize)
78
+ add_text([relative, 'Libraries', "#{artifact}"].flatten.patheticalize)
73
79
  end
74
80
 
75
81
  FileSystem.write! :path => @project.path, :name => @project.csproj, :content => doc.to_s
@@ -83,7 +89,7 @@ module IronHammer
83
89
  def artifact_for reference
84
90
  dependency = Dependency.from_reference reference
85
91
  libraries_dir = Dir.new('Libraries')
86
- libraries_dir.find {|f| f.match "^#{dependency.name}\\.(dll|exe)"}
92
+ libraries_dir.find {|f| f.match "^#{dependency.name}-(.*)\\.(dll|exe)"}
87
93
  end
88
94
  end
89
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mozair Alves do Carmo Junior
@@ -106,6 +106,7 @@ files:
106
106
  - lib/iron_hammer/tasks/analyze.rb
107
107
  - lib/iron_hammer/tasks/ivy.rb
108
108
  - lib/iron_hammer/tasks/test.rb
109
+ - lib/iron_hammer/tasks/version.rb
109
110
  - lib/iron_hammer/utils/code_analyzers_environment.rb
110
111
  - lib/iron_hammer/utils/dot_net_environment.rb
111
112
  - lib/iron_hammer/utils/file_system.rb