Chapter 6. Using a BOM

To explicitly specify the Thorntail fractions your application uses, instead of relying on auto-detection, Thorntail includes a set of BOMs (bill of materials) which you can use instead of having to track and update Maven artifact versions in several places.

6.1. Thorntail product BOM types

Thorntail is described as just enough app-server, which means it consists of multiple pieces. Your application includes only the pieces it needs.

When using the Thorntail product, you can specify the following Maven BOMs:

bom
All fractions available in the product.
bom-certified
All community fractions that have been certified against the product. Any fraction used from bom-certified is unsupported.

6.2. Specifying a BOM for in your application

Importing a specific BOM in the pom.xml file in your application allows you to track all your application dependencies in one place.

Note

One shortcoming of importing a Maven BOM import is that it does not handle the configuration on the level of <pluginManagement>. When you use the Thorntail Maven Plugin, you must specify the version of the plugin to use.

Thanks to the property you use in your pom.xml file, you can easily ensure that your plugin usage matches the release of Thorntail that you are targeting with the BOM import.

<plugins>
  <plugin>
    <groupId>io.thorntail</groupId>
    <artifactId>thorntail-maven-plugin</artifactId>
    <version>${version.thorntail}</version>
      ...
  </plugin>
</plugins>

Prerequisites

  • Your application as a Maven-based project with a pom.xml file.

Procedure

  1. Include a bom artifact in your pom.xml.

    Tracking the current version of Thorntail through a property in your pom.xml is recommended.

    <properties>
      <version.thorntail>2.7.3.Final-redhat-00001</version.thorntail>
    </properties>

    Import BOMs in the <dependencyManagement> section. Specify the <type>pom</type> and <scope>import</scope>.

    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>io.thorntail</groupId>
          <artifactId>bom</artifactId>
          <version>${version.thorntail}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>

    In the example above, the bom artifact is imported to ensure that only stable fractions are available.

    By including the BOMs of your choice in the <dependencyManagement> section, you have:

    • Provided version-management for any Thorntail artifacts you subsequently choose to use.
    • Provided support to your IDE for auto-completing known artifacts when you edit your the pom.xml file of your application.
  2. Include Thorntail dependencies.

    Even though you imported the Thorntail BOMs in the <dependencyManagement> section, your application still has no dependencies on Thorntail artifacts.

    To include Thorntail artifact dependencies based on the capabilities your application, enter the relevant artifacts as <dependency> elements:

    Note

    You do not have to specify the version of the artifacts because the BOM imported in <dependencyManagement> handles that.

    <dependencies>
      <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>jaxrs</artifactId>
      </dependency>
      <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>datasources</artifactId>
      </dependency>
    </dependencies>

    In the example above, we include explicit dependencies on the jaxrs and datasources fractions, which will provide transitive inclusion of others, for example undertow.