iron_hammer 1.0.3 → 1.0.4

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.3'
17
+ self.version = '1.0.4'
18
18
  end
19
19
 
20
20
  require 'newgem/tasks'
@@ -45,7 +45,9 @@ module IronHammer
45
45
  return if projects.nil? || projects.empty?
46
46
  fxcop = @code_analyzers_environment.fxcop
47
47
  rules = @code_analyzers_environment.fxcop_rules
48
- binaries = projects.collect {|project| "/file:#{project.path_to_binaries}"}
48
+ binaries = projects.collect do |project|
49
+ project.artifacts.map {|artifact| "/file:#{File.join(project.path_to_binaries, artifact)}"}
50
+ end.flatten
49
51
  results = @code_analyzers_environment.fxcop_result
50
52
  "\"#{fxcop}\" /rule:\"#{rules}\" /out:\"#{results}\" #{binaries.join ' '}"
51
53
  end
@@ -12,11 +12,11 @@ module IronHammer
12
12
  end
13
13
 
14
14
  def == other
15
- @name == other.name && @version == other.version
15
+ @name == other.name && @version == other.version && @extension == other.extension
16
16
  end
17
17
 
18
18
  def to_s
19
- "[Dependency name=#{@name} version=#{@version}]"
19
+ "[Dependency name=#{@name} version=#{@version} extension=#{@extension}]"
20
20
  end
21
21
 
22
22
  def self.from_reference reference
@@ -29,6 +29,10 @@ module IronHammer
29
29
  Dependency.new :name => name, :version => version, :extension => extension
30
30
  end
31
31
 
32
+ def self.from_project project
33
+ Dependency.new :name => project.assembly_name, :version => project.version,
34
+ :extension => project.artifacts.first.split('.').last
35
+ end
32
36
  private
33
37
  def self.get_extension reference
34
38
  hint_path = reference.elements["HintPath"]
@@ -9,14 +9,15 @@ module IronHammer
9
9
  include IronHammer::DefaultBinariesBehavior
10
10
  include IronHammer::DefaultConfigurationBehavior
11
11
  include IronHammer::DefaultDeliverablesBehavior
12
-
12
+
13
13
  def path_to_configuration
14
14
  @path
15
15
  end
16
-
16
+
17
17
  def path_to_binaries params={}
18
18
  File.join(@path, 'bin', run_configuration(params))
19
19
  end
20
20
  end unless defined? DllProject
21
21
  end
22
22
  end
23
+
@@ -31,6 +31,12 @@ module IronHammer
31
31
  []
32
32
  end
33
33
 
34
+ def artifacts
35
+ Dir[File.join(path_to_binaries, "#{assembly_name}.{dll,exe}")].map do |file|
36
+ file.split(/\/|\\/).last
37
+ end
38
+ end
39
+
34
40
  def assembly_name
35
41
  @assembly_name ||= file.assembly_name
36
42
  end
@@ -43,6 +49,15 @@ module IronHammer
43
49
  @dependencies ||= file.dependencies
44
50
  end
45
51
 
52
+ def project_references
53
+ @project_references ||= file.project_dependencies
54
+ end
55
+
56
+ def dependencies_with_projects projects
57
+ selected = projects.select {|p| p.is_a?(DllProject) && project_references.include?(p.name)}
58
+ dependencies + selected.map {|p| Dependency.from_project p}
59
+ end
60
+
46
61
  def package params={}
47
62
  package_root(params)
48
63
  Package.new :root => package_root, :deliverables => deliverables(params)
@@ -16,6 +16,7 @@ module IronHammer
16
16
  GUID_PATH = '//Project/PropertyGroup/ProjectTypeGuids'
17
17
  ASSEMBLY_NAME_PATH = '//Project/PropertyGroup/AssemblyName'
18
18
  REFERENCE_PATH = '//Reference[not(starts_with(@Include, "System"))]'
19
+ PROJECT_REFERENCE_PATH = '//ProjectReference/Name'
19
20
 
20
21
  def self.load_from *path
21
22
  ProjectFile.new path
@@ -35,11 +36,19 @@ module IronHammer
35
36
  references.collect { |reference| Dependency.from_reference reference }
36
37
  end
37
38
 
39
+ def project_dependencies
40
+ project_references.collect { |name| name.text }
41
+ end
42
+
38
43
  private
