Skip to content

--propOverwrites: how to overload a property that is itself a comma-separated list of values #636

@FALLAI-Denis

Description

@FALLAI-Denis

Hi,

In the build.groovy script, the --propOverwrites / -po parameter allows you to override or replace properties declared in the server or application configuration files.

This parameter accepts a comma-separated list of values in the form key1=value1,key2=value2,...,keyI=valueI.
But what if the value already contains commas?

Example: How to overload the applicationSrcDirs property with multiple folders?

There is no escape mechanism provided in the build.conf script.

// populate property overwrites from argument list                                                                         
if (opts.po) props.propOverwrites = opts.po                                                                                
if (props.propOverwrites) {                                                                                                
 String[] propOverwrites = props.propOverwrites.split(',')                                                                 
 propOverwrites.each { buildPropertyOverwrite ->                                                                           
  (key, value) = buildPropertyOverwrite.tokenize('=')                                                                      
  if (key && value) {                                                                                                      
   if (opts.v) println "** Overwriting build property ${key} from cli argument --propOverwrite with value ${value}"        
   props.put(key, value)                                                                                                   
  }                                                                                                                        
  else {                                                                                                                   
   println "*! Overwriting build property from cli argument --propOverwrite failed due a null value ( key: $key , value :$v
  }                                                                                                                        
 }                                                                                                                         
}            

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions