[#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.

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

[source,java]
----
<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-maven-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[]

