@@ -147,6 +147,11 @@ def ServerConfig.expand_path(path)
147
147
return result
148
148
end
149
149
150
+ def ServerConfig . strip_path ( path )
151
+ basepath = File . expand_path ( @@path + "/.." , @@context )
152
+ return path . sub ( basepath + '/' , '' )
153
+ end
154
+
150
155
def self . jar
151
156
raise HelpException . new ( "jar" , "You must be using JRuby to create a jar" ) unless RUBY_PLATFORM == "java"
152
157
begin
@@ -302,9 +307,9 @@ def self.initcpf
302
307
if @@is_jar
303
308
sample_config = "roxy/sample/pipeline-config.sample.xml"
304
309
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" )
306
311
end
307
- target_config = ServerConfig . expand_path ( " #{ @@path } / pipeline-config.xml" )
312
+ target_config = ServerConfig . expand_path ( ServerConfig . properties [ "ml. pipeline-config-file" ] )
308
313
309
314
force = find_arg ( [ '--force' ] ) . present?
310
315
if !force && File . exists? ( target_config )
@@ -1259,7 +1264,7 @@ def install
1259
1264
if @properties [ "ml.triggers-db" ] then
1260
1265
deploy_triggers
1261
1266
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
1263
1268
deploy_cpf
1264
1269
end
1265
1270
deploy_content
@@ -2249,18 +2254,24 @@ def clean_content
2249
2254
end
2250
2255
2251
2256
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
+
2252
2260
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
2261
2272
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 ) )
2264
2275
cpf_code = File . read ServerConfig . expand_path ( "#{ @@path } /lib/xquery/cpf.xqy" )
2265
2276
query = %Q{#{ cpf_code } cpf:load-from-config(#{ cpf_config } )}
2266
2277
logger . debug ( query )
0 commit comments