A Build profile is a set of configuration values, which can be used to set or override default values of Maven build. Using a build profile, you can customize build for different environments such as Production or Development environments, Profiles are specified in pom.
The profile values can be specific or override extsing values, you can have multiple profiles active at one time.
The build behavior can change depending on the type of operating systems, runtime environment, etc. You can declare a build during the following
There are a number of ways to active a build profile
Below are some of the commandline options you can use to active or deactive build profiles
Activing or Deactiving build profiles | mvn package -P <profile-1>,<profile-2> # activing profiles mvn package -P !<profile-1>,<profile-2> # use the ! to deactive a profile |
view active profiles | mvn help:active-profiles |
There are a number of properties you can use in the profile
As stated above you can setup a build profile in one of three ways this example uses the settings.xml file. Intellij will list the profiles and indicate whichs ones are active.
You can pass some environment variables on a profile basis, you need to updated the build property and then add the properties environment variable to the specific profile (see right screenshot), then in you code you can get to this varaible using the System.getenv() method.
![]() |
![]() |