39
44
  def references
40
45
  doc && doc.get_elements(REFERENCE_PATH)
41
46
  end
42
47
 
48
+ def project_references
49
+ doc && doc.get_elements(PROJECT_REFERENCE_PATH)
50
+ end
51
+
43
52
  def doc
44
53
  @doc ||= REXML::Document.new xml
45
54
  end
@@ -0,0 +1,12 @@
1
+
2
+ namespace :iron do
3
+ namespace :analyze do
4
+ desc 'Analyzes the code using fxcop'
5
+ task :fxcop do
6
+ sh @hammer.analyze *@anvil.projects do |ok, response|
7
+ puts response
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,95 @@
1
+ require 'iron_hammer'
2
+ require 'iron_hammer/utils/topological_sort'
3
+
4
+ namespace :iron do
5
+ namespace :ivy do
6
+ def all_dependencies
7
+ unless @all_dependencies
8
+ @all_dependencies = []
9
+ @anvil.projects.each do |project|
10
+ project.dependencies.each do |dependency|
11
+ @all_dependencies << dependency unless @all_dependencies.include? dependency
12
+ end
13
+ end
14
+ end
15
+ @all_dependencies
16
+ end
17
+
18
+ desc 'Publishes project dependencies into ivy repository'
19
+ task :setup, [:binaries_path] do |t, args|
20
+
21
+ files = Dir.new(args.binaries_path).entries
22
+ candidates = all_dependencies.select {|x| files.include? "#{x.name}.#{x.extension}"}
23
+
24
+ candidates.each do |dependency|
25
+ sh "java -jar #{IVY_JAR} -settings #{IVY_SETTINGS} -dependency #{ORGANISATION} #{dependency.name} #{dependency.version}" do |ok, res|
26
+ unless res.exitstatus == 0
27
+ dependency_project = DependencyProject.new(
28
+ :name => dependency.name,
29
+ :binaries_path => args.binaries_path,
30
+ :version => dependency.version,
31
+ :extension => dependency.extension)
32
+
33
+ puts "Dependency #{dependency.name}"
34
+
35
+ builder = IvyBuilder.new dependency_project
36
+
37
+ builder.write_to "ivy-#{dependency.name}.xml"
38
+
39
+ sh builder.publish "ivy-#{dependency.name}.xml"
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ desc 'Generates ivy-<project_name>.xml for all projects of the solution'
46
+ task :generate => :update_version do
47
+ puts "Generating ivy files for projects"
48
+ @anvil.projects.each do |project|
49
+ builder = IvyBuilder.new project
50
+ builder.write_to "ivy-#{project.name}.xml"
51
+ end
52
+ end
53
+
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
+ desc 'Retrieves all project dependencies from ivy repository and modify project csproj to reference them'
67
+ task :retrieve do
68
+ builder = IvyBuilder.new(SolutionProject.new(@anvil.solution.name, all_dependencies))
69
+ xml = "ivy-#{@anvil.solution.name}.xml"
70
+ builder.write_to xml
71
+
72
+ sh builder.retrieve xml
73
+
74
+ @anvil.projects.each do |project|
75
+ builder = IvyBuilder.new project
76
+
77
+ builder.modify_csproj
78
+ end
79
+ end
80
+
81
+ desc 'Publishes project assemblies to ivy repository (only dll projects)'
82
+ task :publish => [:generate] do
83
+ @anvil.dll_projects.topological_sort.each do |project|
84
+ xml = "ivy-#{project.name}.xml"
85
+ builder = IvyBuilder.new project
86
+
87
+ FileSystem.write! :name => xml, :path => '.',
88
+ :content => builder.generate_xml(project.dependencies_with_projects @anvil.projects)
89
+
90
+ sh builder.publish xml
91
+ end
92
+ end
93
+ end
94
+ end
95
+
@@ -0,0 +1,20 @@
1
+
2
+ namespace :iron do
3
+ namespace :test do
4
+
5
+ desc 'Runs the unit tests'
6
+ task :unit => [:build] do
7
+ command = @hammer.test *@anvil.unit_test_projects
8
+ puts "There are no unit tests to run" unless command
9
+ sh command if command
10
+ end
11
+
12
+ desc 'Runs the integration tests'
13
+ task :integration => [:build] do
14
+ command = @hammer.test *@anvil.integration_test_projects
15
+ puts "There are no integration tests to run" unless command
16
+ sh command if command
17
+ end
18
+ end
19
+ end
20
+
@@ -5,6 +5,9 @@ require 'iron_hammer'
5
5
  CLEAN.include("TestResults/**")
