ShrinkWrap Spring Boot :: API

Parent POM for JBoss projects. Provides default project build configuration.

License

License

Categories

Categories

JBoss Container Application Servers Spring Boot Microservices
GroupId

GroupId

org.jboss.shrinkwrap
ArtifactId

ArtifactId

shrinkwrap-spring-boot-api
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

ShrinkWrap Spring Boot :: API
Parent POM for JBoss projects. Provides default project build configuration.
Project Organization

Project Organization

JBoss by Red Hat

Download shrinkwrap-spring-boot-api

How to add to project

<!-- https://jarcasting.com/artifacts/org.jboss.shrinkwrap/shrinkwrap-spring-boot-api/ -->
<dependency>
    <groupId>org.jboss.shrinkwrap</groupId>
    <artifactId>shrinkwrap-spring-boot-api</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.jboss.shrinkwrap/shrinkwrap-spring-boot-api/
implementation 'org.jboss.shrinkwrap:shrinkwrap-spring-boot-api:0.0.1'
// https://jarcasting.com/artifacts/org.jboss.shrinkwrap/shrinkwrap-spring-boot-api/
implementation ("org.jboss.shrinkwrap:shrinkwrap-spring-boot-api:0.0.1")
'org.jboss.shrinkwrap:shrinkwrap-spring-boot-api:jar:0.0.1'
<dependency org="org.jboss.shrinkwrap" name="shrinkwrap-spring-boot-api" rev="0.0.1">
  <artifact name="shrinkwrap-spring-boot-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jboss.shrinkwrap', module='shrinkwrap-spring-boot-api', version='0.0.1')
)
libraryDependencies += "org.jboss.shrinkwrap" % "shrinkwrap-spring-boot-api" % "0.0.1"
[org.jboss.shrinkwrap/shrinkwrap-spring-boot-api "0.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.jboss.shrinkwrap : shrinkwrap-api jar 1.2.6

Project Modules

There are no modules declared in this project.

Spring Boot ShrinkWrap Archive

This specific ShrinkWrap archive allows you to create Spring Boot archives. The basic archive is class is org.shrinkwrap.springboot.api.spec.SpringBootArchive.

Spring Boot Archive layout

Spring Boot has used different layouts in different versions. As a result, the first action required before adding any resource to a SpringBootArchive is to set the layout. It is important to set the layout according to the Spring Boot version that is going to be added as libraries to the archive. By default the archive will use the original layout used from versions 1.0.x to 1.3.x. You can set a different layout by using the setSpringBootLayout method.

The standard formats used by Spring Boot are defined as constants in the class org.shrinkwrap.springboot.impl.SpringBootLayouts.

Custom layout are also possible by implementing the org.shrinkwrap.springboot.SpringBootLayout interface. Notice that you define a custom layout, it won’t be recognized by the default launcher class, you would also need to implement your own Spring Boot launcher implementation class. An example can be seen by looking at SpringBootTest.should_create_custom_spring_boot_15jar_archive() test method.

Spring Boot Archive usage

To create a Spring Boot archive, you need to pass org.shrinkwrap.springboot.api.spec.SpringBootArchive to the ShrinkWrap.create method.

ShrinkWrap.create(SpringBootArchive.class)
        .setSpringBootLayout(SpringBootLayouts.SPRING_BOOT_14) // (1)

        .addClasses(Application.class, .HelloController.class) // (2)

        .addAsLibraries(Maven.resolver()
                   .resolve("org.springframework.boot:spring-boot-starter-web:1.4.4.RELEASE")
                   .withTransitivity()
                   .as(JavaArchive.class)
        ) // (3)

       .addAsLauncherLibraries(Maven.resolver()
                    .resolve("org.springframework.boot:spring-boot-loader:1.4.4.RELEASE")
                    .withTransitivity()
                    .as(JavaArchive.class)
       ) // (4)

       .addAsWebResource(new StringAsset("world"), "hello") // (5)

       .setSpringBootManifest(Application.class.getName(), "1.4.4.RELEASE"); // (6)
  1. First step must be setting the file layout

  2. Classes can be added in the same way as a JavaArchive

  3. Libraries must be bundled inside the archive (in a libraries directory). addAsLibraries adds them in correct place.

  4. Spring Boot applications need a launcher to run.

  5. Applications can optionally contain static web resources. addAsWebResource allows adding any static web resource, similar to WebArchive.

  6. As in the case of an executable JavaArchive, A Spring Boot application requires a manifest. setSpringBootManifest method prepares a manifest in the expected format.

Notice that the layout, the application libraries, the launcher, and the manifest all reference exactly the same Spring Boot version.

Important
To materialize a Spring Boot application, you need to use ZipStoredExporter, for example springBootArchive.as(ZipStoredExporter.class).exportTo(new File("/tmp/app.jar")); See SpringBootTest.validateSpringBootArchive(…​) for an example.
org.jboss.shrinkwrap

ShrinkWrap

Versions

Version
0.0.1