having a list of users which should be different for stage and production:
user1:
name: username1
password: password1
email: email1
roles: role1, role2
user2:
name: username2
password: password2
email: email2
roles: role1, role2
user3:
name: username3
password: password3
email: email3
roles: role1, role2
user4:
name: username4
password: password4
email: email4
roles: role1, role2
user5:
name: username5
password: password5
email: email5
roles: role1, role2
i tried to put them in the build.properties
file (i skipped the roles part)
[user]
admins=username1|password1|email1,username2|password2|email2,username3|password3|email3,username4|password4|email4,username5|password5|email5
which work quite ok with the following code snippet in the build.xml
<target name="createUsers">
<foreach list="${admins}" param="_userset" target="createUser" />
</target>
<target name="createUser">
<php expression="strpos('${_userset}', '|')" returnProperty="_pos1"/>
<php expression="strrpos('${_userset}', '|')" returnProperty="_pos2"/>
<php expression="${_pos2}-${_pos1}" returnProperty="_len"/>
<php expression="substr('${_userset}', 0, ${_pos1})" returnProperty="_username"/>
<php expression="substr('${_userset}', ${_pos1}+1, ${_len}-1)" returnProperty="_password"/>
<php expression="substr('${_userset}', ${_pos2}+1)" returnProperty="_email"/>
<SymfonyConsole console="${bin.symfony}" command="fos:user:create">
<arg value="${_username}" />
<arg value="${_email}" />
<arg value="${_password}" />
</SymfonyConsole>
</target>
but the part in the build.properties
file is quite unreadable and unhandy, also adding new values like roles, which is also a list, is rather unhandy.
breaking up the lines does not work, like for java https://stackoverflow.com/a/8978515/590247:
[user]
admins=username1|password1|email1,\
username2|password2|email2,\
username3|password3|email3,\
username4|password4|email4,\
username5|password5|email5
is there a better way to store the multidimensional data?