Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
17fa215c
Commit
17fa215c
authored
Apr 29, 2021
by
Scott Frederick
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-26312
parents
4abd6b13
c37b9b8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
0 deletions
+131
-0
BuildImageTests.java
.../java/org/springframework/boot/maven/BuildImageTests.java
+31
-0
pom.xml
...in/src/intTest/projects/build-image-zip-packaging/pom.xml
+32
-0
SampleApplication.java
...p-packaging/src/main/java/org/test/SampleApplication.java
+28
-0
BuildImageMojo.java
...n/java/org/springframework/boot/maven/BuildImageMojo.java
+40
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java
View file @
17fa215c
...
@@ -16,12 +16,16 @@
...
@@ -16,12 +16,16 @@
package
org
.
springframework
.
boot
.
maven
;
package
org
.
springframework
.
boot
.
maven
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.stream.Collectors
;
import
org.junit.jupiter.api.TestTemplate
;
import
org.junit.jupiter.api.TestTemplate
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
...
@@ -272,6 +276,33 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests {
...
@@ -272,6 +276,33 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests {
});
});
}
}
@TestTemplate
void
whenBuildImageIsInvokedWithZipPackaging
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"build-image-zip-packaging"
).
goals
(
"package"
)
.
systemProperty
(
"spring-boot.build-image.pullPolicy"
,
"IF_NOT_PRESENT"
)
.
prepare
(
this
::
writeLongNameResource
).
execute
((
project
)
->
{
File
jar
=
new
File
(
project
,
"target/build-image-zip-packaging-0.0.1.BUILD-SNAPSHOT.jar"
);
assertThat
(
jar
).
isFile
();
assertThat
(
buildLog
(
project
)).
contains
(
"Building image"
)
.
contains
(
"docker.io/library/build-image-zip-packaging:0.0.1.BUILD-SNAPSHOT"
)
.
contains
(
"Successfully built image"
);
ImageReference
imageReference
=
ImageReference
.
of
(
ImageName
.
of
(
"build-image-zip-packaging"
),
"0.0.1.BUILD-SNAPSHOT"
);
try
(
GenericContainer
<?>
container
=
new
GenericContainer
<>(
imageReference
.
toString
()))
{
container
.
waitingFor
(
Wait
.
forLogMessage
(
"Launched\\n"
,
1
)).
start
();
container
.
copyFileFromContainer
(
"/workspace/META-INF/MANIFEST.MF"
,
(
inputStream
)
->
{
String
text
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
))
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
assertThat
(
text
).
contains
(
"Main-Class: org.springframework.boot.loader.PropertiesLauncher"
);
return
null
;
});
}
finally
{
removeImage
(
imageReference
);
}
});
}
@TestTemplate
@TestTemplate
void
failsWhenPublishWithoutPublishRegistryConfigured
(
MavenBuild
mavenBuild
)
{
void
failsWhenPublishWithoutPublishRegistryConfigured
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"build-image"
).
goals
(
"package"
).
systemProperty
(
"spring-boot.build-image.publish"
,
"true"
)
mavenBuild
.
project
(
"build-image"
).
goals
(
"package"
).
systemProperty
(
"spring-boot.build-image.publish"
,
"true"
)
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-zip-packaging/pom.xml
0 → 100644
View file @
17fa215c
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.springframework.boot.maven.it
</groupId>
<artifactId>
build-image-zip-packaging
</artifactId>
<version>
0.0.1.BUILD-SNAPSHOT
</version>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
@java.version@
</maven.compiler.source>
<maven.compiler.target>
@java.version@
</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>
@project.groupId@
</groupId>
<artifactId>
@project.artifactId@
</artifactId>
<version>
@project.version@
</version>
<executions>
<execution>
<goals>
<goal>
build-image
</goal>
</goals>
</execution>
</executions>
<configuration>
<layout>
ZIP
</layout>
</configuration>
</plugin>
</plugins>
</build>
</project>
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-zip-packaging/src/main/java/org/test/SampleApplication.java
0 → 100644
View file @
17fa215c
/*
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
test
;
public
class
SampleApplication
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Launched"
);
synchronized
(
args
)
{
args
.
wait
();
// Prevent exit"
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java
View file @
17fa215c
...
@@ -50,6 +50,7 @@ import org.springframework.boot.buildpack.platform.io.Owner;
...
@@ -50,6 +50,7 @@ import org.springframework.boot.buildpack.platform.io.Owner;
import
org.springframework.boot.buildpack.platform.io.TarArchive
;
import
org.springframework.boot.buildpack.platform.io.TarArchive
;
import
org.springframework.boot.loader.tools.EntryWriter
;
import
org.springframework.boot.loader.tools.EntryWriter
;
import
org.springframework.boot.loader.tools.ImagePackager
;
import
org.springframework.boot.loader.tools.ImagePackager
;
import
org.springframework.boot.loader.tools.LayoutFactory
;
import
org.springframework.boot.loader.tools.Libraries
;
import
org.springframework.boot.loader.tools.Libraries
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -159,6 +160,45 @@ public class BuildImageMojo extends AbstractPackagerMojo {
...
@@ -159,6 +160,45 @@ public class BuildImageMojo extends AbstractPackagerMojo {
@Parameter
@Parameter
private
Docker
docker
;
private
Docker
docker
;
/**
* The type of archive (which corresponds to how the dependencies are laid out inside
* it). Possible values are {@code JAR}, {@code WAR}, {@code ZIP}, {@code DIR},
* {@code NONE}. Defaults to a guess based on the archive type.
* @since 2.3.11
*/
@Parameter
private
LayoutType
layout
;
/**
* The layout factory that will be used to create the executable archive if no
* explicit layout is set. Alternative layouts implementations can be provided by 3rd
* parties.
* @since 2.3.11
*/
@Parameter
private
LayoutFactory
layoutFactory
;
/**
* Return the type of archive that should be used when buiding the image.
* @return the value of the {@code layout} parameter, or {@code null} if the parameter
* is not provided
*/
@Override
protected
LayoutType
getLayout
()
{
return
this
.
layout
;
}
/**
* Return the layout factory that will be used to determine the {@link LayoutType} if
* no explicit layout is set.
* @return the value of the {@code layoutFactory} parameter, or {@code null} if the
* parameter is not provided
*/
@Override
protected
LayoutFactory
getLayoutFactory
()
{
return
this
.
layoutFactory
;
}
@Override
@Override
public
void
execute
()
throws
MojoExecutionException
{
public
void
execute
()
throws
MojoExecutionException
{
if
(
this
.
project
.
getPackaging
().
equals
(
"pom"
))
{
if
(
this
.
project
.
getPackaging
().
equals
(
"pom"
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment