Skip to content

Commit 5e539c7

Browse files
committed
1 parent c93e248 commit 5e539c7

File tree

28 files changed

+102
-33
lines changed

28 files changed

+102
-33
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ You can override this behaviour as shown in the <<build-image.examples.builder-c
209209
For more details, see also <<build-image.examples,examples>>.
210210

211211
include::goals/build-image.adoc[leveloffset=+1]
212+
include::goals/build-image-no-fork.adoc[leveloffset=+1]
212213

213214

214215

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/maven/packaging-oci-image/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<executions>
1313
<execution>
1414
<goals>
15-
<goal>build-image</goal>
15+
<goal>build-image-no-fork</goal>
1616
</goals>
1717
</execution>
1818
</executions>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-bad-buildpack/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-bindings/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-builder-error/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-caches-multiple/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-caches/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-classifier-source-with-repackage/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</execution>
4242
<execution>
4343
<goals>
44-
<goal>build-image</goal>
44+
<goal>build-image-no-fork</goal>
4545
</goals>
4646
<configuration>
4747
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-classifier-source/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<executions>
3636
<execution>
3737
<goals>
38-
<goal>build-image</goal>
38+
<goal>build-image-no-fork</goal>
3939
</goals>
4040
<configuration>
4141
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-classifier-with-repackage/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</execution>
2626
<execution>
2727
<goals>
28-
<goal>build-image</goal>
28+
<goal>build-image-no-fork</goal>
2929
</goals>
3030
<configuration>
3131
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-classifier/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-cmd-line/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
</execution>
2525
</executions>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-builder/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-buildpacks/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-name/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-empty-env-entry/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-final-name/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<execution>
2121
<goals>
2222
<goal>repackage</goal>
23-
<goal>build-image</goal>
23+
<goal>build-image-no-fork</goal>
2424
</goals>
2525
<configuration>
2626
<finalName>final-name</finalName>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-multi-module/app/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<executions>
2828
<execution>
2929
<goals>
30-
<goal>build-image</goal>
30+
<goal>build-image-no-fork</goal>
3131
</goals>
3232
<configuration>
3333
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-network/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-publish/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-tags/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-war-packaging/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<executions>
2121
<execution>
2222
<goals>
23-
<goal>build-image</goal>
23+
<goal>build-image-no-fork</goal>
2424
</goals>
2525
<configuration>
2626
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-with-repackage/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</execution>
2626
<execution>
2727
<goals>
28-
<goal>build-image</goal>
28+
<goal>build-image-no-fork</goal>
2929
</goals>
3030
<configuration>
3131
<image>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-zip-packaging/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
</execution>
2525
</executions>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<executions>
2020
<execution>
2121
<goals>
22-
<goal>build-image</goal>
22+
<goal>build-image-no-fork</goal>
2323
</goals>
2424
<configuration>
2525
<image>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.maven;
18+
19+
import org.apache.maven.plugins.annotations.Execute;
20+
import org.apache.maven.plugins.annotations.LifecyclePhase;
21+
import org.apache.maven.plugins.annotations.Mojo;
22+
import org.apache.maven.plugins.annotations.ResolutionScope;
23+
24+
/**
25+
* {@link BuildImageMojo implementation} that forks the lifecycle to make sure that
26+
* {@code package} ran. This goal is suitable for command-line invocation. If you need to
27+
* configure a mojo {@code execution} in your build, use {@link BuildImageNoForkMojo}
28+
* instead.
29+
*
30+
* @author Stephane Nicoll
31+
* @since 3.0.0
32+
*/
33+
@Mojo(name = "build-image", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true,
34+
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
35+
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
36+
@Execute(phase = LifecyclePhase.PACKAGE)
37+
public class BuildImageForkMojo extends BuildImageMojo {
38+
39+
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@
3232
import org.apache.maven.artifact.Artifact;
3333
import org.apache.maven.plugin.MojoExecutionException;
3434
import org.apache.maven.plugin.logging.Log;
35-
import org.apache.maven.plugins.annotations.Execute;
36-
import org.apache.maven.plugins.annotations.LifecyclePhase;
37-
import org.apache.maven.plugins.annotations.Mojo;
3835
import org.apache.maven.plugins.annotations.Parameter;
39-
import org.apache.maven.plugins.annotations.ResolutionScope;
4036

4137
import org.springframework.boot.buildpack.platform.build.AbstractBuildLog;
4238
import org.springframework.boot.buildpack.platform.build.BuildLog;
@@ -62,11 +58,7 @@
6258
* @author Jeroen Meijer
6359
* @since 2.3.0
6460
*/
65-
@Mojo(name = "build-image", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true,
66-
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
67-
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
68-
@Execute(phase = LifecyclePhase.PACKAGE)
69-
public class BuildImageMojo extends AbstractPackagerMojo {
61+
public abstract class BuildImageMojo extends AbstractPackagerMojo {
7062

7163
static {
7264
System.setProperty("org.slf4j.simpleLogger.log.org.apache.http.wire", "ERROR");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.maven;
18+
19+
import org.apache.maven.plugins.annotations.LifecyclePhase;
20+
import org.apache.maven.plugins.annotations.Mojo;
21+
import org.apache.maven.plugins.annotations.ResolutionScope;
22+
23+
/**
24+
* {@link BuildImageMojo implementation} that does not fork the lifecycle to make sure
25+
* that {@code package} ran. This goal should be used when configuring a mojo
26+
* {@code execution} in your build. To invoke the goal on the command-line, use
27+
* {@link BuildImageForkMojo} instead.
28+
*
29+
* @author Stephane Nicoll
30+
* @since 3.0.0
31+
*/
32+
@Mojo(name = "build-image-no-fork", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true,
33+
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
34+
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
35+
public class BuildImageNoForkMojo extends BuildImageMojo {
36+
37+
}

0 commit comments

Comments
 (0)