I would like to fill a property file common.properties with values depending environment profiles (dev, prod...) but I don't want the file being added in the classpath.
I read several topics like read Maven variable from properties file using profile
So I manage to fill the properties with a profile:
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>${properties-maven-plugin.version}</version>
<executions>
<execution>
<id>read-project-properties</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>config/common_dev.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>config</directory>
<filtering>true</filtering>
</resource>
...
</resources>
...
</build>
in the module I have a folder config containing the files common.properties and common_dev.properties:
common_dev.properties:
common.reception.directory.norm = PHASE1V1
common.properties:
common.reception.directory.norm = ${common.reception.directory.norm}
The common.properties is well filled with mvn clean install, but the config directory becomes a source folder in Eclipse, a classpath entry for the directory had been added. Which is my problem, the common.properties file is got in the application with environnement variable containing its path and not read from the classpath. It's working but confusing for project developers.
I tried also to use write-project-properties and write-active-profile-properties of properties-maven-plugin but first one write all my project properties in the file, and second one write nothing, because read-project-properties read the properties as project properties and not profile properties.
Is there a way to do what I would like to do ?