Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheriting Maven profiles

Is it possible for a child POM to inherit profiles defined in the parent POM? If so, how?

like image 600
Gili Avatar asked Sep 12 '10 15:09

Gili


People also ask

Are Maven properties inherited?

Maven supports project inheritance. You can create a parent project that contains properties child projects have in common, and child projects inherit those properties from the parent project.

What is Maven inheritance?

All Maven POMs inherit values from a parent POM. If a POM does not specify a direct parent using the parent element, that POM will inherit values from the Super POM. Project Inheritance shows the parent element of project-a which inherits the POM defined by the a-parent project.

Where are profiles configured in Maven?

Profiles are specified in pom. xml file using its activeProfiles/profiles elements and are triggered in variety of ways.

How do I run a specific profile in Maven?

What you should do is check the profile behavior by doing the following : set activeByDefault to true in the profile configuration, run mvn help:active-profiles (to make sure it is effectively activated even without -Pdev1 ), run mvn install .


2 Answers

Profiles defined in a parent POM are inherited in a child POM extending the parent, there is nothing to do. And just in case, the Maven Help Plugin has very useful goals allowing to deal with profiles:

  • help:active-profiles : lists the profiles which are currently active for the build.
  • help:all-profiles : lists the available profiles under the current project.
like image 106
Pascal Thivent Avatar answered Sep 22 '22 14:09

Pascal Thivent


I don't think it is inherited. http://www.dashbay.com/2011/03/maven-profile-inheritance/ http://looking4q.blogspot.com/2011/01/maven-profiles-inheritance.html You may find the profiles available is very likely because they are activated by default

like image 30
gigi2 Avatar answered Sep 21 '22 14:09

gigi2