<commit_before>[#maven-plugin]
= Maven Plugin

WildFly Swarm provides a Maven plugin to accomplish most of the work of building xref:uberjar[uberjar] packages.

.General Usage

The WildFly Swarm Maven plugin is used like any other Maven plugin, that is through editing the `pom.xml` file in your application and adding a `<plugin>` section:

[source,xml]
----
<plugin>
  <groupId>org.wildfly.swarm</groupId>
  <artifactId>wildfly-swarm-plugin</artifactId>
  <version>${version.wildfly-swarm}</version>
  <executions>
    ...
    <configuration>
      ...
    <configuration/>
  </executions>
</plugin>
----

== Goals

The WildFly Swarm Maven plugin provides several goals:

package::
Creates the executable package (see xref:creating-an-uberjar[]).

run::
Executes your application in the Maven process. The application is stopped if the Maven build is interrupted, for example when you press Ctrl + C.

[#maven-plugin-multistart-goal]
start and multistart::
Executes your application in a forked process. Generally, it is only useful for running integration tests using a plugin, such as the `maven-failsafe-plugin`.
The `multistart` variant allows starting multiple WildFly Swarm{ndash}built applications using Maven GAVs to support complex testing scenarios.

stop::
Stops any previously started applications.
+
NOTE: The `stop` goal can only stop applications that were started _in the same Maven execution_.

[#maven-plugin-configuration]
== Configuration Options

The plugin accepts the following options:

bundleDependencies::
If true, dependencies will be included in the `-swarm.jar` file.
Otherwise, they will be resolved from `$M2_REPO` or the network at runtime.
+
[cols="1,2a"]
|===
|Property
|`swarm.bundleDependencies`

|Default
|true

|Used by
|`package`
|===

debug::
The port to use for debugging.
If set, the swarm process will suspend on start and open a debugger on this port.
+
[cols="1,2a"]
|===
|Property
|`swarm.debug.port`

|Default
|

|Used by
|`run`, `start`
|===

environment::
A properties-style list of environment variables to use when executing the application.
+
[cols="1,2a"]
|===
|Property
|_none_

|Default
|

|Used by
|`multistart`, `run`, `start`
|===

environmentFile::
A `.properties` file with environment variables to use when executing the application.
+
[cols="1,2a"]
|===
|Property
|`swarm.environmentFile`

|Default
|

|Used by
|`multistart`, `run`, `start`
|===

fractionDetectMode::
+
--
The mode of fraction detection. The available options are:

* `when_missing`: Runs only when no WildFly Swarm dependencies are found.
* `force`: Always run, and merge any detected fractions with the existing dependencies. Existing dependencies take precedence.
* `never`: Disable fraction detection.

[cols="1,2a"]
|===
|Property
|`swarm.detect.mode`

|Default
|`when_missing`

|Used by
|`package`, `run`, `start`
|===
--

fractions::
+
--
A list of extra fractions to include when auto-detection is used. It is useful for fractions that cannot be detected or user-provided fractions.

The format of specifying a fraction can be:
* `group:artifact:version`
* `artifact:version`
* `artifact`

If no group is provided, `org.wildfly.swarm` is assumed.

If no version is provided, the version is taken from the WildFly Swarm BOM for the version of the plugin you are using.

If the value starts with the character `!` a corresponding auto-detected fraction is not installed (unless it's a dependency of any other fraction).
In the following example the Undertow fraction is not installed even if your application references a class from the `javax.servlet` package:

[source,xml]
----
<plugin>
  <groupId>org.wildfly.swarm</groupId>
  <artifactId>wildfly-swarm-plugin</artifactId>
  <version>${version.wildfly-swarm}</version>
  <executions>
    <configuration>
     <fractions>
       <fraction>!undertow</fraction>
     </fractions>
    <configuration/>
  </executions>
</plugin>
----

[cols="1,2a"]
|===
|Property
|_none_

|Default
|

|Used by
|`package`, `run`, `start`
|===
--

ifndef::product[]
hollow::
Specifies if the resulting executable JAR should be hollow, and therefore not include the default deployment.
+
[cols="1,2a"]
|===
|Property<commit_msg>[SWARM-2018] Fix documentation on maven plugin<commit_after>[#maven-plugin]
= Maven Plugin

WildFly Swarm provides a Maven plugin to accomplish most of the work of building xref:uberjar[uberjar] packages.

.General Usage

The WildFly Swarm Maven plugin is used like any other Maven plugin, that is through editing the `pom.xml` file in your application and adding a `<plugin>` section:

[source,xml]
----
<plugin>
  <groupId>org.wildfly.swarm</groupId>
  <artifactId>wildfly-swarm-plugin</artifactId>
  <version>${version.wildfly-swarm}</version>
  <executions>
    ...
    <execution>
      <goals>
        ...
      </goals>
      <configuration>
        ...
      </configuration>
    </execution>
  </executions>
</plugin>
----

== Goals

The WildFly Swarm Maven plugin provides several goals:

package::
Creates the executable package (see xref:creating-an-uberjar[]).

run::
Executes your application in the Maven process. The application is stopped if the Maven build is interrupted, for example when you press Ctrl + C.

[#maven-plugin-multistart-goal]
start and multistart::
Executes your application in a forked process. Generally, it is only useful for running integration tests using a plugin, such as the `maven-failsafe-plugin`.
The `multistart` variant allows starting multiple WildFly Swarm{ndash}built applications using Maven GAVs to support complex testing scenarios.

stop::
Stops any previously started applications.
+
NOTE: The `stop` goal can only stop applications that were started _in the same Maven execution_.

[#maven-plugin-configuration]
== Configuration Options

The plugin accepts the following options:

bundleDependencies::
If true, dependencies will be included in the `-swarm.jar` file.
Otherwise, they will be resolved from `$M2_REPO` or the network at runtime.
+
[cols="1,2a"]
|===
|Property
|`swarm.bundleDependencies`

|Default
|true

|Used by
|`package`
|===

debug::
The port to use for debugging.
If set, the swarm process will suspend on start and open a debugger on this port.
+
[cols="1,2a"]
|===
|Property
|`swarm.debug.port`

|Default
|

|Used by
|`run`, `start`
|===

environment::
A properties-style list of environment variables to use when executing the application.
+
[cols="1,2a"]
|===
|Property
|_none_

|Default
|

|Used by
|`multistart`, `run`, `start`
|===

environmentFile::
A `.properties` file with environment variables to use when executing the application.
+
[cols="1,2a"]
|===
|Property
|`swarm.environmentFile`

|Default
|

|Used by
|`multistart`, `run`, `start`
|===

fractionDetectMode::
+
--
The mode of fraction detection. The available options are:

* `when_missing`: Runs only when no WildFly Swarm dependencies are found.
* `force`: Always run, and merge any detected fractions with the existing dependencies. Existing dependencies take precedence.
* `never`: Disable fraction detection.

[cols="1,2a"]
|===
|Property
|`swarm.detect.mode`

|Default
|`when_missing`

|Used by
|`package`, `run`, `start`
|===
--

fractions::
+
--
A list of extra fractions to include when auto-detection is used. It is useful for fractions that cannot be detected or user-provided fractions.

The format of specifying a fraction can be:
* `group:artifact:version`
* `artifact:version`
* `artifact`

If no group is provided, `org.wildfly.swarm` is assumed.

If no version is provided, the version is taken from the WildFly Swarm BOM for the version of the plugin you are using.

If the value starts with the character `!` a corresponding auto-detected fraction is not installed (unless it's a dependency of any other fraction).
In the following example the Undertow fraction is not installed even if your application references a class from the `javax.servlet` package:

[source,xml]
----
<plugin>
  <groupId>org.wildfly.swarm</groupId>
  <artifactId>wildfly-swarm-plugin</artifactId>
  <version>${version.wildfly-swarm}</version>
  <executions>
    <execution>
      <goals>
        <goal>package</goal>
      </goals>
      <configuration>
       <fractions>
         <fraction>!undertow</fraction>
       </fractions>
      </configuration>
    </execution>
  </executions>
</plugin>
----

[cols="1,2a"]
|===
|Property
|_none_

|Default
|

|Used by
|`package`, `run`, `start`
|===
--

ifndef::product[]
hollow::
Specifies if the resulting executable JAR should be hollow, and therefore not include the default deployment.
+
[cols="1,2a"]
|===
|Property
{'fraction_non_alphanumeric': 0.11796838679683867, 'fraction_numerical': 0.00395165039516504, 'mean_word_length': 4.470438652256834, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '499818', 'n_tokens_mistral': 2742, 'n_tokens_neox': 2582, 'n_words': 977}