If you want to remove ant from your process, I would look at using assembly profiles with filters.
In this case, include your property files in the src / main / resources tree structure. Then parameterize the properties file with filter properties such as this:
jdbc.url=${filtered.jdbc.property}
Then, src / main / filters create filter files based on profiles. so you can have dev-filters.properties sit-filters.properties, etc. They contain:
filtered.jdbc.property=jdbc url here
Then you configure the build profiles for each region where you set the env property, which indicates the specific region of your building. You can then configure the resource filter to use ${env}-filters.properties for each assembly. In addition, you can configure the military plugin to add the env property to your artifact so that you actually store 4 different artifacts in your repository under a different classifier.
Then you simply create an application with each profile. You must call the assembly for each profile, but it works well.
An example of some settings in POM:
<build> <filters> <filter>src/main/filters/filter-${env}-application.properties</filter> </filters> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1-beta-1</version> <executions> <execution> <phase>package</phase> <goals> <goal>war</goal> </goals> <configuration> <classifier>${env}</classifier> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>LOCAL</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <env>LOCAL</env> </properties> </profile> <profile> <id>DEV</id> <properties> <env>DEV</env> </properties> </profile> <profile> <id>UAT</id> <properties> <env>UAT</env> </properties> </profile> <profile> <id>PROD</id> <properties> <env>PROD</env> </properties> </profile> </profiles>
In addition, the details of this blog post in which I initially found steps to accomplish this.
Mike Cornell Jul 19 '09 at 13:53 2009-07-19 13:53
source share