// ĠCopyright Ġ 2 0 0 0 - 2 0 1 9 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġorg . jetbrains . plugins . gradle . service . resolve Ċ Ċ import Ġcom . intellij . util . Processing Context Ċ import Ġgro ovy . lang . Closure Ċ import Ġorg . jetbrains . plugins . gradle . service . resolve . Gradle Common ClassNames .* Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . api . statements . blocks . Gr C losable Block Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . impl . statements . expressions . Types Util . create Type Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . patterns . Gro ovy Closure Pattern Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . patterns . groovy Closure Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . patterns . psi Method Ċ import Ġorg . jetbrains . plugins . groovy . lang . psi . patterns . with Kind Ċ import Ġorg . jetbrains . plugins . groovy . lang . resolve . deleg ates To . Deleg ates To Info Ċ Ċ /** Ċ Ġ* Ġ@ author ĠV lad isl av . S or ok a Ċ Ġ* Ġ*/ Ċ class ĠGradle Artifacts Contributor Ġ: ĠGradle Method Context Contributor Ġ{ ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġval Ġartifacts Closure : ĠGro ovy Closure Pattern Ġ= Ġgro ovy Closure (). in Method ( ĊĠĠĠĠĠ Ġpsi Method ( GRAD LE _ API _ PROJECT , Ġ" artifacts ") ĊĠĠĠ Ġ). in MethodResult ( save Project Type ) ĊĠĠĠ Ġval Ġartifact Closure : ĠGro ovy Closure Pattern Ġ= Ġgro ovy Closure (). in Method ( ĊĠĠĠĠĠ Ġpsi Method ( GRAD LE _ API _ AR TI FACT _ HANDLER ). with Kind ( Gradle Artifact Handler Contributor . our Method Kind ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġget Deleg ates To Info ( closure : ĠGr C losable Block ): ĠDeleg ates To Info ? Ġ{ ĊĠĠĠ Ġval Ġcontext Ġ= ĠProcessing Context () ĊĠĠĠ Ġif Ġ( artifacts Closure . accept s ( closure , Ġcontext )) Ġ{ ĊĠĠĠĠĠ Ġ// ĠIf ĠProject # artifacts Ġmethod Ġwas Ġinvoked Ġon Ġspecial ĠProject Ġtype , ĊĠĠĠĠĠ Ġ// Ġthen Ġwe Ġthen Ġwant Ġto Ġpass Ġinfo Ġabout Ġproject Ġwith ĠArtifact Handler Ġtype . ĊĠĠĠĠĠ Ġ// ĊĠĠĠĠĠ Ġ// ĠExample Ġ 1 : Ġ` artifacts Ġ{ Ġ< here > Ġ} `. ĊĠĠĠĠĠ Ġ// Ġ` artifacts ` Ġcall Ġis Ġresolved Ġagainst ĠGradle Project Aware Type , Ġwhich Ġis Ġcreated Ġby ĠGradle Script Members Contributor . ĊĠĠĠĠĠ Ġ// ĠIn side Ġthat Ġcall Ġwe Ġresolve ĠArtifact Handler Ġdeclarations Ġfrom Ġcurrent Ġproject Ġlater Ġin ĠGradle Artifact Handler Contributor . ĊĠĠĠĠĠ Ġ// ĊĠĠĠĠĠ Ġ// ĠIn Ġother Ġcases Ġwe Ġdon 't Ġknow Ġto Ġwhat Ġproject Ġthe ĠArtifact Handler Ġbelongs . ĊĠĠĠĠĠ Ġ// ĊĠĠĠĠĠ Ġ// ĠExample Ġ 2 : Ġ` sub projects Ġ{ Ġartifacts Ġ{ Ġ< here > Ġ} Ġ}` ĊĠĠĠĠĠ Ġ// ĠWhile Ġthis Ġis Ġperfectly Ġvalid Ġcode , Ġwe Ġdon 't Ġknow Ġwhat Ġproject Ġto Ġresolve Ġagainst , ĊĠĠĠĠĠ Ġ// Ġso Ġwe Ġreturn Ġplain Ġregular Ġdelegate Ġtype . ĊĠĠĠĠĠ Ġval Ġartifact Handler Ġ= Ġcreate Type ( GRAD LE _ API _ AR TI FACT _ HANDLER , Ġclosure ) ĊĠĠĠĠĠ Ġval Ġdelegate Ġ= Ġcontext . get ( project Type Key )?. setType ( artifact Handler ) Ġ?: Ġartifact Handler ĊĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( delegate , ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif Ġ( artifact Closure . accept s ( closure )) Ġ{ ĊĠĠĠĠĠ Ġreturn ĠDeleg ates To Info ( create Type ( GRAD LE _ API _ CONFIG UR ABLE _ PUBL ISH _ AR TI FACT , Ġclosure ), ĠClosure . DE LEG ATE _ FIRST ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġnull ĊĠ Ġ} Ċ } Ċ