Skip to content

Commit

Permalink
Update the example application and blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
pkainulainen committed Nov 22, 2014
1 parent b359a6a commit 51d4110
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 117 deletions.
5 changes: 0 additions & 5 deletions properties-filtering/README

This file was deleted.

3 changes: 3 additions & 0 deletions properties-filtering/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is an example application of my blog post:

* [Creating Profile Specific Configuration Files With Maven](http://www.petrikainulainen.net/programming/tips-and-tricks/creating-profile-specific-configuration-files-with-maven/)
148 changes: 38 additions & 110 deletions properties-filtering/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,143 +30,71 @@

<!-- Profiles configuration -->
<profiles>
<!-- The configuration of the development profile -->
<profile>
<id>dev</id>
<!-- Dev profile is active by default -->
<!-- The development profile is active by default -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!--
Specifies the build profile id, which is used to find out the correct properties file.
This is not actually necessary for this example, but it can be used for other purposes.
Specifies the build.profile.id property that must be equal than the name of
the directory that contains the profile specific configuration file.
Because the name of the directory that contains the configuration file of the
development profile is dev, we must set the value of the build.profile.id property to dev.
-->
<build.profile.id>dev</build.profile.id>
</properties>
<build>
<filters>
<!--
Specifies path to the properties file, which contains profile specific
configuration. In this case, the configuration file is searched
from profiles/dev/ directory.
-->
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<!--
Placeholders found from files located in the configured resource directories are replaced
with values found from the profile specific configuration files.
-->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<!--
You can also include only specific files found from the configured directory or
exclude files. This can be done by uncommenting following sections and adding
the configuration under includes and excludes tags.
-->
<!--
<includes>
<include></include>
</includes>
<excludes>
<exclude></exclude>
</excludes>
-->
</resource>
</resources>
</build>
</profile>
<!-- The configuration of the production profile -->
<profile>
<id>test</id>
<id>prod</id>
<properties>
<!--
Specifies the build profile id, which is used to find out the correct properties file.
This is not actually necessary for this example, but it can be used for other purposes.
Specifies the build.profile.id property that must be equal than the name of
the directory that contains the profile specific configuration file.
Because the name of the directory that contains the configuration file of the
production profile is prod, we must set the value of the build.profile.id property to prod.
-->
<build.profile.id>test</build.profile.id>
<build.profile.id>prod</build.profile.id>
</properties>
<build>
<filters>
<!--
Specifies path to the properties file, which contains profile specific
configuration. In this case, the configuration file is searched
from profiles/test/ directory.
-->
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<!--
Placeholders found from files located in the configured resource directories are replaced
with values found from the profile specific configuration files.
-->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<!--
You can also include only specific files found from the configured directory or
exclude files. This can be done by uncommenting following sections and adding
the configuration under includes and excludes tags.
-->
<!--
<includes>
<include></include>
</includes>
<excludes>
<exclude></exclude>
</excludes>
-->
</resource>
</resources>
</build>
</profile>
<!-- The configuration of the testing profile -->
<profile>
<id>prod</id>
<id>test</id>
<properties>
<!--
Specifies the build profile id, which is used to find out the correct properties file.
This is not actually necessary for this example, but it can be used for other purposes.
Specifies the build.profile.id property that must be equal than the name of
the directory that contains the profile specific configuration file.
Because the name of the directory that contains the configuration file of the
testing profile is test, we must set the value of the build.profile.id property to test.
-->
<build.profile.id>prod</build.profile.id>
<build.profile.id>test</build.profile.id>
</properties>
<build>
<filters>
<!--
Specifies path to the properties file, which contains profile
specific configuration. In this case, the configuration file is searched
from profiles/prod/ directory.
-->
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<!--
Placeholders found from files located in the configured resource directories are replaced
with values found from the profile specific configuration files.
-->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<!--
You can also include only specific files found from the configured directory or
exclude files. This can be done by uncommenting following sections and adding
the configuration under includes and excludes tags.
-->
<!--
<includes>
<include></include>
</includes>
<excludes>
<exclude></exclude>
</excludes>
-->
</resource>
</resources>
</build>
</profile>
</profiles>

<build>
<finalName>maven-properties-filtering</finalName>
<filters>
<!--
Ensures that the config.properties file is always loaded from the
configuration directory of the active Maven profile.

-->
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<!--
Placeholders that are found from the files located in the configured resource
directories are replaced with the property values found from the profile
specific configuration file.
-->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<!-- The configuration of maven-assembly-plugin -->
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*/
public class HelloWorldApp
{
private static Logger logger = Logger.getLogger(HelloWorldApp.class);
private static Logger LOGGER = Logger.getLogger(HelloWorldApp.class);

public static void main( String[] args )
{
logger.info("Hello World!");
LOGGER.info("Hello World!");
}
}

0 comments on commit 51d4110

Please sign in to comment.