h2. Goal {{features:add-features-to-repo}}

The {{features:add-features-to-repo}} goal adds all the required bundles for a given set of features into directory.  You can use this goal to create a {{/system}} directory for building your own Karaf-based distribution.

By default, the Karaf core features descriptors (standard and enterprise) are automatically included in the descriptors set.

h3. Example
The example below copies the bundles for the {{spring}} and {{war}} features defined in the Karaf features XML descriptor into the {{target/features-repo}} directory.
{pygmentize:xml}
<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.karaf.tooling</groupId>
        <artifactId>features-maven-plugin</artifactId>
        <version>${project.version}</version>

        <executions>
          <execution>
            <id>add-features-to-repo</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>add-features-to-repo</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>mvn:my.groupid/my.artifactid/1.0.0/xml/features</descriptor>
              </descriptors>
              <features>
                <feature>spring</feature>
                <feature>war</feature>
                <feature>my</feature>
                <feature>other/1.0-SNAPSHOT</feature>
              </features>
              <repository>target/features-repo</repository>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>  
</project>
{pygmentize}

h3. Parameters
|| Name || Type || Description ||
| {{descriptors}} | {{String[]}} | List of features XML descriptors where the features are defined \\ NB: Karaf core features descriptors (standard and enterprise) are automatically added in this list |
| {{features}} | {{String[]}} | List of features that bundles should be copied to the repository directory. A feature could be just a feature name or a name/version. If it's just a name, the features-maven-plugin will take the first feature with the given name, whatever the version is. |
| {{repository}} | {{File}} | The directory where the bundles will be copied by the plugin goal |
| {{karafVersion}} | {{String}} | Target Karaf version to use to resolve the Karaf core features descriptors (standard and enterprise) |
