Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meta-profiles in Maven

I'm looking for a way to create meta-profiles that just activate sub-profiles in Maven. Let's take a very concrete example. I have the following profiles:

  • "server-jboss"
  • "server-tomcat"
  • "database-hsql"
  • "database-oracle"

To build the project, you have to choose one profile for the server and one for the database. I want to create two "meta-profiles":

  • "dev" => "server-tomcat","database-hsql"
  • "prod" => "server-jboss","database-oracle"

The first idea that comes is to activate the subprofiles by a property:

<profile>
   <id>database-oracle</id>
   <activation>
     <property>
       <name>prod</name>
     </property>
   </activation>
</profile>

But this way, I cannot share subprofiles between meta-profiles. For example, I want my profile "database-oracle" to be activated by both "pre-prod" and "prod" meta-profiles.

Note: my sub-profiles just contain properties. They are used for filtering resources and in the child poms. This is why I think there could be a solution for this particular situation.

The ideal situation for me would be to have them externalized in external properties files, but one issue at a time ;)

like image 882
nicoulaj Avatar asked Feb 28 '23 13:02

nicoulaj


1 Answers

Activating profiles from another profile is not possible (this has been discussed in this previous question). Your first idea, using identical properties to activate different profiles, is the best thing you can implement but has indeed limitations.

like image 185
Pascal Thivent Avatar answered Mar 31 '23 11:03

Pascal Thivent