
[id='auto-detecting-fractions_{context}']
= Auto-detecting fractions

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

NOTE: By default, {Thorntail} 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:thorntail-maven-plugin-configuration-options_{context}[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>
----

{Thorntail} then includes the `jaxrs` fraction during the build automatically.

[discrete]
== Prerequisites

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

[discrete]
== Procedure

. Add the `thorntail-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-thorntail.jar
----

.Related Information

* xref:fractions_{context}[]
* xref:creating-an-uberjar_{context}[]

