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
12
votes
1 answer

Does using activeByDefault go against maven best practices?

I wish to find out whether Never use is a maven best practice? The advice here around this seems pretty sound, but do you think it's absolute or if there are some cases in which it would not apply ? Am posting a snapshot of the…
Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
11
votes
0 answers

Merging plugin configuration from profile

I have a configuration entry for exec-maven-plugin compass compile
Jakub Bochenski
  • 3,113
  • 4
  • 33
  • 61
11
votes
5 answers

Inherited profiles in Maven

I have the following profiles in my parent pom P1 true P2
Adrian Ber
  • 20,474
  • 12
  • 67
  • 117
11
votes
3 answers

Maven 3 profile with extensions

My question had been addressed in this thread, but the explanation is not clear. I have this build definition in one of my pom.xml files: ${my.project}
forhas
  • 11,551
  • 21
  • 77
  • 111
10
votes
2 answers

Combining profiles in Maven to skip multiple categories of unit tests?

I am having a problem trying to configure Maven to excluded some categories of unit tests based on multiple profiles. I have two categories defined for unit testing: SlowTest for those unit tests that take a very long time to run, and WindowsTest…
John Q Citizen
  • 3,138
  • 4
  • 26
  • 31
9
votes
2 answers

Maven: How to print the current profile on the console?

I'm trying to print the current profile that is active running a build of a Maven Project. I'm using the maven-antrun-plugin in order to print messages on the console, in combination with a property that refers to the current profile. I have tried…
Alessandro C
  • 3,310
  • 9
  • 46
  • 82
9
votes
2 answers

Maven Resource Filtering with Profile Properties

I have the following pom.xml:
johnmcase
  • 1,769
  • 2
  • 16
  • 27
9
votes
7 answers

WARNING The requested profile "pom.xml" could not be activated because it does not exist

I am trying to run maven goal: validation and keep getting: [WARNING] The requested profile "pom.xml" could not be activated because it does not exist. In my…
topcan5
  • 1,511
  • 8
  • 30
  • 54
9
votes
1 answer

Activate profile when a certain Maven goal is run

I'm looking for a generic solution to enable a Maven profile when a certain Maven goal is run. For example, if I run mvn site I also want to activate the profile reporting automatically. I don't want to do it manually, e.g., using: mvn site…
Sebi
  • 8,323
  • 6
  • 48
  • 76
8
votes
3 answers

How to enable maven profile when built version is not -SNAPSHOT?

I'm trying to use the gitflow-helper-maven-plugin extension for my maven builds. Therefore I'd like to configure my project in order to run some extra steps when building a release version and skipping them while compiling a SNAPSHOT one, but I…
7
votes
1 answer

Choose maven profile from OS family

I want to set some properties based on the OS type, so I have the following in my pom.xml: KenMacbook mac
Ken Williams
  • 22,756
  • 10
  • 85
  • 147
7
votes
1 answer

Only one Maven profile executed when using activeByDefault

I have two profiles defined in my pom.xml: nobrand true nobrand
Misterer
  • 73
  • 1
  • 4
7
votes
1 answer

Maven: property to activate profile in sub-modules

We have a multi-module maven project, and it has different platforms to run on, like JBoss 4 and JBoss 7. We specify the platform property, and then use it as a classifier for artifacts, and for activation of the platform-specific profile in…
dds
  • 2,335
  • 1
  • 31
  • 45
7
votes
1 answer

Activate Maven profile if no other profile activated

I have a project that has several profiles. How do you make one of the profiles activate only if no other profiles are active?
aberrant80
  • 12,815
  • 8
  • 45
  • 68
7
votes
2 answers

Maven profile removing dependency

I have pom with declared dependencies A,B and C. Is it possible to create a profile which removes dependencies, so that when I compile with that profile, I end up for example with compiled dependency A and B (without C)?
Kamil
  • 2,158
  • 2
  • 18
  • 19
1
2
3
16 17