iron_hammer 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ $hoe = Hoe.spec 'iron_hammer' do
12
12
  self.rubyforge_name = self.name
13
13
  self.extra_deps = [['rubyzip2','>= 2.0.1'],
14
14
  ['builder', '>= 2.1.2']]
15
- self.version = '0.3.5'
15
+ self.version = '0.3.6'
16
16
  end
17
17
 
18
18
  require 'newgem/tasks'
@@ -21,3 +21,4 @@ Dir['tasks/**/*.rake'].each { |t| load t }
21
21
  # TODO - want other tests/tasks run by default? Add them to the list
22
22
  # remove_task :default
23
23
  # task :default => [:spec, :features]
24
+
@@ -3,19 +3,28 @@ module IronHammer
3
3
  class Dependency
4
4
  attr_accessor :name
5
5
  attr_accessor :version
6
-
6
+
7
7
  def initialize params = {}
8
8
  @name = params[:name] || raise(ArgumentError.new('you must specify a name'))
9
9
  @version = params[:version]
10
10
  end
11
-
11
+
12
12
  def == other
13
13
  @name == other.name && @version == other.version
14
14
  end
15
-
15
+
16
16
  def to_s
17
17
  "[Dependency name=#{@name} version=#{@version}]"
18
18
  end
19
+
20
+ def self.from_reference reference
21
+ includes = reference.attribute(:Include).value
22
+ name = includes.split(', ')[0]
23
+ match = includes.match /Version=(.+?),/
24
+ version = match[1] if match
25
+ Dependency.new :name => name, :version => version
26
+ end
19
27
  end
20
28
  end
21
29
  end
30
+
@@ -20,7 +20,7 @@ module IronHammer
20
20
  @type = params[:type] || DllProject
21
21
  raise ArgumentError.new('type must be a Class') unless @type.class == Class
22
22
  end
23
-
23
+
24
24
  def self.type_of *path
25
25
  self.parse(IronHammer::Utils::FileSystem::read_file(*path)).type
26
26
  end
@@ -31,24 +31,20 @@ module IronHammer
31
31
  result || (guids.include?(ProjectTypes::guid_for(current)) && current)
32
32
  end) || DllProject)
33
33
  end
34
-
34
+
35
35
  def self.guids_from xml
36
36
  doc = REXML::Document.new xml
37
37
  elem = doc && doc.elements[GUID_PATH]
38
38
  guids = ((elem && elem.text) || '').split(';').collect { |e| e.upcase }
39
39
  end
40
-
40
+
41
41
  def self.dependencies_of xml
42
42
  doc = REXML::Document.new xml
43
- references = doc && doc.get_elements(REFERENCE_PATH)
43
+ references = doc && doc.get_elements(REFERENCE_PATH)
44
44
  references.map do |reference|
45
- includes = reference.attribute(:Include).value
46
- name = includes.split(', ')[0]
47
- match = includes.match /Version=(.+?),/
48
- version = match[1] if match
49
- Dependency.new :name => name, :version => version
45
+ Dependency.from_reference reference
50
46
  end
51
-
47
+
52
48
  end
53
49
  end unless defined? ProjectFile
54
50
  end
@@ -16,14 +16,14 @@ namespace :iron do
16
16
  task :build => [:clean, :initialize] do
17
17
  sh @hammer.build @anvil.solution
18
18
  end
19
-
19
+
20
20
  namespace :test do
21
21
  desc 'Runs the unit tests'
22
22
  task :unit => [:build] do
23
23
  sh @hammer.test *@anvil.test_projects
24
24
  end
25
25
  end
26
-
26
+
27
27
  namespace :ivy do
28
28
  desc 'Generates ivy-<project_name>.xml for all dll projects of the solution'
29
29
  task :generate => [:initialize] do
@@ -32,18 +32,26 @@ namespace :iron do
32
32
  builder.write_to "ivy-#{project.name}.xml"
33
33
  end
34
34
  end
35
-
35
+
36
+ desc 'Retrieves all project dependencies from ivy repository and modify project csproj to reference them'
36
37
  task :retrieve => [:generate] do
37
38
  @anvil.dll_projects.each do |project|
38
- ivy = "ivy-#{project.name}.xml"
39
- sh "java -jar #{IVY_JAR} -ivy #{ivy} -settings #{IVY_SETTINGS} -retrieve Libraries/[artifact].[ext]"
39
+ xml = "ivy-#{project.name}.xml"
40
+ builder = IvyBuilder.new project
41
+
42
+ sh builder.retrieve xml
43
+
44
+ builder.modify_csproj
40
45
  end
41
46
  end
42
-
47
+
48
+ desc 'Publish project assemblies to ivy repository'
43
49
  task :publish => [:generate] do
44
50
  @anvil.dll_projects.each do |project|
45
- ivy = "ivy-#{project.name}.xml"
46
- sh "java -jar #{IVY_JAR} -ivy #{ivy} -settings #{IVY_SETTINGS} -publish default -publishpattern delivery/[artifact].[ext] -revision 1.0.0 -overwrite true"
51
+ xml = "ivy-#{project.name}.xml"
52
+ builder = IvyBuilder.new project
53
+
54
+ sh builder.retrieve xml
47
55
  end
48
56
  end
49
57
  end
@@ -1,13 +1,16 @@
1
1
  require 'builder'
2
+ require 'rexml/document'
2
3
  module IronHammer
3
4
  module Utils
4
5
  class IvyBuilder
5
-
6
+
6
7
  def initialize project
7
8
  @project = project
8
- @organisation = ORGANISATION || "org"
9
- end
10
-
9
+ @organisation = defined?(ORGANISATION)? ORGANISATION : 'org'
10
+ @ivy_jar = defined?(IVY_JAR)? IVY_JAR : 'ivy.jar'
11
+ @ivy_settings = defined?(IVY_SETTINGS)? IVY_SETTINGS : 'ivysettings.xml'
12
+ end
13
+
11
14
  def to_s
12
15
  xml = Builder::XmlMarkup.new(:indent => 2)
13
16
  xml.tag! 'ivy-module', :version => '2.0' do
@@ -15,7 +18,7 @@ module IronHammer
15
18
  xml.publications do
16
19
  xml.artifact :name => @project.name, :type => 'dll'
17
20
  end if @project.is_a? DllProject
18
-
21
+
19
22
  xml.dependencies do
20
23
  @project.dependencies.each do |dependency|
21
24
  xml.dependency :org => @organisation, :name => dependency.name, :rev => dependency.version
@@ -23,10 +26,48 @@ module IronHammer
23
26
  end unless @project.dependencies.empty?
24
27
  end
25
28
  end
26
-
29
+
30
+ def retrieve ivy_file
31
+ "java -jar #{@ivy_jar}
32
+ -ivy #{ivy_file}
33
+ -settings #{@ivy_settings}
34
+ -retrieve Libraries/[artifact].[ext]".gsub(/\s+/, ' ')
35
+ end
36
+
37
+ def publish ivy_file
38
+ "java -jar #{@ivy_jar}
39
+ -ivy #{ivy_file}
40
+ -settings #{@ivy_settings}
41
+ -publish default
42
+ -publishpattern delivery/[artifact].[ext]
43
+ -revision 1.0.0.0
44
+ -overwrite true".gsub(/\s+/, ' ')
45
+ end
46
+
27
47
  def write_to file
28
48
  File.open(file, "w") { |f| f.write to_s }
29
49
  end
50
+
51
+ def modify_csproj
52
+ xml = FileSystem.read_file @project.path, @project.csproj
53
+ doc = REXML::Document.new xml
54
+ references = doc.get_elements(ProjectFile::REFERENCE_PATH)
55
+ references.each do |reference|
56
+ reference.elements['SpecificVersion'] = REXML::Element.new('SpecificVersion').add_text('false')
57
+ reference.elements['HintPath'] = REXML::Element.new('HintPath').
58
+ add_text("..\\Libraries\\#{artifact_for reference}")
59
+ end
60
+
61
+ FileSystem.write! :path => @project.path, :name => @project.csproj, :content => doc.to_s
62
+ end
63
+
64
+ private
65
+ def artifact_for reference
66
+ dependency = Dependency.from_reference reference
67
+ libraries_dir = Dir.new(File.join(@project.path, '..', 'Libraries'))
68
+ libraries_dir.find {|f| f.match "#{dependency.name}\\.(dll|exe)"}
69
+ end
30
70
  end
31
71
  end
32
72
  end
73
+
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: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mozair Alves do Carmo Junior
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-28 00:00:00 -02:00
12
+ date: 2010-01-29 00:00:00 -02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency