/* Ċ Ġ* ĠSPDX - License - Identifier : ĠApache - 2 . 0 Ċ Ġ* Ċ Ġ* ĠCopyright Ġ 2 0 1 9 ĠT omas z ĠLink owski . Ċ Ġ* Ċ Ġ* Ġ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 . Ċ Ġ*/ Ċ Ċ package Ġpl . t link owski . gradle . my . settings Ċ Ċ import Ġorg . gradle . test kit . runner . Build Result Ċ import Ġorg . gradle . test kit . runner . Gradle Runner Ċ import Ġjava . io . File Ċ Ċ /** Ċ Ġ* ĠSpecial Ġclass Ġthat Ġhandles Ġsetting Ġup Ġand Ġcleaning Ġup Ġan Ġappropriately Ġmodified Ġ` gradle . properties ` Ġfile . Ċ Ġ* Ċ Ġ* Ġ@ author ĠT omas z ĠLink owski Ċ Ġ*/ Ċ internal Ġclass ĠMy Settings S moke TestRunner Ġ{ ĊĊĠ Ġprivate Ġval Ġgradle Runner : ĠGradle Runner Ġ= ĠGradle Runner . create () ĊĠĠĠĠĠĠĠĠĠ Ġ. with Plugin Classpath () ĊĠĠĠĠĠĠĠĠĠ Ġ. with Project Dir ( create TempDir ( java Class . simple Name )) ĊĠĠĠĠĠĠĠĠĠ Ġ. with Arguments (" clean ", Ġ" build ") ĊĠĠĠĠĠĠĠĠĠ Ġ. forward Output () ĊĊĠ Ġfun Ġcreate Sub projects Dir () Ġ= Ġfile (" sub projects "). apply Ġ{ ĊĠĠĠ Ġmkdir () ĊĠ Ġ} ĊĊĠ Ġfun Ġcreate Sub project ( sub path : ĠString ) Ġ= Ġfile (" sub projects /$ sub path "). apply Ġ{ ĊĠĠĠ Ġval Ġname Ġ= Ġsub path . substring After Last ('/') ĊĠĠĠ Ġmkdir s () ĊĠĠĠ Ġresolve ("$ name . gradle . k ts "). write Text (` build - gradle - k ts `) ĊĠ Ġ} ĊĊĠ Ġfun Ġbuild (): ĠBuild Result Ġ= Ġgradle Runner . with Arguments ( gradle Runner . arguments Ġ+ Ġ"-- stack trace "). build () ĊĊĠ Ġfun Ġbuild And Fail (): ĠBuild Result Ġ= Ġgradle Runner . build And Fail () ĊĊĠ Ġfun Ġfile ( relative : ĠString ) Ġ= Ġgradle Runner . project Dir . resolve ( relative ) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġfile (" gradle . properties "). write Text (` gradle - properties `) ĊĠĠĠ Ġfile (" settings . gradle . k ts "). write Text (` settings - gradle - k ts `) ĊĠĠĠ Ġfile (" build . gradle . k ts "). write Text (` build - gradle - k ts `) ĊĠ Ġ} ĊĊĠ Ġ// region ĠBUILD ĠCONTENT ĊĠ Ġprivate Ġval Ġ` gradle - properties ` ĊĠĠĠ Ġget () Ġ= Ġread Test kit Properties Content () ĊĊĠ Ġprivate Ġval Ġ` settings - gradle - k ts ` ĊĠĠĠ Ġget () Ġ= Ġ""" ĊĠĠĠĠĠ Ġbuild script Ġ{ ĊĠĠĠĠĠĠĠ Ġdependencies Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġclasspath ( files (${ build Plugin Classpath String ()} )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġapply ( plugin Ġ= Ġ" pl . t link owski . gradle . my . settings ") ĊĠĠĠ Ġ""" . trim Indent () ĊĊĠ Ġprivate Ġval Ġ` build - gradle - k ts ` ĊĠĠĠ Ġget () Ġ= Ġ""" ĊĠĠĠĠĠ Ġplugins Ġ{ ĊĠĠĠĠĠĠĠ Ġjava ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ""" . trim Indent () ĊĠ Ġ// endregion ĊĊĠ Ġ// region ĠGR AD LE . PROPERTIES Ġ( d uplicated Ġin Ġ` My Super pom S moke TestRunner . kt `) ĊĠ Ġprivate Ġfun Ġread Test kit Properties Content (): ĠString Ġ= Ġwith ( Gradle Runner :: class . java . class Loader ) Ġ{ ĊĠĠĠ Ġreturn ĠcheckNotNull ( getResource (" test kit - gradle . properties ")). read Text () ĊĠ Ġ} ĊĠ Ġ// endregion ĊĊĠ Ġ// region ĠSET T INGS . GRAD LE . K TS ĊĠ Ġ// Ġhttps :// dis cuss . gradle . org / t / testing - a - settings - plugin / 1 2 7 1 6 / 4 Ġ( d uplicated Ġin Ġ` My Super pom S moke TestRunner . kt `) ĊĠ Ġprivate Ġfun Ġbuild Plugin Classpath String () Ġ= Ġgradle Runner . plugin Classpath . join ToString (", Ġ") Ġ{ Ġfile Ġ-> ĊĠĠĠ Ġ'"' Ġ+ Ġfile . to Normalized String () Ġ+ Ġ'"' ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠFile . to Normalized String () Ġ= Ġpath . replace ('\\ ', Ġ'/') ĊĠ Ġ// endregion Ċ } Ċ