@@ -147,6 +147,11 @@ def ServerConfig.expand_path(path)
147147 return result
148148 end
149149
150+ def ServerConfig . strip_path ( path )
151+ basepath = File . expand_path ( @@path + "/.." , @@context )
152+ return path . sub ( basepath + '/' , '' )
153+ end
154+
150155 def self . jar
151156 raise HelpException . new ( "jar" , "You must be using JRuby to create a jar" ) unless RUBY_PLATFORM == "java"
152157 begin
@@ -302,9 +307,9 @@ def self.initcpf
302307 if @@is_jar
303308 sample_config = "roxy/sample/pipeline-config.sample.xml"
304309 else
305- sample_config = ServerConfig . expand_path ( "#{ @@path } /sample/pipeline-config.sample.xml" )
310+ sample_config = ServerConfig . expand_path ( "#{ @@path } /sample/pipeline-config.sample.xml" )
306311 end
307- target_config = ServerConfig . expand_path ( " #{ @@path } / pipeline-config.xml" )
312+ target_config = ServerConfig . expand_path ( ServerConfig . properties [ "ml. pipeline-config-file" ] )
308313
309314 force = find_arg ( [ '--force' ] ) . present?
310315 if !force && File . exists? ( target_config )
@@ -1194,7 +1199,7 @@ def install
11941199 if @properties [ "ml.triggers-db" ] then
11951200 deploy_triggers
11961201 end
1197- if @properties [ "ml.triggers-db" ] and @properties [ "ml.data.dir" ] and File . exist? ( ServerConfig . expand_path ( " #{ @@path } / pipeline-config.xml" ) ) then
1202+ if @properties [ "ml.triggers-db" ] and @properties [ "ml.data.dir" ] and File . exist? ( ServerConfig . expand_path ( @properties [ "ml. pipeline-config-file" ] ) ) then
11981203 deploy_cpf
11991204 end
12001205 deploy_content
@@ -2182,18 +2187,24 @@ def clean_content
21822187 end
21832188
21842189 def deploy_cpf
2190+ default_cpf_config_file = ServerConfig . expand_path ( ServerConfig . properties [ "ml.pipeline-config-file" ] )
2191+ cpf_config_file = ServerConfig . expand_path ( @properties [ "ml.pipeline-config-file" ] )
2192+
21852193 if @properties [ "ml.triggers-db" ] . blank? || @properties [ "ml.data.dir" ] . blank?
2186- logger . error "To use CPF, you must define the triggers-db property in your build.properties file"
2187- elsif !File . exist? ( ServerConfig . expand_path ( "#{ @@path } /pipeline-config.xml" ) )
2188- logger . error <<-ERR . strip_heredoc
2189- Before you can deploy CPF, you must define a configuration. Steps:
2190- 1. Run 'ml initcpf'
2191- 2. Edit deploy/pipeline-config.xml to set up your domain and pipelines
2192- 3. Run 'ml <env> deploy cpf')
2193- ERR
2194+ logger . error "To use CPF, you must define the triggers-db property in your deploy/build.properties file"
2195+ elsif !File . exist? ( cpf_config_file )
2196+ msg = "Before you can deploy CPF, you must define a configuration. Steps:"
2197+ if !File . exist? ( default_cpf_config_file ) && !File . exist? ( cpf_config_file )
2198+ msg = msg + "\n - CPF requires a pipeline-config file, run ml initcpf to create a sample."
2199+ end
2200+ if !File . exist? ( cpf_config_file ) && cpf_config_file != default_cpf_config_file
2201+ msg = msg + "\n - Copy #{ ServerConfig . strip_path ( default_cpf_config_file ) } to #{ ServerConfig . strip_path ( cpf_config_file ) } ."
2202+ end
2203+ msg = msg + "\n - Edit #{ ServerConfig . strip_path ( cpf_config_file ) } to customize your domain and pipelines for the given environment."
2204+ logger . error msg
21942205 else
2195- cpf_config = File . read ServerConfig . expand_path ( " #{ @@path } /pipeline-config.xml" )
2196- replace_properties ( cpf_config , "pipeline-config.xml" )
2206+ cpf_config = File . read cpf_config_file
2207+ replace_properties ( cpf_config , ServerConfig . strip_path ( cpf_config_file ) )
21972208 cpf_code = File . read ServerConfig . expand_path ( "#{ @@path } /lib/xquery/cpf.xqy" )
21982209 query = %Q{#{ cpf_code } cpf:load-from-config(#{ cpf_config } )}
21992210 logger . debug ( query )
0 commit comments