6
6
  CLEAN.include("ivy*.xml")
7
7
 
8
+ require 'iron_hammer/tasks/analyze'
9
+ require 'iron_hammer/tasks/ivy'
10
+ require 'iron_hammer/tasks/test'
8
11
 
9
12
  namespace :iron do
10
13
 
@@ -16,124 +19,12 @@ namespace :iron do
16
19
  FileUtils.mkdir 'TestResults' unless (File.exists?('TestResults') && File.directory?('TestResults'))
17
20
 
18
21
  desc 'Executes the default lifecycle'
19
- task :default => [:clean, "ivy:retrieve", :build, "test:unit", "ivy:publish"]
22
+ task :default => [:clean, "ivy:retrieve", "ivy:update_version", :build, "test:unit", "ivy:publish"]
20
23
 
21
24
  desc 'Builds the solution'
22
25
  task :build => [:clean] do
23
26
  sh @hammer.build @anvil.solution
24
27
  end
25
28
 
26
- namespace :test do
27
-
28
- desc 'Runs the unit tests'
29
- task :unit => [:build] do
30
- command = @hammer.test *@anvil.unit_test_projects
31
- puts "There are no unit tests to run" unless command
32
- sh command if command
33
- end
34
-
35
- desc 'Runs the integration tests'
36
- task :integration => [:build] do
37
- command = @hammer.test *@anvil.integration_test_projects
38
- puts "There are no integration tests to run" unless command
39
- sh command if command
40
- end
41
- end
42
-
43
- namespace :analyze do
44
- desc 'Analyzes the code using fxcop'
45
- task :fxcop do
46
- sh @hammer.analyze *@anvil.projects do |ok, response|
47
- puts response
48
- end
49
- end
50
- end
51
-
52
- namespace :ivy do
53
- def all_dependencies
54
- unless @all_dependencies
55
- @all_dependencies = []
56
- @anvil.projects.each do |project|
57
- project.dependencies.each do |dependency|
58
- @all_dependencies << dependency unless @all_dependencies.include? dependency
59
- end
60
- end
61
- end
62
- @all_dependencies
63
- end
64
-
65
- desc 'Publishes project dependencies into ivy repository'
66
- task :setup, [:binaries_path] do |t, args|
67
-
68
- files = Dir.new(args.binaries_path).entries
69
- candidates = all_dependencies.select {|x| files.include? "#{x.name}.#{x.extension}"}
70
-
71
- candidates.each do |dependency|
72
- sh "java -jar #{IVY_JAR} -settings #{IVY_SETTINGS} -dependency #{ORGANISATION} #{dependency.name} #{dependency.version}" do |ok, res|
73
- unless res.exitstatus == 0
74
- dependency_project = DependencyProject.new(
75
- :name => dependency.name,
76
- :binaries_path => args.binaries_path,
77
- :version => dependency.version,
78
- :extension => dependency.extension)
79
-
80
- puts "Dependency #{dependency.name}"
81
-
82
- builder = IvyBuilder.new dependency_project
83
-
84
- builder.write_to "ivy-#{dependency.name}.xml"
85
-
86
- sh builder.publish "ivy-#{dependency.name}.xml"
87
- end
88
- end
89
- end
90
- end
91
-
92
- desc 'Generates ivy-<project_name>.xml for all projects of the solution'
93
- task :generate => :update_version do
94
- puts "Generating ivy files for projects"
95
- @anvil.projects.each do |project|
96
- builder = IvyBuilder.new project
97
- builder.write_to "ivy-#{project.name}.xml"
98
- end
99
- end
100
-
101
- desc 'updates version of AssemblyInfo based on build_number environment variable'
102
- task :update_version do
103
- @anvil.projects.each do |project|
104
- old_version = project.version
105
- project.version = old_version.gsub /\.\d+$/, ".#{build_number}"
106
- end
107
- end
108
-
109
- def build_number
110
- ENV['BUILD_NUMBER'] || '0'
111
- end
112
-
113
- desc 'Retrieves all project dependencies from ivy repository and modify project csproj to reference them'
114
- task :retrieve do
115
- builder = IvyBuilder.new(SolutionProject.new(@anvil.solution.name, all_dependencies))
116
- xml = "ivy-#{@anvil.solution.name}.xml"
117
- builder.write_to xml
118
-
119
- sh builder.retrieve xml
120
-
121
- @anvil.projects.each do |project|
122
- builder = IvyBuilder.new project
123
-
124
- builder.modify_csproj
125
- end
126
- end
127
-
128
- desc 'Publishes project assemblies to ivy repository (only dll projects)'
129
- task :publish => [:generate] do
130
- @anvil.dll_projects.each do |project|
131
- xml = "ivy-#{project.name}.xml"
132
- builder = IvyBuilder.new project
133
-
134
- sh builder.publish xml
135
- end
136
- end
137
- end
138
29
  end
