// Ġ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 . idea . maven . project Ċ Ċ import Ġcom . intellij . openapi . Disposable Ċ import Ġcom . intellij . openapi . external System . auto import .* Ċ import Ġcom . intellij . openapi . external System . auto import . External System Refresh Status . SUCCESS Ċ import Ġcom . intellij . openapi . external System . auto import . settings . Read Async Supplier Ċ import Ġcom . intellij . openapi . file Editor . File Document Manager Ċ import Ġcom . intellij . openapi . observable . properties . Atomic Boolean Property Ċ import Ġcom . intellij . openapi . progress . Progress Manager Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . util . io . File Util Ċ import Ġcom . intellij . openapi . vfs . Local FileSystem Ċ import Ġcom . intellij . openapi . vfs . Virtual File Ċ import Ġorg . jetbrains . idea . maven . model . Maven Constants Ċ import Ġorg . jetbrains . idea . maven . utils . Maven Util Ċ import Ġjava . io . File Ċ import Ġjava . util . concurrent . ExecutorService Ċ Ċ class ĠMaven Projects Aware ( ĊĠ Ġproject : ĠProject , ĊĠ Ġprivate Ġval Ġprojects Tree : ĠMaven Projects Tree , ĊĠ Ġprivate Ġval Ġmanager : ĠMaven Projects Manager , ĊĠ Ġprivate Ġval Ġwatcher : ĠMaven Projects Manager Watcher , ĊĠ Ġprivate Ġval Ġbackground Executor : ĠExecutor Service Ċ ) Ġ: ĠExternal System Project Aware Ġ{ ĊĊĠ Ġprivate Ġval Ġis Import Completed Ġ= ĠAtomic Boolean Property ( true ) ĊĊĠ Ġoverride Ġval ĠprojectId Ġ= ĠExternal System ProjectId ( Maven Util . SYSTEM _ ID , Ġproject . name ) ĊĊĠ Ġoverride Ġval Ġsettings Files : ĠSet < String > ĊĠĠĠ Ġget () Ġ= Ġcollect Settings Files (). map Ġ{ ĠFile Util . to Canonical Path ( it ) Ġ}. toSet () ĊĊĠ Ġoverride Ġfun Ġsubscribe ( listener : ĠExternal System Project Refresh Listener , Ġparent Disposable : ĠDis posable ) Ġ{ ĊĠĠĠ Ġis Import Completed . after Reset ({ Ġlistener . before Project Refresh () Ġ}, Ġparent Disposable ) ĊĠĠĠ Ġis Import Completed . after Set ({ Ġlistener . after Project Refresh ( SUCCESS ) Ġ}, Ġparent Disposable ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġreload Project ( context : ĠExternal System Project Reload Context ) Ġ{ ĊĠĠĠ ĠFile Document Manager . getInstance (). save All Documents () ĊĠĠĠ Ġval Ġsettings Files Context Ġ= Ġcontext . settings Files Context ĊĠĠĠ Ġif Ġ( context . has Undefined Mod ifications ) Ġ{ ĊĠĠĠĠĠ Ġmanager . force Update All Projects Or Find All Available P om Files () ĊĠĠĠ Ġ} ĊĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠ Ġsubmit Settings Files Partition ( settings Files Context ) Ġ{ Ġ( files ToUpdate , Ġfiles ToDelete ) Ġ-> ĊĠĠĠĠĠĠĠ Ġval Ġupdated Ġ= Ġsettings Files Context . created Ġ+ Ġsettings Files Context . updated ĊĠĠĠĠĠĠĠ Ġval Ġdeleted Ġ= Ġsettings Files Context . deleted ĊĠĠĠĠĠĠĠ Ġif Ġ( updated . size Ġ== Ġfiles ToUpdate . size Ġ&& Ġdeleted . size Ġ== Ġfiles ToDelete . size ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġwatcher . schedule Update ( files ToUpdate , Ġfiles ToDelete , Ġfalse , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġmanager . force Update All Projects Or Find All Available P om Files () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġsubmit Settings Files Partition ( ĊĠĠĠ Ġcontext : ĠExternal System Settings Files Reload Context , ĊĠĠĠ Ġaction : Ġ( Pair < List < Virtual File >, ĠList < Virtual File >>) Ġ-> ĠUnit ĊĠ Ġ) Ġ{ ĊĠĠĠ ĠRead Async Supplier . Builder Ġ{ Ġpartition Settings Files ( context ) Ġ} ĊĠĠĠĠĠ Ġ. build ( background Executor ) ĊĠĠĠĠĠ Ġ. supply ( action , Ġmanager ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġpartition Settings Files ( context : ĠExternal System Settings Files Reload Context ): ĠPair < List < Virtual File >, ĠList < Virtual File >> Ġ{ ĊĠĠĠ Ġval Ġlocal FileSystem Ġ= ĠLocal FileSystem . getInstance () ĊĠĠĠ Ġval Ġcreated Ġ= Ġcontext . created . map NotNull Ġ{ Ġlocal FileSystem . find File By Path ( it ) Ġ} ĊĠĠĠ Ġval Ġprojects Files Ġ= Ġprojects Tree . projects Files ĊĠĠĠ Ġval Ġupdated Ġ= Ġprojects Files . filter Ġ{ Ġit . path Ġin Ġcontext . updated Ġ} ĊĠĠĠ Ġval Ġdeleted Ġ= Ġprojects Files . filter Ġ{ Ġit . path Ġin Ġcontext . deleted Ġ} ĊĠĠĠ Ġreturn Ġcreated Ġ+ Ġupdated Ġto Ġdeleted ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġhas P om File ( root Directory : ĠString ): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn ĠMaven Constants . PO M _ NAMES . as Sequence () ĊĠĠĠĠĠ Ġ. map Ġ{ Ġjoin ( root Directory , Ġit ) Ġ} ĊĠĠĠĠĠ Ġ. any Ġ{ Ġprojects Tree . is Potential Project ( it ) Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcollect Settings Files () Ġ= Ġsequence Ġ{ ĊĠĠĠ Ġyield All ( projects Tree . managed Files Paths ) ĊĠĠĠ Ġyield All ( projects Tree . projects Files . map Ġ{ Ġit . path Ġ}) ĊĠĠĠ Ġfor Ġ( maven Project Ġin Ġprojects Tree . projects ) Ġ{ ĊĠĠĠĠĠ ĠProgress Manager . check Canceled () ĊĊĠĠĠĠĠ Ġval Ġroot Directory Ġ= Ġmaven Project . directory ĊĠĠĠĠĠ Ġyield All ( maven Project . module Paths ) ĊĠĠĠĠĠ Ġyield ( join ( root Directory , ĠMaven Constants . JVM _ CONFIG _ REL ATIVE _ PATH )) ĊĠĠĠĠĠ Ġyield ( join ( root Directory , ĠMaven Constants . MA VEN _ CONFIG _ REL ATIVE _ PATH )) ĊĠĠĠĠĠ Ġyield ( join ( root Directory , ĠMaven Constants . MA VEN _ WRAPPER _ REL ATIVE _ PATH )) ĊĠĠĠĠĠ Ġif Ġ( has P om File ( root Directory )) Ġ{ ĊĠĠĠĠĠĠĠ Ġyield ( join ( root Directory , ĠMaven Constants . PRO FILES _ XML )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġjoin ( parent Path : ĠString , Ġrelative Path : ĠString ) Ġ= ĠFile ( parent Path , Ġrelative Path ). path ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġmanager . add Manager Listener ( object Ġ: ĠMaven Projects Manager . Listener Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġimport And Resolve Scheduled () Ġ= Ġis Import Completed . set ( false ) ĊĠĠĠĠĠ Ġoverride Ġfun Ġproject Import Completed () Ġ= Ġis Import Completed . set ( true ) ĊĠĠĠ Ġ}) ĊĠ Ġ} Ċ } Ċ