Skip to content

Commit

Permalink
Use configuration avoidance APIs in Gradle plugin's docs
Browse files Browse the repository at this point in the history
Closes gh-30056
  • Loading branch information
wilkinsona committed Mar 3, 2022
1 parent 58e2adb commit e7566e9
Show file tree
Hide file tree
Showing 60 changed files with 135 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
apply(plugin = "io.spring.dependency-management")
// end::apply[]

task("verify") {
tasks.register("verify") {
doLast {
project.plugins.getPlugin(JavaPlugin::class)
project.plugins.getPlugin(io.spring.gradle.dependencymanagement.DependencyManagementPlugin::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ the<DependencyManagementExtension>().apply {
}
}

task("slf4jVersion") {
tasks.register("slf4jVersion") {
doLast {
println(project.the<DependencyManagementExtension>().managedVersions["org.slf4j:slf4j-api"])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ plugins {
id 'org.springframework.boot' version '{gradle-project-version}'
}

bootJar {
tasks.named("bootJar") {
mainClass = 'com.example.ExampleApplication'
}

// tag::builder[]
bootBuildImage {
tasks.named("bootBuildImage") {
builder = "mine/java-cnb-builder"
runImage = "mine/java-cnb-run"
}
// end::builder[]

task bootBuildImageBuilder {
tasks.register("bootBuildImageBuilder") {
doFirst {
println("builder=${tasks.bootBuildImage.builder}")
println("runImage=${tasks.bootBuildImage.runImage}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ plugins {
id("org.springframework.boot") version "{gradle-project-version}"
}

tasks.getByName<BootJar>("bootJar") {
tasks.named<BootJar>("bootJar") {
mainClass.set("com.example.ExampleApplication")
}

// tag::builder[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
builder = "mine/java-cnb-builder"
runImage = "mine/java-cnb-run"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

// tag::buildpacks[]
bootBuildImage {
tasks.named("bootBuildImage") {
buildpacks = ["file:///path/to/example-buildpack.tgz", "urn:cnb:builder:paketo-buildpacks/java"]
}
// end::buildpacks[]

task bootBuildImageBuildpacks {
tasks.register("bootBuildImageBuildpacks") {
doFirst {
bootBuildImage.buildpacks.each { reference -> println "$reference" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

// tag::buildpacks[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
buildpacks = listOf("file:///path/to/example-buildpack.tgz", "urn:cnb:builder:paketo-buildpacks/java")
}
// end::buildpacks[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
id 'org.springframework.boot' version '{gradle-project-version}'
}

bootJar {
tasks.named("bootJar") {
mainClass = 'com.example.ExampleApplication'
}

// tag::docker-auth-token[]
bootBuildImage {
tasks.named("bootBuildImage") {
docker {
builderRegistry {
token = "9cbaf023786cd7..."
Expand All @@ -17,7 +17,7 @@ bootBuildImage {
}
// end::docker-auth-token[]

task bootBuildImageDocker {
tasks.register("bootBuildImageDocker") {
doFirst {
println("token=${tasks.bootBuildImage.docker.builderRegistry.token}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ plugins {
id("org.springframework.boot") version "{gradle-project-version}"
}

tasks.getByName<BootJar>("bootJar") {
tasks.named<BootJar>("bootJar") {
mainClass.set("com.example.ExampleApplication")
}

// tag::docker-auth-token[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
docker {
builderRegistry {
token = "9cbaf023786cd7..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
id 'org.springframework.boot' version '{gradle-project-version}'
}

bootJar {
tasks.named("bootJar") {
mainClass = 'com.example.ExampleApplication'
}

// tag::docker-auth-user[]
bootBuildImage {
tasks.named("bootBuildImage") {
docker {
builderRegistry {
username = "user"
Expand All @@ -20,7 +20,7 @@ bootBuildImage {
}
// end::docker-auth-user[]

task bootBuildImageDocker {
tasks.register("bootBuildImageDocker") {
doFirst {
println("username=${tasks.bootBuildImage.docker.builderRegistry.username}")
println("password=${tasks.bootBuildImage.docker.builderRegistry.password}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ plugins {
id("org.springframework.boot") version "{gradle-project-version}"
}

tasks.getByName<BootJar>("bootJar") {
tasks.named<BootJar>("bootJar") {
mainClass.set("com.example.ExampleApplication")
}

// tag::docker-auth-user[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
docker {
builderRegistry {
username = "user"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
id 'org.springframework.boot' version '{gradle-project-version}'
}

bootJar {
tasks.named("bootJar") {
mainClass = 'com.example.ExampleApplication'
}

// tag::docker-host[]
bootBuildImage {
tasks.named("bootBuildImage") {
docker {
host = "tcp://192.168.99.100:2376"
tlsVerify = true
Expand All @@ -17,7 +17,7 @@ bootBuildImage {
}
// end::docker-host[]

task bootBuildImageDocker {
tasks.register("bootBuildImageDocker") {
doFirst {
println("host=${tasks.bootBuildImage.docker.host}")
println("tlsVerify=${tasks.bootBuildImage.docker.tlsVerify}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ plugins {
id("org.springframework.boot") version "{gradle-project-version}"
}

tasks.getByName<BootJar>("bootJar") {
tasks.named<BootJar>("bootJar") {
mainClass.set("com.example.ExampleApplication")
}

// tag::docker-host[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
docker {
host = "tcp://192.168.99.100:2376"
isTlsVerify = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ plugins {
}

// tag::env[]
bootBuildImage {
tasks.named("bootBuildImage") {
environment = [
"HTTP_PROXY" : "http://proxy.example.com",
"HTTPS_PROXY": "https://proxy.example.com"
]
}
// end::env[]

task bootBuildImageEnvironment {
tasks.register("bootBuildImageEnvironment") {
doFirst {
bootBuildImage.environment.each { name, value -> println "$name=$value" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

// tag::env[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
environment = mapOf("HTTP_PROXY" to "http://proxy.example.com",
"HTTPS_PROXY" to "https://proxy.example.com")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ plugins {
id 'org.springframework.boot' version '{gradle-project-version}'
}

bootJar {
tasks.named("bootJar") {
mainClass = 'com.example.ExampleApplication'
}

// tag::env-runtime[]
bootBuildImage {
tasks.named("bootBuildImage") {
environment = [
"BPE_DELIM_JAVA_TOOL_OPTIONS" : " ",
"BPE_APPEND_JAVA_TOOL_OPTIONS" : "-XX:+HeapDumpOnOutOfMemoryError"
]
}
// end::env-runtime[]

task bootBuildImageEnvironment {
tasks.register("bootBuildImageEnvironment") {
doFirst {
bootBuildImage.environment.each { name, value -> println "$name=$value" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

// tag::env-runtime[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
environment = mapOf(
"BPE_DELIM_JAVA_TOOL_OPTIONS" to " ",
"BPE_APPEND_JAVA_TOOL_OPTIONS" to "-XX:+HeapDumpOnOutOfMemoryError"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

// tag::env[]
bootBuildImage {
tasks.named("bootBuildImage") {
environment = ["BP_JVM_VERSION" : "8.*"]
}
// end::env[]

task bootBuildImageEnvironment {
tasks.register("bootBuildImageEnvironment") {
doFirst {
bootBuildImage.environment.each { name, value -> println "$name=$value" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

// tag::env[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
environment = mapOf("BP_JVM_VERSION" to "8.*")
}
// end::env[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ plugins {
}

// tag::image-name[]
bootBuildImage {
tasks.named("bootBuildImage") {
imageName = "example.com/library/${project.name}"
}
// end::image-name[]

task bootBuildImageName {
doFirst {
println(tasks.bootBuildImage.imageName)
}
tasks.register("bootBuildImageName") {
doFirst {
println(tasks.bootBuildImage.imageName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ plugins {
}

// tag::image-name[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
imageName = "example.com/library/${project.name}"
}
// end::image-name[]

tasks.register("bootBuildImageName") {
doFirst {
println(tasks.getByName<BootBuildImage>("bootBuildImage").imageName)
}
doFirst {
println(tasks.getByName<BootBuildImage>("bootBuildImage").imageName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
id 'org.springframework.boot' version '{gradle-project-version}'
}

bootJar {
tasks.named("bootJar") {
mainClass = 'com.example.ExampleApplication'
}

// tag::publish[]
bootBuildImage {
tasks.named("bootBuildImage") {
imageName = "docker.example.com/library/${project.name}"
publish = true
docker {
Expand All @@ -22,8 +22,8 @@ bootBuildImage {
}
// end::publish[]

task bootBuildImagePublish {
doFirst {
println(tasks.bootBuildImage.publish)
}
tasks.register("bootBuildImagePublish") {
doFirst {
println(tasks.bootBuildImage.publish)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ plugins {
id("org.springframework.boot") version "{gradle-project-version}"
}

tasks.getByName<BootJar>("bootJar") {
tasks.named<BootJar>("bootJar") {
mainClass.set("com.example.ExampleApplication")
}

// tag::publish[]
tasks.getByName<BootBuildImage>("bootBuildImage") {
tasks.named<BootBuildImage>("bootBuildImage") {
imageName = "docker.example.com/library/${project.name}"
isPublish = true
docker {
Expand All @@ -26,7 +26,7 @@ tasks.getByName<BootBuildImage>("bootBuildImage") {
// end::publish[]

tasks.register("bootBuildImagePublish") {
doFirst {
println(tasks.getByName<BootBuildImage>("bootBuildImage").isPublish)
}
doFirst {
println(tasks.getByName<BootBuildImage>("bootBuildImage").isPublish)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ plugins {
}

// tag::classifiers[]
bootJar {
tasks.named("bootJar") {
archiveClassifier = 'boot'
}

jar {
tasks.named("jar") {
archiveClassifier = ''
}
// end::classifiers[]

bootJar {
tasks.named("bootJar") {
mainClass = 'com.example.Application'
}

0 comments on commit e7566e9

Please sign in to comment.