Skip to content

Commit

Permalink
more idempotence
Browse files Browse the repository at this point in the history
  • Loading branch information
dobozysaurus committed Oct 9, 2011
1 parent 6689667 commit 3f8f1ce
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions java_to_ruby.rb
Expand Up @@ -23,24 +23,27 @@
standalone_xml = File.join(root, '.openshift', 'config', 'standalone.xml')
doc = REXML::Document.new(File.read(standalone_xml))
extensions = doc.root.get_elements('extensions').first
modules.each do |name|
extensions.add_element('extension', 'module'=>"org.torquebox.#{name}")
end
profiles = doc.root.get_elements('//profile')
profiles.each do |profile|
jboss_config_done = false; extensions.each_element_with_attribute('module', "org.torquebox.bootstrap") {|e| jboss_config_done = true }
unless (jboss_config_done)
modules.each do |name|
profile.add_element('subsystem', 'xmlns'=>"urn:jboss:domain:torquebox-#{name}:1.0")
extensions.add_element('extension', 'module'=>"org.torquebox.#{name}")
end
profiles = doc.root.get_elements('//profile')
profiles.each do |profile|
modules.each do |name|
profile.add_element('subsystem', 'xmlns'=>"urn:jboss:domain:torquebox-#{name}:1.0")
end
scanner_subsystem = profile.get_elements("subsystem[@xmlns='urn:jboss:domain:deployment-scanner:1.0']").first
scanner = scanner_subsystem.get_elements('deployment-scanner').first
scanner.add_attribute('deployment-timeout', '1200')
end
File.open(File.join(root, '.openshift', 'config', 'standalone.xml'), 'w') do |file|
doc.write(file, 4)
end
scanner_subsystem = profile.get_elements("subsystem[@xmlns='urn:jboss:domain:deployment-scanner:1.0']").first
scanner = scanner_subsystem.get_elements('deployment-scanner').first
scanner.add_attribute('deployment-timeout', '1200')
end
File.open(File.join(root, '.openshift', 'config', 'standalone.xml'), 'w') do |file|
doc.write(file, 4)
end

# Add TorqueBox bits to .openshift/action_hooks/build
unless Dir.exist?(File.join(root, '.openshift'))
unless File.exist?(File.join(root, '.openshift'))
File.open(File.join(root, '.openshift', 'action_hooks', 'build'), 'w') do |file|
file.write(<<-END_OF_BUILD)
#!/bin/bash
Expand Down Expand Up @@ -583,8 +586,9 @@
end

# Add java_to_ruby.rb to .gitignore
File.open('.gitignore', 'a') do |file|
file.write("java_to_ruby.rb\n")
File.open('.gitignore', 'r+') do |file|
lines = file.readlines
file.write("java_to_ruby.rb\n") unless lines.index("java_to_ruby.rb\n")
end

setup_git = ARGV.index('--setup-git') || ARGV.index('-g')
Expand Down

0 comments on commit 3f8f1ce

Please sign in to comment.