Reputation: 2287
I think I've a fairly generic problem that I expecting Maven to solve, but I can't find the appropriate plug-in...
Background
Like most reasonably sized projects I've got a requirement to deploy my application in several different environments. Let's say they are called "development", "qa" and "production". In each of these environments my application will talk to a different back end server and save it's data to a different data base. Rather then hard code all the setting in my application I'm going to create a Java properties file for each environment and just deploy the right one with the application. In my source code will look something like:
<root>
|-- conf
| |--develop
| | \-- application.properties
| |--qa
| | \-- application.properties
| \--production
| \-- application.properties
\-- pom.xml
The problem
If the developer is adding a new setting to the project it's too easy to update conf\development\application.properties
file but forget to update the other files. If the setting is missing this typically causes errors a run time, which on a production server could be disastrous.
The Question
Is there a Maven plug-in that could be used to ensure that all three versions of application.properties contain the exactly same set of keys. If one (or more) key is missing from any of the files the build should be failed.
Upvotes: 2
Views: 1398
Reputation: 14762
with an appropriate parameter, e.g. files
.
See this answer for examples how to implement multiple values parameters.
that reads the three .properties
files and fills a Map<String, Integer>
(where: String key
, Integer count
).
If any of the Integer
is not equal to the number of files given in the end throw an org.apache.maven.plugin.MojoFailureException
. The same applies if one of the values is invalid, e.g. empty or otherwise syntactically wrong.
I'd bind the plugin's goal to the generate-resources
phase.
Upvotes: 1