### Feature groups

A feature spec represents a minimal configuration unit. When a configuration model reaches a certain level of complexity though, using and manipulating features to define the final configuration may become impractical.
Feature groups allow to group a set of features that represent a certain part of the configuration together and then include them all into the final configuration as a group. For example

[source,xml]
----
 <feature-group-spec name="group1" xmlns="urn:jboss:galleon:feature-group:1.0">
   <feature spec="feature1">
     <param name="id" value="a1"/>
     <feature spec="feature2">
       <param name="id" value="b1"/>
     </feature>
   </feature>
   <feature spec="feature3">
     <param name="id" value="c1"/>
   </feature>
 </feature-group-spec>
----

[source,xml]
----
 <feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
                location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0">
   <config name="main">
     <feature-group name="group1"/>
   </config>
 </feature-pack>
----

First, we defined a feature group named `group1` which includes three features.

NOTE: The name of the group must be unique in the scope of the feature-pack.

Feature groups are saved in the feature-pack's `feature_groups` directory in XML files named after the feature groups (`group1.xml` in this example).

Then in the default configuration of the feature-pack we simply included `group1`, which is equivalent to including the mentioned three features into the config directly.

Besides features, feature groups may also include other feature groups. Continuing the example above:

[source,xml]
----
 <feature-group-spec name="group2" xmlns="urn:jboss:galleon:feature-group:1.0">
   <feature-group name="group1"/>
   <feature spec="feature4">
     <param name="id" value="d1"/>
   </feature>
 </feature-group-spec>
----

[source,xml]
----
 <feature-pack xmlns="urn:jboss:galleon:feature-pack:1.0"
                location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0">
   <config name="main">
     <feature-group name="group2"/>
   </config>
 </feature-pack>
----

The final configuration will now include all the four features.

NOTE: The order of the features in the resolved configuration will reflect the order in which the features were included into the configuration but also respecting the feature references and the dependencies, i.e.

. `feature1:id=a1`

. `feature2:id=b1`

. `feature3:id=c1`

. `feature4:id=d1`
