@@ -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 )
@@ -1259,7 +1264,7 @@ def install
12591264 if @properties [ "ml.triggers-db" ] then
12601265 deploy_triggers
12611266 end
1262- if @properties [ "ml.triggers-db" ] and @properties [ "ml.data.dir" ] and File . exist? ( ServerConfig . expand_path ( " #{ @@path } / pipeline-config.xml" ) ) then
1267+ if @properties [ "ml.triggers-db" ] and @properties [ "ml.data.dir" ] and File . exist? ( ServerConfig . expand_path ( @properties [ "ml. pipeline-config-file" ] ) ) then
12631268 deploy_cpf
12641269 end
12651270 deploy_content
@@ -2249,18 +2254,24 @@ def clean_content
22492254 end
22502255
22512256 def deploy_cpf
2257+ default_cpf_config_file = ServerConfig . expand_path ( ServerConfig . properties [ "ml.pipeline-config-file" ] )
2258+ cpf_config_file = ServerConfig . expand_path ( @properties [ "ml.pipeline-config-file" ] )
2259+
22522260 if @properties [ "ml.triggers-db" ] . blank? || @properties [ "ml.data.dir" ] . blank?
2253- logger . error "To use CPF, you must define the triggers-db property in your build.properties file"
2254- elsif !File . exist? ( ServerConfig . expand_path ( "#{ @@path } /pipeline-config.xml" ) )
2255- logger . error <<-ERR . strip_heredoc
2256- Before you can deploy CPF, you must define a configuration. Steps:
2257- 1. Run 'ml initcpf'
2258- 2. Edit deploy/pipeline-config.xml to set up your domain and pipelines
2259- 3. Run 'ml <env> deploy cpf')
2260- ERR
2261+ logger . error "To use CPF, you must define the triggers-db property in your deploy/build.properties file"
2262+ elsif !File . exist? ( cpf_config_file )
2263+ msg = "Before you can deploy CPF, you must define a configuration. Steps:"
2264+ if !File . exist? ( default_cpf_config_file ) && !File . exist? ( cpf_config_file )
2265+ msg = msg + "\n - CPF requires a pipeline-config file, run ml initcpf to create a sample."
2266+ end
2267+ if !File . exist? ( cpf_config_file ) && cpf_config_file != default_cpf_config_file
2268+ msg = msg + "\n - Copy #{ ServerConfig . strip_path ( default_cpf_config_file ) } to #{ ServerConfig . strip_path ( cpf_config_file ) } ."
2269+ end
2270+ msg = msg + "\n - Edit #{ ServerConfig . strip_path ( cpf_config_file ) } to customize your domain and pipelines for the given environment."
2271+ logger . error msg
22612272 else
2262- cpf_config = File . read ServerConfig . expand_path ( " #{ @@path } /pipeline-config.xml" )
2263- replace_properties ( cpf_config , "pipeline-config.xml" )
2273+ cpf_config = File . read cpf_config_file
2274+ replace_properties ( cpf_config , ServerConfig . strip_path ( cpf_config_file ) )
22642275 cpf_code = File . read ServerConfig . expand_path ( "#{ @@path } /lib/xquery/cpf.xqy" )
22652276 query = %Q{#{ cpf_code } cpf:load-from-config(#{ cpf_config } )}
22662277 logger . debug ( query )
0 commit comments