Questions tagged [maven-profiles]

Profiles are intended to give some extra behaviors to maven builds, with a set of properties, plugin or actions

Introduction to Build Profiles

Maven 2.0 introduces the concept of a build profile. Profiles are specified using a subset of the elements available in the POM itself (plus one extra section), and are triggered in any of a variety of ways.

They modify the POM at build time, and are meant to be used in complementary sets to give equivalent-but-different parameters for a set of target environments (providing, for example, the path of the appserver root in the development, testing, and production environments).

As such, profiles can easily lead to differing build results from different members of your team. However, used properly, profiles can be used while still preserving project portability. This will also minimize the use of -f option of maven which allows user to create another POM with different parameters or configuration to build which makes it more maintainable since it is runnning with one POM only.

What are the different types of profile? Where is each defined?

Per Project - Defined in the POM itself (pom.xml).

Per User - Defined in the Maven-settings (%USER_HOME%/.m2/settings.xml).

Global - Defined in the global Maven-settings (%M2_HOME%/conf/settings.xml).

Profile descriptor - a descriptor located in project basedir (profiles.xml) (unsupported in Maven 3.0: see Maven 3 compatibility notes)

Sources and official site : http://maven.apache.org/guides/introduction/introduction-to-profiles.html

248 questions
88
votes
2 answers

Default build profile for Maven

I have added profiling to my Maven project. da live dev
Isuru
  • 7,893
  • 8
  • 30
  • 38
78
votes
4 answers

How do I invoke two different profiles in one maven command?

I have two profiles for different environments in pom.xml, I have to run mvn -PTest1 install and mvn -PTest2 install command to get these profiles in use. Can we integrate two separate maven commands in a single one (like mvn clean install)? Here is…
dinesh sharma
  • 863
  • 1
  • 7
  • 8
34
votes
4 answers

Inheriting Maven profiles

Is it possible for a child POM to inherit profiles defined in the parent POM? If so, how?
Gili
  • 86,244
  • 97
  • 390
  • 689
33
votes
2 answers

How can I assign a specific maven profile to an intellij run configuration?

I have multiple projects loaded into my project structure and they all use different maven profiles. I know I can switch up the profiles using the Maven Projects tab but I would like to assign a specific profile to go along with a specific run…
Grammin
  • 11,808
  • 22
  • 80
  • 138
33
votes
4 answers

Values for os.family in Maven profile activation condition

Maven allows to activate certain build profiles based on the operating system family it runs on, for example: Windows There is a number of question around…
MaDa
  • 10,511
  • 9
  • 46
  • 84
31
votes
5 answers

How to list all activated profiles in mvn in a multimodule project

mvn help:active-profiles only list the profiles activate within the project + system settings you call it in. It does not list the profiles that have been enabled/activated from i.e. the parent pom. Any any way to actually see the full list of…
Max Rydahl Andersen
  • 3,630
  • 2
  • 23
  • 28
29
votes
1 answer

Activate Maven profile if another profile is not activated

The question is related to Maven: Only activate profile A if profile B is not activated?, but it's more specific. If I type one of the following: mvn clean install -PspecificProfile mvn clean install -Dsmth -PspecificProfile mvn clean install -Dsmth…
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
17
votes
2 answers

Is it possible to use proxy only when a specific profile is active in Maven?

I would like to use proxy only when a specific profile is active. To accomplish this, my guess is to parameterize the property of element. However, I am not exactly sure how to accomplish this. Question: How can I use proxy only…
Utku
  • 2,025
  • 22
  • 42
16
votes
2 answers

Get list of activated profile name during run time in maven java project

I need to be able to use the profile activated during the run time of JUnit tests. I was wondering if there is any way of doing something like: String str = System.getProperty("activated.profile[0]"); Or any other relative way... I realized there…
Mickey Hovel
  • 982
  • 1
  • 15
  • 31
16
votes
5 answers

How to enforce the use of exactly one out of two Maven profiles?

I have a Maven project that defines two separate profiles, developer and release (surely you get the drift, here). I want one of these two profiles to be activated at any time, but never both. If both are somehow activated, this build makes no sense…
Sander Verhagen
  • 8,540
  • 4
  • 41
  • 63
16
votes
1 answer

Using the properties tag within maven profiles

I am in reference to "Maven: The Complete Reference" and especially the section regarding profiles which documents the use of a development
balteo
  • 23,602
  • 63
  • 219
  • 412
14
votes
6 answers

How to overwrite files in the WAR file during maven build?

I have a Java webapp project that I develop in Eclipse (more precisely MyEclipse 10) and build using Maven 3. I have the following layout (including only the files relevant to my problem : project root |-- src | |-- main | | |-- java | | …
Pierre Henry
  • 16,658
  • 22
  • 85
  • 105
13
votes
2 answers

Activating a Child Profile from a Parent Profile

I have the following parent pom.xml file: build_full true mymodule_interface
KingFish
  • 8,773
  • 12
  • 53
  • 81
12
votes
2 answers

How to activate maven profile use environment variables?

For some reason, I have to use environment variable instead of passing the system properties to mvn command. So, I use ${env.PROFILE} as the property name, The profile setting in the pom.xml shows as follows:
gamedo
  • 141
  • 1
  • 1
  • 8
12
votes
1 answer

Maven - Child Module Profiles

Problem I have a maven project that has a similar structure to the following one: (simplified for explanation purposes) --parent |-- child A (inherits from parent) |-- child B (inherits from parent) |-- child B1 (inherits from B) …
JDC
  • 4,247
  • 5
  • 31
  • 74
1
2 3
16 17