[#auto-detecting-fractions]
= Auto-detecting fractions

Migrating existing legacy applications to benefit from WildFly Swarm is simple when using fraction auto-detection.
If you enable the WildFly Swarm Maven plugin in your application, WildFly Swarm detects which APIs you use, and includes the appropriate fractions at build time.

NOTE: By default, WildFly Swarm only auto-detects if you do not specify any fractions explicitly. This behavior is controlled by the `fractionDetectMode` property. For more information, see the xref:maven-plugin-configuration[Maven plugin configuration reference].

For example, consider your `pom.xml` already specifies the API `.jar` file for a specification such as JAX-RS:

[source,xml]
----
<dependencies>
include::pom.xml[tag=jaxrs,index=2]
</dependencies>
----

WildFly Swarm then includes the `jaxrs` fraction during the build automatically.

.Prerequisites

* An existing Maven-based application with a `pom.xml` file.

.Procedure

. Add the `wildfly-swarm-plugin` to your `pom.xml` in a `<plugin>` block,
  with an `<execution>` specifying the `package` goal.
+
[source,xml]
----
<plugins>
include::pom.xml[tag=plugin,indent=2]
</plugins>
----

. Perform a normal Maven build:
+
[source]
----
$ mvn package
----

. Execute the resulting uberjar:
+
[source]
----
$ java -jar ./target/myapp-swarm.jar
----

.Related Information

* xref:fractions[]
* xref:creating-an-uberjar[]

