Do you have a standalone example which triggers the error, i.e. with map and config already set? That will save us time reproducing.
Cheers, Paul. On Sat, May 26, 2018 at 2:59 AM, Nelson, Erick <erick.nel...@hdsupply.com> wrote: > Caught: groovy.lang.ReadOnlyPropertyException: Cannot set readonly > property: opt for class: org.apache.commons.cli.Option > > groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: opt > for class: org.apache.commons.cli.Option > > at script.Cli.createOption(Cli.groovy:158) > > at script.Cli.createDefaultOptions(Cli.groovy:88) > > at script.Cli.<init>(Cli.groovy:29) > > at test_cli.run(test_cli.groovy:6) > > > > I see that it upgrades from commons-cli 1.2 to 1.4 > > > > Code snippet… > > I’m dynamically trying to build default command line options for my > scripting framework. > > This works in 2.4 > > > > // validate the option > > Integer slen = map.opt.*length*() // short opt length > > Integer llen = map.longOpt.*length*() // long opt length > > if (slen > 1 || llen == 1 || (slen == 0 && llen == 0)) { > > log.warn "invalid cli opt definition [$config]" > > return > > } > > if (slen) { > > if (builder.options.getOption(map.opt)) { > > log.warn "opt already used [$config]" > > return > > } > > } > > if (llen) { > > if (builder.options.getOption(map.longOpt)) { > > log.warn "longOpt already used [$config]" > > return > > } > > } > > // add the option > > Map builderOption = [:] > > if (llen > 0) { > > builderOption.longOpt = map.longOpt > > } > > if (slen > 0) { > > builderOption.opt = map.opt > > } > > if (map.argName) { > > builderOption.args = 1 > > builderOption.argName = map.argName > > } > > builder."${map.opt ?: '_'}"(builderOption, map.desc) // problem > is here > > > > > > >