Use configuration avoidance APIs in Gradle plugin's docs

Closes gh-30056
This commit is contained in:
Andy Wilkinson
2022-03-03 20:27:46 +00:00
parent 58e2adb895
commit e7566e968e
60 changed files with 135 additions and 135 deletions

View File

@@ -4,12 +4,12 @@ plugins {
}
// tag::launch[]
bootRun {
tasks.named("bootRun") {
optimizedLaunch = false
}
// end::launch[]
task optimizedLaunch {
tasks.register("optimizedLaunch") {
doLast {
println bootRun.optimizedLaunch
}

View File

@@ -6,12 +6,12 @@ plugins {
}
// tag::launch[]
tasks.getByName<BootRun>("bootRun") {
tasks.named<BootRun>("bootRun") {
isOptimizedLaunch = false
}
// end::launch[]
task("optimizedLaunch") {
tasks.register("optimizedLaunch") {
doLast {
println(tasks.getByName<BootRun>("bootRun").isOptimizedLaunch)
}

View File

@@ -4,12 +4,12 @@ plugins {
}
// tag::main[]
bootRun {
tasks.named("bootRun") {
mainClass = 'com.example.ExampleApplication'
}
// end::main[]
task configuredMainClass {
tasks.register("configuredMainClass") {
doLast {
println bootRun.mainClass
}

View File

@@ -6,12 +6,12 @@ plugins {
}
// tag::main[]
tasks.getByName<BootRun>("bootRun") {
tasks.named<BootRun>("bootRun") {
mainClass.set("com.example.ExampleApplication")
}
// end::main[]
task("configuredMainClass") {
tasks.register("configuredMainClass") {
doLast {
println(tasks.getByName<BootRun>("bootRun").mainClass)
}

View File

@@ -4,12 +4,12 @@ plugins {
}
// tag::source-resources[]
bootRun {
tasks.named("bootRun") {
sourceResources sourceSets.main
}
// end::source-resources[]
task configuredClasspath {
tasks.register("configuredClasspath") {
doLast {
println bootRun.classpath.files
}

View File

@@ -6,12 +6,12 @@ plugins {
}
// tag::source-resources[]
tasks.getByName<BootRun>("bootRun") {
tasks.named<BootRun>("bootRun") {
sourceResources(sourceSets["main"])
}
// end::source-resources[]
task("configuredClasspath") {
tasks.register("configuredClasspath") {
doLast {
println(tasks.getByName<BootRun>("bootRun").classpath.files)
}

View File

@@ -4,12 +4,12 @@ plugins {
}
// tag::system-property[]
bootRun {
tasks.named("bootRun") {
systemProperty 'com.example.property', findProperty('example') ?: 'default'
}
// end::system-property[]
task configuredSystemProperties {
tasks.register("configuredSystemProperties") {
doLast {
bootRun.systemProperties.each { k, v ->
println "$k = $v"

View File

@@ -6,14 +6,14 @@ plugins {
}
// tag::system-property[]
tasks.getByName<BootRun>("bootRun") {
tasks.named<BootRun>("bootRun") {
systemProperty("com.example.property", findProperty("example") ?: "default")
}
// end::system-property[]
task("configuredSystemProperties") {
tasks.register("configuredSystemProperties") {
doLast {
tasks.getByName<BootRun>("bootRun").systemProperties.forEach { k, v ->
tasks.getByName<BootRun>("bootRun").systemProperties.forEach { k, v ->
println("$k = $v")
}
}