Reputation: 85
I'm using maven to build a war package for java application.This war includes some of the property files(comes around 10 files per env) but it needs to be updated based on the environment(dev,test,stage,prod) in following folders.
/usr/local/tomcat/webapps/ROOT/WEB-INF/classes/
/usr/local/tomcat/webapps/ROOT/js
/usr/local/tomcat/webapps/axis2/WEB-INF/classes/templates/
/usr/local/tomcat/webapps/axis2/WEB-INF/classes/
As of now I have a script in each virtual machine to copy those property files to extracted war folders. But it is cumbersome. Hence i need to update those property files during the build process itself.
Question: How we can achieve this in maven or jenkins?
Upvotes: 2
Views: 658
Reputation: 27862
To build for multiple environments you could use the new multienv-maven-plugin
, providing different configurations as part of your project and building for different environments in a single build.
As an example, your project would provide different environments configurations:
src
├── main
├── environments
├── dev-01
│ └── first.properties
├── dev-02
│ └── first.properties
├── test-01
│ └── first.properties
├── test-02
│ └── first.properties
└── prod
└── first.properties
And the plugin would create different artefacts based on the configuration above:
- artifactId-version-dev-01.war
- artifactId-version-dev-02.war
- artifactId-version-test-01.war
- artifactId-version-test-02.war
- artifactId-version-prod.war
Then you would no need further scripts but rather deploy each artefact to its related target environment.
Upvotes: 1