You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Lifecycle.java
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
1
[[build-image]]
2
2
== Packaging OCI images
3
-
4
3
The plugin can create an https://github.com/opencontainers/image-spec[OCI image] from executable jars using https://buildpacks.io[Cloud Native Buildpacks].
5
4
Images can be built using the `bootBuildImage` task and a local Docker installation.
6
5
The task is automatically created when the `java` plugin is applied and is an instance of {boot-build-image-javadoc}[`BootBuildImage`].
7
6
7
+
8
+
8
9
[[build-image-customization]]
9
10
=== Image Customizations
10
11
The plugin invokes a {buildpacks-reference}/concepts/components/builder/[builder] to orchestrate the generation of an image.
@@ -37,12 +38,15 @@ The following table summarizes the available properties and their default values
37
38
| `verboseLogging`
38
39
| Enables verbose logging of builder operations.
39
40
| `false`
40
-
41
41
|===
42
42
43
+
44
+
43
45
[[build-image-examples]]
44
46
=== Examples
45
47
48
+
49
+
46
50
[[build-image-example-custom-image-builder]]
47
51
==== Custom Image Builder
48
52
If you need to customize the builder used to create the image, configure the task as shown in the following example:
The example above assumes that the builder defines a `BP_JAVA_VERSION` property (typically used to customize the JDK version the image should use).
79
83
80
84
85
+
81
86
[[build-image-example-custom-image-name]]
82
87
==== Custom Image Name
83
88
By default, the image name is inferred from the `artifactId` and the `version` of the project, something like `docker.io/library/${project.artifactId}:${project.version}`.
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging.adoc
+4-16Lines changed: 4 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,11 @@
1
1
[[packaging-executable]]
2
2
== Packaging executable archives
3
-
4
3
The plugin can create executable archives (jar files and war files) that contain all of an application's dependencies and can then be run with `java -jar`.
5
4
6
5
7
6
8
7
[[packaging-executable-jars]]
9
8
=== Packaging executable jars
10
-
11
9
Executable jars can be built using the `bootJar` task.
12
10
The task is automatically created when the `java` plugin is applied and is an instance of {boot-jar-javadoc}[`BootJar`].
13
11
The `assemble` task is automatically configured to depend upon the `bootJar` task so running `assemble` (or `build`) will also run the `bootJar` task.
@@ -16,7 +14,6 @@ The `assemble` task is automatically configured to depend upon the `bootJar` tas
16
14
17
15
[[packaging-executable-wars]]
18
16
=== Packaging executable wars
19
-
20
17
Executable wars can be built using the `bootWar` task.
21
18
The task is automatically created when the `war` plugin is applied and is an instance of {boot-war-javadoc}[`BootWar`].
22
19
The `assemble` task is automatically configured to depend upon the `bootWar` task so running `assemble` (or `build`) will also run the `bootWar` task.
@@ -25,7 +22,6 @@ The `assemble` task is automatically configured to depend upon the `bootWar` tas
25
22
26
23
[[packaging-executable-wars-deployable]]
27
24
==== Packaging executable and deployable wars
28
-
29
25
A war file can be packaged such that it can be executed using `java -jar` and deployed to an external container.
30
26
To do so, the embedded servlet container dependencies should be added to the `providedRuntime` configuration, for example:
31
27
@@ -50,7 +46,6 @@ NOTE: `providedRuntime` is preferred to Gradle's `compileOnly` configuration as,
50
46
51
47
[[packaging-executable-and-normal]]
52
48
=== Packaging executable and normal archives
53
-
54
49
By default, when the `bootJar` or `bootWar` tasks are configured, the `jar` or `war` tasks are disabled.
55
50
A project can be configured to build both an executable archive and a normal archive at the same time by enabling the `jar` or `war` task:
The {boot-jar-javadoc}[`BootJar`] and {boot-war-javadoc}[`BootWar`] tasks are subclasses of Gradle's `Jar` and `War` tasks respectively.
90
84
As a result, all of the standard configuration options that are available when packaging a jar or war are also available when packaging an executable jar or war.
91
85
A number of configuration options that are specific to executable jars and wars are also provided.
92
86
93
87
94
88
[[packaging-executable-configuring-main-class]]
95
89
==== Configuring the main class
96
-
97
90
By default, the executable archive's main class will be configured automatically by looking for a class with a `public static void main(String[])` method in directories on the task's classpath.
98
91
99
92
The main class can also be configured explicitly using the task's `mainClassName` property:
If the {application-plugin}[`application` plugin] has been applied its `mainClassName` project property must be configured and can be used for the same purpose:
By default, the `bootJar` tasks builds an archive that contains the application's classes and dependencies in `BOOT-INF/classes` and `BOOT-INF/lib` respectively.
280
268
For cases where a docker image needs to be built from the contents of the jar, the jar format can be enhanced to support layer folders.
281
269
To use this feature, the layering feature must be enabled:
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/publishing.adoc
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,6 @@
5
5
6
6
[[publishing-your-application-maven]]
7
7
=== Publishing with the `maven` plugin
8
-
9
8
When the {maven-plugin}[`maven` plugin] is applied, an `Upload` task for the `bootArchives` configuration named `uploadBootArchives` is automatically created.
10
9
By default, the `bootArchives` configuration contains the archive produced by the `bootJar` or `bootWar` task.
11
10
The `uploadBootArchives` task can be configured to publish the archive to a Maven repository:
When the {dependency-management-plugin}[`io.spring.dependency-management` plugin] is applied to a project, the Spring Boot plugin will automatically import the `spring-boot-dependencies` bom.
54
49
55
50
56
51
57
52
[[reacting-to-other-plugins-application]]
58
53
=== Reacting to the application plugin
59
-
60
54
When Gradle's {application-plugin}[`application` plugin] is applied to a project, the Spring Boot plugin:
61
55
62
56
1. Creates a `CreateStartScripts` task named `bootStartScripts` that will create scripts that launch the artifact in the `bootArchives` configuration using `java -jar`.
@@ -71,5 +65,4 @@ When Gradle's {application-plugin}[`application` plugin] is applied to a project
71
65
72
66
[[reacting-to-other-plugins-maven]]
73
67
=== Reacting to the Maven plugin
74
-
75
68
When Gradle's {maven-plugin}[`maven` plugin] is applied to a project, the Spring Boot plugin will configure the `uploadBootArchives` `Upload` task to ensure that no dependencies are declared in the pom that it generates.
If the {application-plugin}[`application` plugin] has been applied, its `mainClassName` property must be configured and can be used for the same purpose:
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/integration-tests.adoc
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
[[integration-tests]]
2
2
== Running Integration tests
3
-
4
3
While you may start your Spring Boot application very easily from your test (or test suite) itself, it may be desirable to handle that in the build itself.
5
4
To make sure that the lifecycle of your Spring Boot application is properly managed around your integration tests, you can use the `start` and `stop` goals, as shown in the following example:
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,8 @@ It is possible to automate the creation of an image whenever the `package` phase
30
30
TIP: While the buildpack runs from an <<repackage,executable archive>>, it is not necessary to execute the `repackage` goal first as the executable archive is created automatically if necessary.
31
31
When the `build-image` repackages the application, it applies the same settings as the `repackage` goal would, i.e. dependencies can be excluded using one of the exclude options, and Devtools is automatically excluded by default (you can control that using the `excludeDevtools` property).
32
32
33
+
34
+
33
35
[[build-image-customization]]
34
36
=== Image Customizations
35
37
The plugin invokes a {buildpacks-reference}/concepts/components/builder/[builder] to orchestrate the generation of an image.
@@ -62,17 +64,19 @@ The following table summarizes the available properties and their default values
62
64
| `verboseLogging`
63
65
| Enables verbose logging of builder operations.
64
66
| `false`
65
-
66
67
|===
67
68
68
69
For more details, see <<build-image-example-custom-image-builder,custom image builder>> and <<build-image-example-custom-image-name,custom image name>>.
69
70
70
71
include::goals/build-image.adoc[leveloffset=+1]
71
72
72
73
74
+
73
75
[[build-image-examples]]
74
76
=== Examples
75
77
78
+
79
+
76
80
[[build-image-example-custom-image-builder]]
77
81
==== Custom Image Builder
78
82
If you need to customize the builder used to create the image, configure yours as shown in the following example:
0 commit comments