139
30
 
@@ -13,24 +13,31 @@ module IronHammer
13
13
  end
14
14
 
15
15
  def to_s
16
+ generate_xml @project.dependencies
17
+ end
18
+
19
+ def generate_xml dependencies=[]
16
20
  xml = Builder::XmlMarkup.new(:indent => 2)
17
21
  xml.tag! 'ivy-module', :version => '2.0' do
18
22
  name = @project.assembly_name
19
23
  xml.info :organisation => @organisation, :module => name
20
24
  xml.publications do
21
- @project.binary_types.each do |btype|
22
- xml.artifact :name => name, :type => btype
25
+ @project.artifacts.each do |artifact|
26
+ names = artifact.split '.'
27
+ extension = names.pop
28
+ name = names.join '.'
29
+ xml.artifact :name => name, :type => extension
23
30
  end
24
31
  end if @project.is_a? DllProject
25
32
 
26
33
  xml.dependencies do
27
- @project.dependencies.each do |dependency|
34
+ dependencies.each do |dependency|
28
35
  rev = dependency.version.gsub /\.\d+$/, '.+'
29
36
  xml.dependency :org => @organisation, :name => dependency.name, :rev => rev do
30
37
  xml.artifact :type => dependency.extension, :name => dependency.name
31
38
  end
32
39
  end
33
- end unless @project.dependencies.empty?
40
+ end unless dependencies.empty?
34
41
  end
35
42
  end
36
43
 
@@ -0,0 +1,31 @@
1
+ class Array
2
+
3
+ def topological_sort
4
+ graph = {}
5
+ refs = {}
6
+ set = []
7
+ list = []
8
+ self.each {|e| set << e.name if e.project_references.empty?}
9
+ self.each {|e| graph[e.name] = []; refs[e.name] = []}
10
+ self.each do |e|
11
+ e.project_references.each do |r|
12
+ graph[r] << e.name if graph[r]
13
+ refs[e.name] << r if refs[e.name]
14
+ end
15
+ end
16
+
17
+ until set.empty?
18
+ n = set.pop
19
+ list << n
20
+ until graph[n].empty?
21
+ m = graph[n].pop
22
+ refs[m].delete n
23
+ set << m if refs[m].empty? && !set.include?(m)
24
+ end
25
+ end
26
+
27
+ list.map {|e| self.find {|p| p.name == e}}
28
+ end
29
+
30
+ end
31
+
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.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mozair Alves do Carmo Junior
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-11 00:00:00 -02:00
13
+ date: 2010-02-19 00:00:00 -02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -103,10 +103,14 @@ files:
103
103
  - lib/iron_hammer/solutions/solution.rb
104
104
  - lib/iron_hammer/solutions/solution_file.rb
105
105
  - lib/iron_hammer/tasks.rb
106
+ - lib/iron_hammer/tasks/analyze.rb
107
+ - lib/iron_hammer/tasks/ivy.rb
108
+ - lib/iron_hammer/tasks/test.rb
106
109
  - lib/iron_hammer/utils/code_analyzers_environment.rb
107
110
  - lib/iron_hammer/utils/dot_net_environment.rb
108
111
  - lib/iron_hammer/utils/file_system.rb
109
112
  - lib/iron_hammer/utils/ivy_builder.rb
113
+ - lib/iron_hammer/utils/topological_sort.rb
110
114
  - lib/iron_hammer/utils/windows.rb
111
115
  - lib/iron_hammer/utils/zipper.rb
112
116
  - lib/iron_hammer/version.rb