2020-09-19 06:59:10 +08:00
|
|
|
import org.springframework.boot.gradle.tasks.bundling.BootJar
|
|
|
|
|
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
|
|
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
|
java
|
|
|
|
|
id("org.springframework.boot") version "{gradle-project-version}"
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-04 04:27:46 +08:00
|
|
|
tasks.named<BootJar>("bootJar") {
|
2021-07-26 21:36:55 +08:00
|
|
|
mainClass.set("com.example.ExampleApplication")
|
2020-09-19 06:59:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// tag::publish[]
|
2022-03-04 04:27:46 +08:00
|
|
|
tasks.named<BootBuildImage>("bootBuildImage") {
|
2020-09-19 06:59:10 +08:00
|
|
|
imageName = "docker.example.com/library/${project.name}"
|
2021-02-27 04:07:17 +08:00
|
|
|
isPublish = true
|
2020-09-19 06:59:10 +08:00
|
|
|
docker {
|
|
|
|
|
publishRegistry {
|
|
|
|
|
username = "user"
|
|
|
|
|
password = "secret"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// end::publish[]
|
2021-02-27 04:07:17 +08:00
|
|
|
|
|
|
|
|
tasks.register("bootBuildImagePublish") {
|
2022-03-04 04:27:46 +08:00
|
|
|
doFirst {
|
|
|
|
|
println(tasks.getByName<BootBuildImage>("bootBuildImage").isPublish)
|
|
|
|
|
}
|
2021-02-27 04:07:17 +08:00
|
|
|
}
|