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}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tasks.getByName<BootJar>("bootJar") {
|
|
|
|
|
mainClassName = "com.example.ExampleApplication"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// tag::publish[]
|
|
|
|
|
tasks.getByName<BootBuildImage>("bootBuildImage") {
|
|
|
|
|
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"
|
|
|
|
|
url = "https://docker.example.com/v1/"
|
|
|
|
|
email = "user@example.com"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// end::publish[]
|
2021-02-27 04:07:17 +08:00
|
|
|
|
|
|
|
|
tasks.register("bootBuildImagePublish") {
|
|
|
|
|
doFirst {
|
|
|
|
|
println(tasks.getByName<BootBuildImage>("bootBuildImage").isPublish)
|
|
|
|
|
}
|
|
|
|
|
}
|