/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 9 ĠK not . x ĠProject Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ plugins Ġ{ ĊĠĠĠ Ġbase ĊĠĠĠ Ġid (" com . bm us ch ko . docker - remote - api ") ĊĠĠĠ Ġid (" org . no sphere . apache . rat ") Ċ } Ċ Ċ repositories Ġ{ ĊĠĠĠ Ġj center () ĊĠĠĠ Ġmaven Local () ĊĠĠĠ Ġmaven Central () ĊĠĠĠ Ġmaven Ġ{ Ġurl Ġ= Ġuri (" https :// plugins . gradle . org / m 2 /") Ġ} Ċ } Ċ Ċ tasks Ġ{ ĊĠĠĠ Ġnamed < org . no sphere . apache . rat . Rat Task >(" rat ") Ġ{ ĊĠĠĠĠĠĠĠ Ġexclude s . addAll ( listOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"*. md ", Ġ// Ġdocs ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" gradle / wrapper /** ", Ġ" gradle *", Ġ" **/ build /** ", Ġ// ĠGradle ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"*. im l ", Ġ"*. ipr ", Ġ"*. i ws ", Ġ"*. idea /** ", Ġ// ĠIDE s ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ". github /* " ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġnamed (" check ") Ġ{ ĊĠĠĠĠĠĠĠ Ġdepends On (" rat ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġwith Type < com . bm us ch ko . gradle . docker . tasks . image . Docker Build Image >() Ġ{ ĊĠĠĠĠĠĠĠ Ġdepends On (" rat ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġnamed (" build ") Ġ{ ĊĠĠĠĠĠĠĠ Ġdepends On (" download And Un zip Distribution ", Ġ" prepare Docker ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġnamed (" clean ") Ġ{ ĊĠĠĠĠĠĠĠ Ġdepends On (" remove Base Image ", Ġ" remove Base Al pine Image ") ĊĠĠĠ Ġ} Ċ Ċ } ĊĊĊ Ċ val Ġdocker Base Image Ref Ġ= Ġ"$ build Dir /. docker / build Base Image - image Id . txt " Ċ val Ġdocker Base Al pine Image Ref Ġ= Ġ"$ build Dir /. docker / build Base Al pine Image - image Id . txt " Ċ Ċ val Ġdocker Base Image Id Ġ= Ġ"${ project . property (" docker . domain ") }/ k not x :${ project . version }" Ċ val Ġdocker Base Al pine Image Id Ġ= Ġ"${ project . property (" docker . domain ") }/ k not x - alpine :${ project . version }" Ċ Ċ val Ġdocker file Base Image Path Ġ= Ġ"$ project Dir / src / main / docker / base / Dockerfile " Ċ val Ġdocker file Base Al pine Image Path Ġ= Ġ"$ project Dir / src / main / docker / base - alpine / Dockerfile " Ċ Ċ fun Ġcom . bm us ch ko . gradle . docker . tasks . image . Docker Remove Image . remove ( name : ĠString ): ĠUnit Ġ{ ĊĠĠĠ Ġval Ġspec Ġ= Ġobject Ġ: ĠSpec < Task > Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġis Satisf ied By ( task : ĠTask ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġfile ( name ). exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġonly If ( spec ) ĊĊĠĠĠ Ġtarget Image Id ( if Ġ( file ( name ). exists ()) Ġfile ( name ). read Text () Ġelse Ġ"") ĊĠĠĠ ĠonError Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! this . message !!. contains (" No Ġsuch Ġimage ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow Ġthis ĊĠĠĠ Ġ} Ċ } Ċ Ċ tasks . register < Copy >(" copy Dockerfile Base ") Ġ{ ĊĠĠĠ Ġgroup Ġ= Ġ" docker " ĊĠĠĠ Ġfrom ( dockerfile Base Image Path ) ĊĠĠĠ Ġinto ("$ build Dir / out / base ") Ċ } Ċ Ċ tasks . register < Copy >(" copy Dockerfile Base Al pine ") Ġ{ ĊĠĠĠ Ġgroup Ġ= Ġ" docker " ĊĠĠĠ Ġfrom ( dockerfile Base Al pine Image Path ) ĊĠĠĠ Ġinto ("$ build Dir / out / base Al pine ") Ċ } Ċ Ċ tasks . register < com . bm us ch ko . gradle . docker . tasks . image . Docker Remove Image >(" remove Base Image ") Ġ{ ĊĠĠĠ Ġgroup Ġ= Ġ" docker " ĊĠĠĠ Ġremove ( docker Base Image Ref ) Ċ } Ċ Ċ tasks . register < com . bm us ch ko . gradle . docker . tasks . image . Docker Remove Image >(" remove Base Al pine Image ") Ġ{ ĊĠĠĠ Ġgroup Ġ= Ġ" docker " ĊĠĠĠ Ġremove ( docker Base Al pine Image Ref ) Ċ } Ċ Ċ tasks . register < com . bm us ch ko . gradle . docker . tasks . image . Docker Build Image > Ġ(" build Base Image ") Ġ{ ĊĠĠĠ Ġgroup Ġ= Ġ" docker " ĊĠĠĠ Ġinput Dir . set ( file ("$ build Dir / out ")) ĊĠĠĠ Ġdocker File . set ( file ("$ build Dir / out / base / Dockerfile ")) ĊĠĠĠ Ġimages . add ( docker Base Image Id ) ĊĠĠĠ Ġdepends On (" remove Base Image ", Ġ" copy Dockerfile Base ") Ċ } Ċ Ċ tasks . register < com . bm us ch ko . gradle . docker . tasks . image . Docker Build Image > Ġ(" build Base Al pine Image ") Ġ{ ĊĠĠĠ Ġgroup Ġ= Ġ" docker " ĊĠĠĠ Ġinput Dir . set ( file ("$ build Dir / out ")) ĊĠĠĠ Ġdocker File . set ( file ("$ build Dir / out / base Al pine / Dockerfile ")) ĊĠĠĠ Ġimages . add ( docker Base Al pine Image Id ) ĊĠĠĠ Ġdepends On (" remove Base Al pine Image ", Ġ" copy Dockerfile Base Al pine ") Ċ } Ċ Ċ tasks . register < com . bm us ch ko . gradle . docker . tasks . image . Docker Save Image >(" save Base Image ") Ġ{ ĊĠĠĠ Ġdest File . set ( file ("$ project Dir / build / docker / docker - build - base . tar ")) ĊĠĠĠ Ġimage . set ( docker Base Image Id ) ĊĠĠĠ Ġuse Compression . set ( true ) ĊĠĠĠ Ġmust Run After (" build Base Image ") Ċ } Ċ Ċ tasks . register < com . bm us ch ko . gradle . docker . tasks . image . Docker Save Image >(" save Base Al pine Image ") Ġ{ ĊĠĠĠ Ġdest File . set ( file ("$ project Dir / build / docker / docker - build - base - alpine . tar ")) ĊĠĠĠ Ġimage . set ( docker Base Al pine Image Id ) ĊĠĠĠ Ġuse Compression . set ( true ) ĊĠĠĠ Ġmust Run After (" build Base Al pine Image ") Ċ } Ċ Ċ tasks . register (" prepare Docker ") Ġ{ ĊĠĠĠ Ġdepends On (" build Base Image ", Ġ" build Base Al pine Image ", Ġ" save Docker Image ") ĊĠĠĠ Ġmust Run After (" download And Un zip Distribution ") Ċ } ĊĊ Ċ tasks . register (" save Docker Image ") Ġ{ ĊĠĠĠ Ġdepends On (" save Base Image ", Ġ" save Base Al pine Image ") Ċ } Ċ Ċ apply ( from Ġ= Ġ" gradle / distribution . gradle . k ts ")