A Java project with maven as build tool needs to be deployed to different environments, such as ci, dev, test, prod etc. Each environment has a properties file with the same set of properties such as:
service.host
environment.suffix
user
password
- ...
The values of these properties are environment-specific. Currently the properties file have a template called management_template.properties
in the directory src/main/resources
, and the content looks like the following:
service.host=${host}
environment.suffix=${suffix}
user=${user}
password=${password}
In the configuration above,
- when deploying the project to production, the system property
config.dir
is needed for telling the directory of the properties file - when deploying the project to test for executing tests, the system properties
config.dir.test
is needed for telling the directory of the properties file.
The properties file in each of the environment is generated by means of shell script on base of the aforementioned template file, meaning the placeholders ${user}
,${host}
etc. are replaced by some system-specific values.
Problem with the current solution: the process of generating the properties files and giving the system properties config.dir
or config.dir.test
seems to complicate the work. Extra Shell scripting is needed, also I doubt about the necessity of the system properties config.dir
or config.dir.test
Question: is there any better solution for configuring and deploying the system-specific properties files?