Skip to content

Latest commit

 

History

History
16 lines (14 loc) · 1.23 KB

README.md

File metadata and controls

16 lines (14 loc) · 1.23 KB

mavenprofiles

Sample project to demonstrate maven profiles usage

Most of the times a project will have different build flavours, dev, test, staging or prod. Depending on a build flavour the deployment params will vary most of the times e.g when in dev mode your db URL will most likely be localhost and in prod it could be an external IP.

At the same time, when running your integration tests, you don't want to run them against your production db because tests fixtures could be the db data which is cleaned up before and after tests execution.

Keeping in mind the fact that app constants that change based on the build environment should be saved in the .properties files, and dynamically injected (filtered) in the app resource files, (in this case am referring to a spring framework app) having maven profiles simplifies this task in that passing "-P profile" to the build command automatically sets the right params.

Building the project

mvn clean compile -P test

Use -P option to set the current build profile.
By default dev profile is active. This ensures that at all times any build that doesn't specify the profile to use executes, it runs on dev properties including tests.