I will give you a completely different answer here, which will allow you to have two different files with their own configuration, which are then filtered into one file.
.
├── pom.xml
└── src
└── main
├── java
├── webapp
| └── WEB-INF
| └── web.xml
├── filters
| ├── dev.properties
| └── prod.properties
└── resources
├── application.properties
└── other.properties
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.stackoverflow</groupId> <artifactId>Q13045684</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>${project.artifactId}-${project.version}</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.4.3</version> <executions> <execution> <id>dev-resources</id> <phase>process-resources</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.outputDirectory}</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>application.properties</include> </includes> <filtering>true</filtering> </resource> </resources> <filters> <filter>src/main/filters/dev.properties</filter> </filters> </configuration> </execution> <execution> <id>prod-resources</id> <phase>prepare-package</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.outputDirectory}</outputDirectory> <overwrite>true</overwrite> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>application.properties</include> </includes> <filtering>true</filtering> </resource> </resources> <filters> <filter>src/main/filters/prod.properties</filter> </filters> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
src/main/filters/dev.properties
someProperty = foo someOtherProperty = bar
src/main/filters/prod.properties
someProperty = someOtherProperty =
src/main/resources/application.properties
someProperty = ${someProperty} someOtherProperty = ${someOtherProperty}
This will give you three files to work with. The output will have only application.properties .
source share