Skip to content

Commit

Permalink
#33 Handle applicationSetup.n3
Browse files Browse the repository at this point in the history
Not like build.properties, because there is no template.
If it is provided in the instance, use it instead of the one in the source code.
  • Loading branch information
j2blake committed Nov 17, 2014
1 parent 21cd266 commit 67c5f36
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 15 deletions.
2 changes: 2 additions & 0 deletions common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
--------------------------------------------------------------------------------
=end
require 'fileutils'

require 'distro'
require 'hash_monkey_patch'
require 'instance'
Expand Down
69 changes: 54 additions & 15 deletions distro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
--------------------------------------------------------------------------------
Info about the source code distribution.
Is it git repositories or a release?
Is it older than release 1.5?
Is it older than release 1.5? 1.8 or newer?
--------------------------------------------------------------------------------
Expand All @@ -13,6 +14,12 @@
class Distro
attr_reader :path
attr_reader :props
attr_reader :filename
def initialize(path)
@path = path
@filename = File.basename(path)
end

def file(filename)
File.expand_path(filename, @path)
end
Expand All @@ -31,24 +38,30 @@ def run_build_script(command)

def self.create(path)
begin
GitDistro.new(path)
rescue
Rel18GitDistro.new(path)
rescue Exception => e
puts ">>>>>>Exception #{e}"
puts e.backtrace.inspect
begin
ReleaseDistro.new(path)
EarlyGitDistro.new(path)
rescue
begin
OldReleaseDistro.new(path)
ReleaseDistro.new(path)
rescue
EmptyDistro.new(path)
begin
OldReleaseDistro.new(path)
rescue
EmptyDistro.new(path)
end
end
end
end
end
end

class GitDistro < Distro
class EarlyGitDistro < Distro
def initialize(path)
@path = path
super
@props = {"vitro_path" => file('Vitro'), "vivo_path" => file('VIVO')}.merge(PropertyFileReader.read(file('distro.properties')))
confirm_props()
end
Expand All @@ -62,14 +75,14 @@ def confirm_props()

def status()
vivo_status = Dir.chdir(@props.vivo_path) do
format_git_status(`git status`)
format_git_status(`git status`)
end

vitro_status = Dir.chdir(@props.vitro_path) do
format_git_status(`git status`)
format_git_status(`git status`)
end
" VIVO:\n#{vivo_status} Vitro:\n#{vitro_status}"

" Git Distribution\n VIVO:\n#{vivo_status} Vitro:\n#{vitro_status}"
end

def format_git_status(text)
Expand All @@ -84,11 +97,29 @@ def update
def deploy(all_props)
super(NewConfiguration.new(), all_props)
end

def deploy(configurator, all_props)
super
end
end

class Rel18GitDistro < EarlyGitDistro
def confirm_props()
raise "No application setup" unless File.exist?(File.expand_path("config/applicationSetup.n3", @props.vivo_path))
super
end

def deploy(all_props)
configurator = Rel18Configuration.new()
super(configurator, all_props)
configurator.inject_application_setup(all_props)
end

end

class BaseReleaseDistro < Distro
def initialize(path)
@path = path
super
@props = {"vivo_path" => locate_release_dir()}.merge(PropertyFileReader.read(file('distro.properties')))
@props.vitro_path = File.expand_path('vitro-core', @props.vivo_path)
@props.release_name = File.basename(@props.vivo_path)
Expand Down Expand Up @@ -149,7 +180,7 @@ def deploy(all_props)

class EmptyDistro < Distro
def initialize(path)
@path = path
super
@props = {}
end

Expand Down Expand Up @@ -188,3 +219,11 @@ def build_command()
"ant all -Ddeploy.properties.file=#{$instance.file('_generated.deploy.properties')}"
end
end

class Rel18Configuration < NewConfiguration
def inject_application_setup(all_props)
config_dir = File.expand_path('config', all_props.vivo_home)
application_setup = $instance.file('applicationSetup.n3')
FileUtils.cp(application_setup, config_dir) if File.exist?(application_setup)
end
end

0 comments on commit 67c5f36

Please sign in to comment.