<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.jwach.examples</groupId>
<artifactId>example</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<dependencies>
...
</dependencies>
<build>
<finalName>${project.artifactId}-${build.env}-${project.version}</finalName>
<plugins>
...
</plugins>
<resources>
<!-- FILTERED -->
<resource>
<directory>src/main/resources/default</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/lib/*.jar</exclude>
<exclude>**/*.someFiles</exclude>
</excludes>
</resource>
<!-- NOT FILTERED -->
<resource>
<directory>src/main/resources/external</directory>
<filtering>false</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<!-- DEFAULT FILTERS -->
<filters>
<filter>src/main/filters/default/config.properties</filter>
</filters>
</build>
<!-- Filters do not have to show the src/main -->
<profiles>
<profile>
<id>preprod-env</id>
<properties>
<build.env>preprod-env</build.env>
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<filters>
<filter>src/main/filters/preprod-env/config.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>prod-env</id>
<properties>
<build.env>prod-env</build.env>
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<filters>
<filter>src/main/filters/prod-env/config.properties</filter>
</filters>
</build>
</profile>
</profiles>
</project>
As you can see, all profiles are disabled by default. This is because common configuration with custom properties for local deployment are collected in default profile, as stated in build section of the POM. When additional profile is activated, properties from new filter will override properties from default. Thanks to such solution we can minimize number of disjoint properties and build development product version without any extra effort.
Brak komentarzy:
Prześlij komentarz