mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '2.4.x'
Closes gh-25469
This commit is contained in:
commit
434db48969
@ -13,3 +13,10 @@ bootBuildImage {
|
||||
runImage = "mine/java-cnb-run"
|
||||
}
|
||||
// end::builder[]
|
||||
|
||||
task bootBuildImageBuilder {
|
||||
doFirst {
|
||||
println("builder=${tasks.bootBuildImage.builder}")
|
||||
println("runImage=${tasks.bootBuildImage.runImage}")
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.springframework.boot.gradle.tasks.bundling.BootJar
|
||||
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
|
||||
|
||||
plugins {
|
||||
java
|
||||
@ -15,3 +16,10 @@ tasks.getByName<BootBuildImage>("bootBuildImage") {
|
||||
runImage = "mine/java-cnb-run"
|
||||
}
|
||||
// end::builder[]
|
||||
|
||||
tasks.register("bootBuildImageBuilder") {
|
||||
doFirst {
|
||||
println("builder=${tasks.getByName<BootBuildImage>("bootBuildImage").builder}")
|
||||
println("runImage=${tasks.getByName<BootBuildImage>("bootBuildImage").runImage}")
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,14 @@ plugins {
|
||||
|
||||
// tag::buildpacks[]
|
||||
tasks.getByName<BootBuildImage>("bootBuildImage") {
|
||||
buildpacks = listOf("file:///path/to/example-buildpack.tgz", "urn:cnb:builder:paketo-buildpacks/java")
|
||||
buildpacks = listOf("file:///path/to/example-buildpack.tgz", "urn:cnb:builder:paketo-buildpacks/java")
|
||||
}
|
||||
// end::buildpacks[]
|
||||
|
||||
tasks.register("bootBuildImageBuildpacks") {
|
||||
doFirst {
|
||||
for((reference) in tasks.getByName<BootBuildImage>("bootBuildImage").buildpacks) {
|
||||
print(reference)
|
||||
}
|
||||
}
|
||||
doFirst {
|
||||
for(reference in tasks.getByName<BootBuildImage>("bootBuildImage").buildpacks) {
|
||||
print(reference)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,3 +16,9 @@ bootBuildImage {
|
||||
}
|
||||
}
|
||||
// end::docker-auth-token[]
|
||||
|
||||
task bootBuildImageDocker {
|
||||
doFirst {
|
||||
println("token=${tasks.bootBuildImage.docker.builderRegistry.token}")
|
||||
}
|
||||
}
|
||||
|
@ -19,3 +19,9 @@ tasks.getByName<BootBuildImage>("bootBuildImage") {
|
||||
}
|
||||
}
|
||||
// end::docker-auth-token[]
|
||||
|
||||
tasks.register("bootBuildImageDocker") {
|
||||
doFirst {
|
||||
println("token=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.builderRegistry.token}")
|
||||
}
|
||||
}
|
||||
|
@ -19,3 +19,12 @@ bootBuildImage {
|
||||
}
|
||||
}
|
||||
// end::docker-auth-user[]
|
||||
|
||||
task bootBuildImageDocker {
|
||||
doFirst {
|
||||
println("username=${tasks.bootBuildImage.docker.builderRegistry.username}")
|
||||
println("password=${tasks.bootBuildImage.docker.builderRegistry.password}")
|
||||
println("url=${tasks.bootBuildImage.docker.builderRegistry.url}")
|
||||
println("email=${tasks.bootBuildImage.docker.builderRegistry.email}")
|
||||
}
|
||||
}
|
||||
|
@ -22,3 +22,12 @@ tasks.getByName<BootBuildImage>("bootBuildImage") {
|
||||
}
|
||||
}
|
||||
// end::docker-auth-user[]
|
||||
|
||||
tasks.register("bootBuildImageDocker") {
|
||||
doFirst {
|
||||
println("username=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.builderRegistry.username}")
|
||||
println("password=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.builderRegistry.password}")
|
||||
println("url=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.builderRegistry.url}")
|
||||
println("email=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.builderRegistry.email}")
|
||||
}
|
||||
}
|
||||
|
@ -16,3 +16,11 @@ bootBuildImage {
|
||||
}
|
||||
}
|
||||
// end::docker-host[]
|
||||
|
||||
task bootBuildImageDocker {
|
||||
doFirst {
|
||||
println("host=${tasks.bootBuildImage.docker.host}")
|
||||
println("tlsVerify=${tasks.bootBuildImage.docker.tlsVerify}")
|
||||
println("certPath=${tasks.bootBuildImage.docker.certPath}")
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,16 @@ tasks.getByName<BootJar>("bootJar") {
|
||||
tasks.getByName<BootBuildImage>("bootBuildImage") {
|
||||
docker {
|
||||
host = "tcp://192.168.99.100:2376"
|
||||
tlsVerify = true
|
||||
isTlsVerify = true
|
||||
certPath = "/home/users/.minikube/certs"
|
||||
}
|
||||
}
|
||||
// end::docker-host[]
|
||||
|
||||
tasks.register("bootBuildImageDocker") {
|
||||
doFirst {
|
||||
println("host=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.host}")
|
||||
println("tlsVerify=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.isTlsVerify}")
|
||||
println("certPath=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.certPath}")
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Jean-Baptiste Nizet
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
@ExtendWith(GradleMultiDslExtension.class)
|
||||
class PackagingDocumentationTests {
|
||||
@ -221,14 +222,21 @@ class PackagingDocumentationTests {
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImageWithCustomBuildpackJvmVersion() throws IOException {
|
||||
void bootBuildImageWithBuilder() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-builder")
|
||||
.build("bootBuildImageBuilder");
|
||||
assertThat(result.getOutput()).contains("builder=mine/java-cnb-builder").contains("runImage=mine/java-cnb-run");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImageWithCustomBuildpackJvmVersion() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-env")
|
||||
.build("bootBuildImageEnvironment");
|
||||
assertThat(result.getOutput()).contains("BP_JVM_VERSION=8.*");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImageWithCustomProxySettings() throws IOException {
|
||||
void bootBuildImageWithCustomProxySettings() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-env-proxy")
|
||||
.build("bootBuildImageEnvironment");
|
||||
assertThat(result.getOutput()).contains("HTTP_PROXY=http://proxy.example.com")
|
||||
@ -236,19 +244,50 @@ class PackagingDocumentationTests {
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImageWithCustomImageName() throws IOException {
|
||||
void bootBuildImageWithCustomImageName() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-name")
|
||||
.build("bootBuildImageName");
|
||||
assertThat(result.getOutput()).contains("example.com/library/" + this.gradleBuild.getProjectDir().getName());
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImagePublish() throws IOException {
|
||||
void bootBuildImageWithDockerHost() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-host")
|
||||
.build("bootBuildImageDocker");
|
||||
assertThat(result.getOutput()).contains("host=tcp://192.168.99.100:2376").contains("tlsVerify=true")
|
||||
.contains("certPath=/home/users/.minikube/certs");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImageWithDockerUserAuth() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-auth-user")
|
||||
.build("bootBuildImageDocker");
|
||||
assertThat(result.getOutput()).contains("username=user").contains("password=secret")
|
||||
.contains("url=https://docker.example.com/v1/").contains("email=user@example.com");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImageWithDockerTokenAuth() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-auth-token")
|
||||
.build("bootBuildImageDocker");
|
||||
assertThat(result.getOutput()).contains("token=9cbaf023786cd7...");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImagePublish() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-publish")
|
||||
.build("bootBuildImagePublish");
|
||||
assertThat(result.getOutput()).contains("true");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootBuildImageWithBuildpacks() {
|
||||
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-buildpacks")
|
||||
.build("bootBuildImageBuildpacks");
|
||||
assertThat(result.getOutput()).contains("file:///path/to/example-buildpack.tgz")
|
||||
.contains("urn:cnb:builder:paketo-buildpacks/java");
|
||||
}
|
||||
|
||||
protected void jarFile(File file) throws IOException {
|
||||
try (JarOutputStream jar = new JarOutputStream(new FileOutputStream(file))) {
|
||||
jar.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
|
||||
|
Loading…
Reference in New Issue
Block a user