Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Commit

Permalink
merged leandro commits
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigues committed May 31, 2011
2 parents cdda626 + c6b318f commit 018f93a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ temp/**
**/*.*~
pkg/**
*~
.DS_Store
2 changes: 2 additions & 0 deletions Manifest.txt
Expand Up @@ -15,7 +15,9 @@ lib/iron_hammer/deliverables/deliverable.rb
lib/iron_hammer/deploy/create_status.rb
lib/iron_hammer/deploy/wmi_service.rb
lib/iron_hammer/deploy/windows_service.rb
lib/iron_hammer/ext/rexml_ext.rb
lib/iron_hammer/hammer.rb
lib/iron_hammer/os/platform.rb
lib/iron_hammer/package.rb
lib/iron_hammer/projects/asp_net_mvc_project.rb
lib/iron_hammer/projects/asp_net_project.rb
Expand Down
1 change: 0 additions & 1 deletion bin/ivy
Expand Up @@ -8,4 +8,3 @@ if ARGV.empty?
puts "You must specify a target. Available targets (remove iron:ivy: prefix):"
`rake -f "#{IronHammer::Configuration.home}\\rakefile.rb" -T iron:ivy`
end

1 change: 1 addition & 0 deletions lib/iron_hammer.rb
Expand Up @@ -24,6 +24,7 @@ module Defaults
require 'iron_hammer/deploy/windows_service'
require 'iron_hammer/deploy/wmi_service'
require 'iron_hammer/hammer'
require 'iron_hammer/os/platform'
require 'iron_hammer/package'
require 'iron_hammer/projects/asp_net_mvc_project'
require 'iron_hammer/projects/asp_net_project'
Expand Down
62 changes: 36 additions & 26 deletions lib/iron_hammer/configuration.rb
Expand Up @@ -3,59 +3,69 @@ module Configuration

def self.home
return ENV['IRON_HAMMER_HOME'] if ENV['IRON_HAMMER_HOME']
@home = File.join(ENV['USERPROFILE'], '.IronHammer')
print_message
generate_config
@home
new_default_home
end

private
def self.generate_config
FileUtils.mkpath @home

`setx IRON_HAMMER_HOME "#{@home}"`
def self.new_default_home
home_dir = File.join(IronHammer::OS::Platform.home_directory, '.IronHammer')
setup_home_dir(home_dir)
home_dir
end

File.open(File.join(@home, 'rakefile.rb'), 'w') do |f|
f.write default_rakefile_rb
end
def self.setup_home_dir(home_dir)
ENV['IRON_HAMMER_HOME'] = FileUtils.mkpath(home_dir)

File.open(File.join(@home, 'ivysettings.xml'), 'w') do |f|
f.write default_ivysettings
end
generate_config_files(home_dir)
print_warning_message(home_dir)
end

def self.print_message
puts "IRON_HAMMER_HOME environment variable not found! Generating default config on #{@home}\
You'll need to download apache ivy from http://ant.apache.org/ivy/download.cgi\
and copy ivy-x.x.x.jar to #{@home}\\ivy.jar\
You can also edit #{@home}\\rakefile.rb and change any settings you want"
def self.generate_config_files(home_dir)
File.open(File.join(home_dir, 'rakefile.rb'), 'w') do |f|
f.write default_rakefile_rb(home_dir)
end

File.open(File.join(home_dir, 'ivysettings.xml'), 'w') do |f|
f.write default_ivysettings_xml(home_dir)
end
end

def self.default_rakefile_rb
def self.default_rakefile_rb(home_dir)
<<EOF
require 'rubygems'
IVY_JAR = "#{ENV['IRON_HAMMER_HOME']}\\ivy.jar"
IVY_SETTINGS = "#{ENV['IRON_HAMMER_HOME']}\\ivysettings.xml"
#VISUAL_STUDIO_PATH = ENV['VISUAL_STUDIO_PATH'] || 'C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE'
IVY_JAR = "#{File.join(home_dir, 'ivy.jar')}"
IVY_SETTINGS = "#{File.join(home_dir, 'ivysettings.xml')}"
#ORGANISATION = 'Your company'
require 'iron_hammer/tasks'
EOF
end

def self.default_ivysettings
def self.default_ivysettings_xml(home_dir)
<<EOF
<ivysettings>
<settings defaultResolver="default" />
<caches defaultCacheDir="#{@home}/Ivy/Cache"/>
<caches defaultCacheDir="#{home_dir}/Ivy/Cache"/>
<resolvers>
<filesystem name="default">
<ivy pattern="#{@home}/Ivy/Repository/[organisation]/[module]/ivys/ivy-[revision].xml"/>
<artifact pattern="#{@home}/Ivy/Repository/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
<ivy pattern="#{home_dir}/Ivy/Repository/[organisation]/[module]/ivys/ivy-[revision].xml"/>
<artifact pattern="#{home_dir}/Ivy/Repository/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
</filesystem>
</resolvers>
</ivysettings>
EOF
end

def self.print_warning_message(home_dir)
puts %Q{
IRON_HAMMER_HOME environment variable not found! Generating default config on #{home_dir}.
You'll need to download apache ivy from http://ant.apache.org/ivy/download.cgi
and copy ivy-x.x.x.jar to #{File.join(home_dir, 'ivy.jar')}.
You can also edit #{File.join(home_dir, 'rakefile.rb')} and change any settings you want.
}
end
end
end

15 changes: 13 additions & 2 deletions lib/iron_hammer/tasks/ivy.rb
Expand Up @@ -19,7 +19,6 @@ def all_dependencies

desc 'Publishes project dependencies into ivy repository'
task :setup, [:binaries_path] do |t, args|

files = Dir.new(args.binaries_path).entries
candidates = all_dependencies.select {|x| files.include? "#{x.name}.#{x.extension}"}

Expand Down Expand Up @@ -68,6 +67,19 @@ def all_dependencies
end
IvyBuilder.rename_artifacts
end

desc "Gets a specific dependency from ivy repository but doesn't modify project csproj to reference it"
task :get, [:artifact, :version] do |task, args|
builder = IvyConfiguration.builder_for(SolutionProject.new(@anvil.solution.name, all_dependencies))

begin
sh builder.get args.artifact, args.version
rescue RuntimeError
puts "\nThe artifact '#{args.artifact}' version '#{args.version}' not found in ivy repository"
end

IvyBuilder.rename_artifacts
end

desc 'Publishes project assemblies to ivy repository (only dll projects)'
task :publish => [:generate] do
Expand All @@ -83,4 +95,3 @@ def all_dependencies
end
end
end

9 changes: 8 additions & 1 deletion lib/iron_hammer/utils/ivy_builder.rb
Expand Up @@ -56,6 +56,13 @@ def retrieve ivy_file
" -retrieve Libraries/[artifact]-[revision].[ext]"
end

def get artifact, version
"java -jar #{@config.ivy_jar}
-dependency #{@config.organisation} #{artifact} #{version}
-settings #{@config.ivy_settings}
-retrieve Libraries/[artifact]-[revision].[ext]".gsub(/\s+/, ' ')
end

def publish ivy_file
"java -jar \"#{@config.ivy_jar}\"
-ivy #{ivy_file}
Expand Down Expand Up @@ -94,7 +101,7 @@ def modify_csproj
def self.rename_artifacts
Dir["Libraries/*.{dll,exe}"].each do |file|
file.scan(/Libraries\/(.*)-([\d\.]*)\.(.*)/) do |name, version, extension|
FileUtils.mv(file, "Libraries\\#{name}.#{extension}")
FileUtils.mv(file, File.join("Libraries", "#{name}.#{extension}"))
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/iron_hammer/utils/ivy_configuration.rb
Expand Up @@ -17,9 +17,9 @@ def self.instance

private
def initialize
@organisation = defined?(ORGANISATION)? ORGANISATION : 'org'
@ivy_jar = defined?(IVY_JAR)? IVY_JAR : 'ivy.jar'
@ivy_settings = defined?(IVY_SETTINGS)? IVY_SETTINGS : 'ivysettings.xml'
@organisation = defined?(ORGANISATION) ? ORGANISATION : (ENV['IVY_ORGANISATION'] ? ENV['IVY_ORGANISATION'] : 'org')
@ivy_jar = defined?(IVY_JAR) ? IVY_JAR : (ENV['IVY_JAR'] ? ENV['IVY_JAR'] : 'ivy.jar')
@ivy_settings = defined?(IVY_SETTINGS) ? IVY_SETTINGS : (ENV['IVY_SETTINGS'] ? ENV['IVY_SETTINGS'] : 'ivysettings.xml')
@retrieve_version = ENV['retrieve_version'] || 'latest.build'
end

Expand Down

0 comments on commit 018f93a

Please sign in to comment.