@@ -24,10 +24,13 @@ import org.elasticsearch.gradle.Version
2424import org.elasticsearch.gradle.BwcVersions
2525import org.elasticsearch.gradle.VersionProperties
2626import org.elasticsearch.gradle.plugin.PluginBuildPlugin
27+ import org.elasticsearch.gradle.tool.Boilerplate
2728import org.gradle.util.GradleVersion
2829import org.gradle.util.DistributionLocator
2930import org.gradle.plugins.ide.eclipse.model.SourceFolder
3031
32+ import static org.elasticsearch.gradle.tool.Boilerplate.maybeConfigure
33+
3134plugins {
3235 id ' com.gradle.build-scan' version ' 2.3'
3336 id ' base'
@@ -212,7 +215,7 @@ task branchConsistency {
212215
213216allprojects {
214217 // ignore missing javadocs
215- tasks. withType(Javadoc ) { Javadoc javadoc ->
218+ tasks. withType(Javadoc ). configureEach { Javadoc javadoc ->
216219 // the -quiet here is because of a bug in gradle, in that adding a string option
217220 // by itself is not added to the options. By adding quiet, both this option and
218221 // the "value" -quiet is added, separated by a space. This is ok since the javadoc
@@ -329,13 +332,9 @@ allprojects {
329332 }
330333 }
331334
332- task cleanIdeaBuildDir( type : Delete ) {
333- delete ' build-idea'
335+ tasks . named( ' cleanIdea ' ) {
336+ delete ' build-idea'
334337 }
335- cleanIdeaBuildDir. setGroup(" ide" )
336- cleanIdeaBuildDir. setDescription(" Deletes the IDEA build directory." )
337-
338- tasks. cleanIdea. dependsOn(cleanIdeaBuildDir)
339338}
340339
341340idea {
@@ -390,29 +389,20 @@ allprojects {
390389
391390 String lineSeparator = Os . isFamily(Os . FAMILY_WINDOWS ) ? ' \\\\ r\\\\ n' : ' \\\\ n'
392391 String licenseHeader = licenseHeaderFile. getText(' UTF-8' ). replace(System . lineSeparator(), lineSeparator)
393- task copyEclipseSettings(type : Copy ) {
392+ tasks. register(' copyEclipseSettings' , Copy ) {
393+ mustRunAfter ' wipeEclipseSettings'
394394 // TODO: "package this up" for external builds
395395 from new File (project. rootDir, ' buildSrc/src/main/resources/eclipse.settings' )
396396 into ' .settings'
397397 filter{ it. replaceAll(' @@LICENSE_HEADER_TEXT@@' , licenseHeader)}
398398 }
399399 // otherwise .settings is not nuked entirely
400- task wipeEclipseSettings( type : Delete ) {
400+ tasks . register( ' wipeEclipseSettings ' , Delete ) {
401401 delete ' .settings'
402402 }
403- tasks. cleanEclipse. dependsOn( wipeEclipseSettings)
403+ tasks. named( ' cleanEclipse' ) { dependsOn ' wipeEclipseSettings' }
404404 // otherwise the eclipse merging is *super confusing*
405- tasks. eclipse. dependsOn(cleanEclipse, copyEclipseSettings)
406-
407- // work arround https://github.com/gradle/gradle/issues/6582
408- tasks. eclipseProject. mustRunAfter tasks. cleanEclipseProject
409- tasks. matching { it. name == ' eclipseClasspath' }. all {
410- it. mustRunAfter { tasks. cleanEclipseClasspath }
411- }
412- tasks. matching { it. name == ' eclipseJdt' }. all {
413- it. mustRunAfter { tasks. cleanEclipseJdt }
414- }
415- tasks. copyEclipseSettings. mustRunAfter tasks. wipeEclipseSettings
405+ tasks. named(' eclipse' ) { dependsOn ' cleanEclipse' , ' copyEclipseSettings' }
416406}
417407
418408allprojects {
@@ -477,13 +467,11 @@ gradle.projectsEvaluated {
477467 * need to publish artifacts for them.
478468 */
479469 if (project. name. equals(' qa' ) || project. path. contains(' :qa:' )) {
480- Task assemble = project. tasks. findByName(' assemble' )
481- if (assemble) {
482- assemble. enabled = false
470+ maybeConfigure(project. tasks, ' assemble' ) {
471+ it. enabled = false
483472 }
484- Task dependenciesInfo = project. tasks. findByName(' dependenciesInfo' )
485- if (dependenciesInfo) {
486- dependenciesInfo. enabled = false
473+ maybeConfigure(project. tasks, ' dependenciesInfo' ) {
474+ it. enabled = false
487475 }
488476 }
489477 }
@@ -505,7 +493,7 @@ gradle.projectsEvaluated {
505493}
506494
507495allprojects {
508- task resolveAllDependencies {
496+ tasks . register( ' resolveAllDependencies' ) {
509497 dependsOn tasks. matching { it. name == " pullFixture" }
510498 doLast {
511499 configurations. findAll { it. isCanBeResolved() }. each { it. resolve() }
@@ -535,13 +523,13 @@ allprojects {
535523 }
536524 }
537525
538- task checkPart1
539- task checkPart2
540- tasks . matching { it . name == " check " } . all { check ->
541- if (check . path. startsWith(" :x-pack:" )) {
542- checkPart2 . dependsOn check
543- } else {
544- checkPart1 . dependsOn check
545- }
546- }
526+ def checkPart1 = tasks . register( ' checkPart1 ' )
527+ def checkPart2 = tasks . register( ' checkPart2 ' )
528+ plugins . withId( ' lifecycle-base ' ) {
529+ if (project . path. startsWith(" :x-pack:" )) {
530+ checkPart1 . configure { dependsOn ' check' }
531+ } else {
532+ checkPart2 . configure { dependsOn ' check' }
533+ }
534+ }
547535}
0 commit comments