package Ġdev . t uring complete . intellij gradle utilities plugin . running grad led a emon Ċ Ċ import Ġcom . intellij . icons . All Icons Ċ import Ġcom . intellij . openapi . action System . Data Key Ċ import Ġcom . intellij . openapi . progress . Progress Indicator Ċ import Ġcom . intellij . openapi . project . guess Project Dir Ċ import Ġcom . intellij . util . containers . or Null Ċ import Ġdev . t uring complete . intellij gradle utilities plugin . common . Gradle Utility Action Ċ import Ġdev . t uring complete . intellij gradle utilities plugin . common . Gradle Utils Ċ import Ġjava . nio . file . Path Ċ import Ġkotlin . streams . as Sequence Ċ Ċ class ĠCollect Running Gradle Da em ons Action ĊĠ Ġ: ĠGradle Utility Action < List < Gradle Daemon >> (" Collect ĠRunning ĠGradle ĠDa em ons ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Collect s Ġall Ġrunning ĠGradle Ġda em ons .", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAll Icons . Actions . Refresh , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexecution Mode Ġ= ĠExecution Mode . MOD AL ) Ġ{ ĊĊĠ Ġ// Ġ-- ĠComp anion ĠObject Ġ-------------------------------------------------------------------------------- ------------ Ġ// ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġconst Ġval ĠGR AD LE _ DA EM ON _ CLASS Ġ= Ġ" org . gradle . launcher . daemon . bootstrap . Gradle Daemon " ĊĊĠĠĠ Ġval ĠDET ER M INE _ DA EM ON _ STATUS : ĠData Key < Boolean > Ġ= ĠData Key . create (" Gradle . Utilities . Plugin . Collect Running Gradle Da em ons Action . Find Daemon Status ") ĊĠ Ġ} ĊĊĠ Ġ// Ġ-- ĠProperties Ġ------------------------------------------------------------------------------------------------ -- Ġ// ĊĠ Ġ// Ġ-- ĠInitialization Ġ-------------------------------------------------------------------------------- -------------- Ġ// ĊĠĠĊĠ Ġinit Ġ{ ĊĠĠĠ Ġshow Open s Dialog Indicator On ButtonText Ġ= Ġfalse ĊĠ Ġ} ĊĊĠ Ġ// Ġ-- ĠEx posed ĠMethods Ġ-------------------------------------------------------------------------------- ------------- Ġ// ĊĊĠ Ġoverride Ġfun Ġrun Action ( executionContext : ĠExecutionContext , Ġprogress Indicator : ĠProgress Indicator ) Ġ{ ĊĠĠĠ Ġ// ĠCollect Ġprocesses ĊĠĠĠ Ġprogress Indicator . text Ġ= Ġ" Collect ing ĠGradle Ġdaemon Ġprocesses ..." ĊĊĠĠĠ Ġval Ġgradle Daemon Processes : ĠMap < Long , ĠProcess Handle > Ġ= ĠProcess Handle . all Processes (). as Sequence (). filter Ġ{ Ġprocess Ġ-> ĊĠĠĠĠĠ Ġprocess . info (). command Line (). map Ġ{ Ġit . contains ( GRAD LE _ DA EM ON _ CLASS ) Ġ}. orElse ( false ) ĊĠĠĠ Ġ}. associate By Ġ{ Ġit . pid () Ġ} ĊĊĠĠĠ Ġval Ġgradle Da em ons Ġ= Ġmutable Map Of < Long , ĠGradle Daemon >() ĊĊĠĠĠ Ġ// ĠAdd Ġda em ons Ġwith Ġknown Ġstatus ĊĠĠĠ Ġprogress Indicator . check Canceled () ĊĊĠĠĠ Ġif Ġ( DE TERM INE _ DA EM ON _ STATUS . getData ( executionContext . data Context ) Ġ== Ġtrue ) Ġ{ ĊĠĠĠĠĠ Ġprogress Indicator . text Ġ= Ġ" Determin ing ĠGradle Ġdaemon Ġstatuses ..." ĊĊĠĠĠĠĠ Ġval Ġworking Dir To Gradle Executable Ġ= Ġmutable Map Of < Path ?, ĠPath >() ĊĊĠĠĠĠĠ Ġexecution Context . project ?. guess Project Dir ()?. let Ġ{ Ġproject Dir Ġ-> ĊĠĠĠĠĠĠĠ Ġprogress Indicator . check Canceled () ĊĊĠĠĠĠĠĠĠ ĠGradle Utils . find Gradle w Executable ( project Dir )?. let Ġ{ Ġgradle w Executable Ġ-> ĊĠĠĠĠĠĠĠĠĠ Ġworking Dir To Gradle Executable . put ( project Dir . to Nio Path (), Ġgradle w Executable . to Nio Path ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ ĠGradle Utils . find System Gradle Executable ( executionContext . project )?. let Ġ{ Ġsystem Gradle Executable Ġ-> ĊĠĠĠĠĠĠĠ Ġworking Dir To Gradle Executable . put ( null , Ġsystem Gradle Executable ) ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġworking Dir To Gradle Executable . forEach Ġ{ Ġ( working Dir , Ġgradle Executable ) Ġ-> ĊĠĠĠĠĠĠĠ Ġprogress Indicator . check Canceled () ĊĠĠĠĠĠĠĠ ĠGradle Utils . determine Gradle Daemon Status ( working Dir , Ġgradle Executable ). forEach Ġ{ Ġ( pid , Ġstatus ) Ġ-> ĊĠĠĠĠĠĠĠĠĠ Ġif Ġ( gradle Daemon Processes . containsKey ( pid )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgradle Da em ons [ pid ] Ġ= ĠGradle Daemon ( gradle Daemon Processes [ pid ] !! , Ġstatus ) ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprogress Indicator . check Canceled () ĊĊĠĠĠ Ġ// ĠAdd Ġremaining ĠGradle Ġda em ons , Ġwhich Ġhave Ġan Ġunknown Ġstatus ĊĠĠĠ Ġgradle Daemon Processes . filter Ġ{ Ġ! gradle Da em ons . containsKey ( it . key ) Ġ}. forEach Ġ{ ĊĠĠĠĠĠ Ġgradle Da em ons [ it . key ] Ġ= ĠGradle Daemon ( it . value , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġresult ( gradle Da em ons . values . toList ()) ĊĠ Ġ} ĊĊĠ Ġ// Ġ-- ĠPrivate ĠMethods Ġ-------------------------------------------------------------------------------- ------------- Ġ// ĊĠ Ġ// Ġ-- ĠInner ĠType Ġ------------------------------------------------------------------------------------------------ -- Ġ// Ċ }