// ĠCopyright Ġ 2 0 0 0 - 2 0 2 1 Ġ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 . execution . w sl Ċ Ċ import Ġcom . intellij . execution . target . value . Target Value Ċ import Ġcom . intellij . execution . w sl . W SL Distribution Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . util . text . nul lize Ċ import Ġorg . gradle . util . Distribution Locator Ċ import Ġorg . gradle . util . Gradle Version Ċ import Ġorg . gradle . wrapper . Wrapper Configuration Ċ import Ġorg . jetbrains . concurrency . resolved Promise Ċ import Ġorg . jetbrains . plugins . gradle . execution . target . maybe Get Local Value Ċ import Ġorg . jetbrains . plugins . gradle . service . Gradle Installation Manager Ċ import Ġorg . jetbrains . plugins . gradle . service . execution . Build Layout Parameters Ċ import Ġorg . jetbrains . plugins . gradle . settings . Distribution Type Ċ import Ġorg . jetbrains . plugins . gradle . settings . Gradle Local Settings Ċ import Ġorg . jetbrains . plugins . gradle . settings . Gradle Settings Ċ import Ġorg . jetbrains . plugins . gradle . util . Gradle Util Ċ Ċ internal Ġclass ĠW sl Build Layout Parameters ( private Ġval Ġw sl Distribution : ĠW SL Distribution , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġproject : ĠProject , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġproject Path : ĠString ?) Ġ: ĠBuild Layout Parameters Ġ{ ĊĠ Ġprivate Ġval Ġgradle Project Settings Ġ= Ġproject Path ?. let Ġ{ ĠGradle Settings . getInstance ( project ). get Linked Project Settings ( it ) Ġ} ĊĊĠ Ġoverride Ġval Ġgradle Home : ĠTarget Value < String >? Ġby Ġlazy Ġ{ Ġfind Gradle Home () Ġ} ĊĠ Ġoverride Ġval Ġgradle Version : ĠGradle Version ? Ġby Ġlazy Ġ{ Ġguess Gradle Version () Ġ} ĊĠ Ġoverride Ġval Ġgradle User Home : ĠTarget Value < String > Ġby Ġlazy Ġ{ Ġfind Gradle User Home Dir ( w sl Distribution ) Ġ} ĊĊĠ Ġprivate Ġfun Ġfind Gradle Home (): ĠTarget Value < String >? Ġ{ ĊĠĠĠ Ġval Ġdistribution Type Ġ= Ġgradle Project Settings ?. distribution Type Ġ?: Ġreturn Ġnull Ġ// Ġtodo Ġadd ĠGradle Home Ġauto - detect ĊĠĠĠ Ġif Ġ( distribution Type Ġ== ĠDistribution Type . LOCAL ) Ġreturn Ġgradle Project Settings . gradle Home ?. let Ġ{ ĊĠĠĠĠĠ Ġw sl Distribution . getTarget Value For Remote Path ( it ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn ĠGradle Local Settings . getInstance ( project ). get Gradle Home ( project Path )?. let Ġ{ Ġw sl Distribution . getTarget Value For Local Path ( it ) Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġguess Gradle Version (): ĠGradle Version ? Ġ{ ĊĠĠĠ Ġval Ġdistribution Type Ġ= Ġgradle Project Settings ?. distribution Type Ġ?: Ġreturn Ġnull ĊĠĠĠ Ġwhen Ġ( distribution Type ) Ġ{ ĊĠĠĠĠĠ ĠDistribution Type . B UND LED Ġ-> Ġreturn ĠGradle Version . current () ĊĠĠĠĠĠ ĠDistribution Type . LOCAL Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠGradle Installation Manager . get Gradle Version ( gradle Home ?. maybe Get Local Value ()) ?. run Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠGradle Installation Manager . get Gradle Version Safe ( this ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ ĠDistribution Type . DEFAULT _ WRAP PED Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgradle Version Ġ= ĠGradle Installation Manager . get Gradle Version ( gradle Home ?. maybe Get Local Value ()) ?. run Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠGradle Installation Manager . get Gradle Version Safe ( this ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ( gradle Version Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġval Ġpath Ġ= Ġget Wrapper Configuration ()?. distribution ?. raw Path ĊĠĠĠĠĠĠĠĠĠ Ġif Ġ( path Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠGradle Installation Manager . parse Distribution Version ( path ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġreturn Ġgradle Version ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ ĠDistribution Type . WRAP PED Ġ-> Ġreturn Ġnull ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġnull ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġget Wrapper Configuration (): ĠWrapper Configuration ? Ġ{ ĊĠĠĠ Ġval Ġdistribution Type Ġ= Ġgradle Project Settings ?. distribution Type Ġ?: Ġreturn Ġnull ĊĠĠĠ Ġwhen Ġ( distribution Type ) Ġ{ ĊĠĠĠĠĠ ĠDistribution Type . DEFAULT _ WRAP PED Ġ-> Ġreturn ĠGradle Util . get Wrapper Configuration ( project Path ) ĊĠĠĠĠĠ ĠDistribution Type . B UND LED Ġ-> Ġreturn ĠWrapper Configuration (). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġdistribution Ġ= ĠDistribution Locator (). get Distribution For ( Gradle Version . current ()) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġelse Ġ-> Ġreturn Ġnull ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġfind Gradle User Home Dir ( w sl Distribution : ĠW SL Distribution ): ĠTarget Value < String > Ġ{ ĊĠĠĠ Ġif Ġ( project Path Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġval Ġservice DirectoryPath Ġ= ĠGradle Settings . getInstance ( project ). service DirectoryPath ĊĠĠĠĠĠ Ġif Ġ( service DirectoryPath Ġ!= Ġnull ) Ġreturn Ġw sl Distribution . getTarget Value For Local Path ( service DirectoryPath ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġgradle User Home Ġ= Ġw sl Distribution . get EnvironmentVariable (" GRAD LE _ USER _ HOME "). nul lize ( true ) ĊĠĠĠ Ġreturn Ġw sl Distribution . getTarget Value For Remote Path ( gradle User Home Ġ?: Ġ"${ w sl Distribution . user Home }/. gradle ") ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠW SL Distribution . getTarget Value For Local Path ( windows Path : ĠString ): ĠTarget Value < String > Ġ{ ĊĠĠĠ Ġval Ġw sl Path Ġ= Ġget W sl Path ( windows Path ) Ġ?: Ġwindows Path ĊĠĠĠ Ġreturn ĠTarget Value . create ( windows Path , Ġresolved Promise ( w sl Path )) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠW SL Distribution . getTarget Value For Remote Path ( w sl Path : ĠString ): ĠTarget Value < String > Ġ{ ĊĠĠĠ Ġval Ġwindows Path Ġ= Ġget Windows Path ( w sl Path ) Ġ?: Ġw sl Path ĊĠĠĠ Ġreturn ĠTarget Value . create ( windows Path , Ġresolved Promise ( w sl Path )) ĊĠ Ġ} Ċ }