Build profiles


Build profiles

A build profile is a set of setup values that can set or override Maven build default values. Using a building profile, you can tailor construction for various conditions, such as production versus development environments.

Profiles are supplied and triggered in various methods in pom.xml files utilizing their activeProfiles/profiles elements. Profiles modify the POM at the time of construction to provide distinct target environments with parameters (for example, the path of the database server in the development, testing, and production environments)

Types of Build Profile

Build profiles are majorly of three types.

Profile Activation

You can activate a Maven Build Profile in different ways.

  • Use of console input explicitly.
  • Through maven settings.
  • Based on environment variables (User/System variables).
  • OS configuration (for example, Windows family).
  • Files that are present / missing.

Profile Activation Examples

There are now three environment-specific files under src/main/resources.

Explicit Profile Activation

The following stages can now be done as an exercise.

  • Add another profile element to pom.xml (copy existing profile element and paste it where profile elements end).
  • Update the id from the test to normal for this profile element.
  • Updating the env.properties task section and copying env.properties to destination directories.
  • Repeat these three steps, updating the id to prod and the env.prod.properties task section.
  • This is everything. Three profiles (normal/test/prod) now are available for build.