@ file : Suppress (" Un stable Api Usage ") Ċ Ċ package Ġmb . sp oof ax . compiler . gradle . sp oof ax core Ċ Ċ import Ġmb . common . util . Properties Ċ import Ġmb . resource . Default Resource Service Ċ import Ġmb . resource . fs . FS Path Ċ import Ġmb . resource . fs . FS Resource Registry Ċ import Ġmb . sp oof ax . compiler . sp oof ax core .* Ċ import Ġmb . sp oof ax . compiler . util .* Ċ import Ġorg . gradle . api . Gradle Exception Ċ import Ġorg . gradle . api . Plugin Ċ import Ġorg . gradle . api . Project Ċ import Ġorg . gradle . api . artifacts . Dependency Ċ import Ġorg . gradle . api . plugins . Java Library Plugin Ċ import Ġorg . gradle . api . plugins . Java Plugin Ċ import Ġorg . gradle . api . provider . List Property Ċ import Ġorg . gradle . api . provider . Property Ċ import Ġorg . gradle . api . tasks . Copy Ċ import Ġorg . gradle . api . tasks . Source Set Container Ċ import Ġorg . gradle . api . tasks . Sync Ċ import Ġorg . gradle . kotlin . dsl .* Ċ import Ġjava . io . IOException Ċ import Ġjava . nio . charset . StandardCharsets Ċ Ċ open Ġclass ĠComp ilers Ġ{ ĊĠ Ġinternal Ġval Ġresource Service Ġ= ĠDefault Resource Service ( FS Resource Registry ()) ĊĠ Ġinternal Ġval Ġcharset Ġ= ĠStandard Charsets . UTF _ 8 ĊĠ Ġinternal Ġval Ġtemplate Compiler Ġ= ĠTemplate Compiler ( Shared :: class . java , Ġresource Service , Ġcharset ) ĊĠ Ġinternal Ġval Ġclass loader Resource Service Ġ= ĠClass loader Resources Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġparser Compiler Ġ= ĠParser Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġsty ler Compiler Ġ= ĠSty ler Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġcomp leter Compiler Ġ= ĠComp leter Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġstr ateg o Runtime Compiler Ġ= ĠStr ateg o Runtime Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġconstraint Analyzer Compiler Ġ= ĠConstraint Analyzer Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġmult il ang Analyzer Compiler Ġ= ĠMult il ang Analyzer Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġlanguage Project Compiler Ġ= ĠLanguage Project Compiler ( template Compiler , Ġclass loader Resource Service , Ġparser Compiler , Ġsty ler Compiler , Ġcomp leter Compiler , Ġstr ateg o Runtime Compiler , Ġconstraint Analyzer Compiler , Ġmult il ang Analyzer Compiler ) ĊĠ Ġinternal Ġval Ġadapter Project Compiler Ġ= ĠAdapter Project Compiler ( template Compiler , Ġparser Compiler , Ġsty ler Compiler , Ġcomp leter Compiler , Ġstr ateg o Runtime Compiler , Ġconstraint Analyzer Compiler , Ġmult il ang Analyzer Compiler ) ĊĠ Ġinternal Ġval Ġcli Project Compiler Ġ= ĠCli Project Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġec lipse External deps Project Compiler Ġ= ĠEclipse External deps Project Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġec lipse Project Compiler Ġ= ĠEclipse Project Compiler ( template Compiler ) ĊĠ Ġinternal Ġval Ġint ellij Project Compiler Ġ= ĠInt ellij Project Compiler ( template Compiler ) Ċ } Ċ Ċ open Ġclass ĠLanguage Project Settings ( ĊĠ Ġval Ġshared : ĠShared . Builder Ġ= ĠShared . builder (), ĊĊĠ Ġval Ġlanguage Project : ĠLanguage Project . Builder Ġ= ĠLanguage Project . builder (), ĊĠ Ġval Ġclass loader Resources : ĠClass loader Resources Compiler . Language Project Input . Builder Ġ= ĠClass loader Resources Compiler . Language Project Input . builder (), ĊĠ Ġval Ġparser : ĠParser Compiler . Language Project Input . Builder ? Ġ= Ġnull , Ġ// ĠOptional ĊĠ Ġval Ġsty ler : ĠSty ler Compiler . Language Project Input . Builder ? Ġ= Ġnull , Ġ// ĠOptional ĊĠ Ġval Ġcomp leter : ĠComp leter Compiler . Language Project Input . Builder ? Ġ= Ġnull , Ġ// ĠOptional ĊĠ Ġval Ġstr ateg o Runtime : ĠStr ateg o Runtime Compiler . Language Project Input . Builder ? Ġ= Ġnull , Ġ// ĠOptional ĊĠ Ġval Ġconstraint Analyzer : ĠConstraint Analyzer Compiler . Language Project Input . Builder ? Ġ= Ġnull , Ġ// ĠOptional ĊĠ Ġval Ġmult il ang Analyzer : ĠMult il ang Analyzer Compiler . Language Project Input . Builder ? Ġ= Ġnull , Ġ// ĠOptional ĊĊĠ Ġval Ġbuilder : ĠLanguage Project Compiler . Input . Builder Ġ= ĠLanguage Project Compiler . Input . builder () Ċ ) Ġ{ ĊĠ Ġinternal Ġfun Ġfinalize ( gradle Project : ĠProject ): ĠLanguage Project Final ized Ġ{ ĊĠĠĠ Ġ// ĠAttempt Ġto Ġload Ġcompiler Ġproperties Ġfrom Ġfile . ĊĠĠĠ Ġval Ġsp oof ax Compiler Properties File Ġ= Ġgradle Project . project Dir . resolve (" sp oof ax c . lock ") ĊĠĠĠ Ġval Ġsp oof ax Compiler Properties Ġ= ĠProperties () ĊĠĠĠ Ġif ( sp oof ax Compiler Properties File . exists ()) Ġ{ ĊĠĠĠĠĠ Ġsp oof ax Compiler Properties File . buffered Reader (). use Ġ{ ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġsp oof ax Compiler Properties . load ( it ) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch ( e : ĠIOException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġgradle Project . logger . warn (" Failed Ġto Ġload ĠSp oof ax Ġcompiler Ġproperties Ġfrom Ġfile Ġ'$ sp oof ax Compiler Properties File '", Ġe ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠBuild Ġshared Ġsettings . ĊĠĠĠ Ġval Ġshared Ġ= Ġshared ĊĠĠĠĠĠ Ġ. with Persistent Properties ( sp oof ax Compiler Properties ) ĊĠĠĠĠĠ Ġ. base Directory ( FS Path ( gradle Project . project Dir . parent )) Ġ// ĠTODO : Ġremove Ġthe Ġneed Ġto Ġset Ġa Ġbase Ġdirectory , Ġas Ġit Ġis Ġoften Ġwrong . ĊĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġ// ĠBuild Ġlanguage Ġproject Ġcompiler Ġsettings . ĊĠĠĠ Ġval Ġlanguage Project Ġ= Ġthis . language Project . shared ( shared ). project ( gradle Project . to Sp oof ax Compiler Project ()). build () ĊĠĠĠ Ġval Ġclass loader Resources Ġ= Ġthis . class loader Resources . shared ( shared ). language Project ( language Project ). build () ĊĠĠĠ Ġval Ġparser Ġ= Ġif ( this . parser Ġ!= Ġnull ) Ġthis . parser . shared ( shared ). language Project ( language Project ). build () Ġelse Ġnull ĊĠĠĠ Ġval Ġsty ler Ġ= Ġif ( this . sty ler Ġ!= Ġnull ) Ġthis . sty ler . shared ( shared ). language Project ( language Project ). build () Ġelse Ġnull ĊĠĠĠ Ġval Ġcomp leter Ġ= Ġif ( this . comp leter Ġ!= Ġnull ) Ġthis . comp leter . shared ( shared ). language Project ( language Project ). build () Ġelse Ġnull ĊĠĠĠ Ġval Ġstr ateg o Runtime Ġ= Ġif ( this . str ateg o Runtime Ġ!= Ġnull ) Ġthis . str ateg o Runtime . shared ( shared ). language Project ( language Project ). build () Ġelse Ġnull ĊĠĠĠ Ġval Ġconstraint Analyzer Ġ= Ġif ( this . constraint Analyzer Ġ!= Ġnull ) Ġthis . constraint Analyzer . shared ( shared ). language Project ( language Project ). build () Ġelse Ġnull ĊĠĠĠ Ġval Ġmult il ang Analyzer Ġ= Ġif ( this . mult il ang Analyzer Ġ!= Ġnull ) Ġthis . mult il ang Analyzer . shared ( shared ). language Project ( language Project ) ĊĠĠĠĠĠ Ġ. class loader Resources ( class loader Resources . class loader Resources ()). build () Ġelse Ġnull ĊĠĠĠ Ġval Ġbuilder Ġ= Ġthis . builder ĊĠĠĠĠĠ Ġ. shared ( shared ) ĊĠĠĠĠĠ Ġ. language Project ( language Project ) ĊĠĠĠĠĠ Ġ. class loader Resources ( class loader Resources ) ĊĠĠĠ Ġif ( parser Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġbuilder . parser ( parser ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif ( sty ler Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġbuilder . sty ler ( sty ler ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif ( comp leter Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġbuilder . comp leter ( comp leter ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif ( str ateg o Runtime Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġbuilder . str ateg o Runtime ( str ateg o Runtime ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif ( constraint Analyzer Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġbuilder . constraint Analyzer ( constraint Analyzer ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif ( mult il ang Analyzer Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġbuilder . mult il ang Analyzer ( mult il ang Analyzer ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġinput Ġ= Ġbuilder . build () ĊĊĠĠĠ Ġ// ĠSave Ġcompiler Ġproperties Ġto Ġfile . ĊĠĠĠ Ġshared . save Persistent Properties ( sp oof ax Compiler Properties ) ĊĠĠĠ Ġsp oof ax Compiler Properties File . parent File . mkdir s () ĊĠĠĠ Ġsp oof ax Compiler Properties File . createNew File () ĊĠĠĠ Ġsp oof ax Compiler Properties File . buffered Writer (). use Ġ{ ĊĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠ Ġsp oof ax Compiler Properties . store Without Date ( it ) ĊĠĠĠĠĠĠĠ Ġit . flush () ĊĠĠĠĠĠ Ġ} Ġcatch ( e : ĠIOException ) Ġ{ ĊĠĠĠĠĠĠĠ Ġgradle Project . logger . warn (" Failed Ġto Ġsave ĠSp oof ax Ġcompiler Ġproperties Ġto Ġfile Ġ'$ sp oof ax Compiler Properties File '", Ġe ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn ĠLanguage Project Final ized ( shared , Ġinput , ĠComp ilers ()) ĊĠ Ġ} ĊĊĠ Ġinternal Ġfun Ġadd Stat ix Dependencies ( stat ix Dependencies : ĠList < Project >) Ġ{ ĊĠĠĠ Ġstat ix Dependencies . forEach Ġ{ ĊĠĠĠĠĠ Ġval Ġext : ĠLanguage Project Extension Ġ= Ġit . extensions . getBy Type () ĊĠĠĠĠĠ Ġval Ġfactory Ġ= Ġext . settings Final ized . input . mult il ang Analyzer (). get (). spec Config Factory () ĊĠĠĠĠĠ Ġthis . mult il ang Analyzer ?. add Dependency Factories ( factory ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ Ċ open Ġclass ĠLanguage Project Extension ( project : ĠProject ) Ġ{ ĊĠ Ġ// Ġstat ix Dependencies Ġmust Ġbe Ġin Ġa Ġseparate Ġproperty , Ġsince Ġits Ġfinal ized ĊĠ Ġ// Ġvalue Ġis Ġused Ġto Ġcheck Ġif Ġthe Ġsettings Ġproperty Ġcan Ġbe Ġfinal ized ĊĠ Ġval Ġstat ix Dependencies : ĠList Property < Project > Ġ= Ġproject . objects . list Property () ĊĠ Ġval Ġsettings : ĠProperty < Language Project Settings > Ġ= Ġproject . objects . property () ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġsettings . convention ( Language Project Settings ()) ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġinternal Ġconst Ġval Ġid Ġ= Ġ" sp oof ax Language Project " ĊĠĠĠ Ġprivate Ġconst Ġval Ġname Ġ= Ġ" Sp oof ax Ġlanguage Ġproject " ĊĠ Ġ} ĊĊĠ Ġinternal Ġval Ġsettings Final ized : ĠLanguage Project Final ized Ġby Ġlazy Ġ{ ĊĠĠĠ Ġproject . logger . debug (" Final izing Ġ$ name Ġsettings Ġin Ġ$ project ") ĊĠĠĠ Ġsettings . finalize Value () ĊĠĠĠ Ġif (! settings . isPresent ) Ġ{ ĊĠĠĠĠĠ Ġthrow ĠGradle Exception ("$ name Ġsettings Ġin Ġ$ project Ġhave Ġnot Ġbeen Ġset ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġsettings Ġ= Ġsettings . get () ĊĠĠĠ Ġval Ġstat ix Dependencies Ġ= Ġstat ix Dependencies Final ized ĊĊĠĠĠ Ġif ( settings . mult il ang Analyzer Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġif ( stat ix Dependencies . isNotEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠ Ġproject . logger . warn (" Stat ix Ġdependencies Ġgiven , Ġbut Ġno Ġmult il ang Ġanalyzer Ġconfiguration Ġset . ĠIgn oring Ġstat ix Ġdependencies ") ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ Ġsettings . add Stat ix Dependencies ( stat ix Dependencies ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġsettings . finalize ( project ) ĊĠ Ġ} ĊĊĠ Ġinternal Ġval Ġstat ix Dependencies Final ized : ĠList < Project > Ġby Ġlazy Ġ{ ĊĠĠĠ Ġproject . logger . debug (" Final izing Ġ$ name Ġstat ix Ġdependencies Ġin Ġ$ project ") ĊĠĠĠ Ġstat ix Dependencies . finalize Value () ĊĠĠĠ Ġif (! stat ix Dependencies . isPresent ) Ġ{ ĊĠĠĠĠĠ Ġthrow ĠGradle Exception ("$ name Ġstat ix Ġdependencies Ġin Ġ$ project Ġhave Ġnot Ġbeen Ġset ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġstat ix Dependencies . get () ĊĠ Ġ} Ċ } Ċ Ċ internal Ġclass ĠLanguage Project Final ized ( ĊĠ Ġval Ġshared : ĠShared , ĊĠ Ġval Ġinput : ĠLanguage Project Compiler . Input , ĊĠ Ġval Ġcompilers : ĠComp ilers Ċ ) Ġ{ ĊĠ Ġval Ġresource Service Ġ= Ġcompilers . resource Service ĊĠ Ġval Ġcompiler Ġ= Ġcompilers . language Project Compiler Ċ } Ċ Ċ internal Ġfun ĠProject . when Language Project Final ized ( closure : Ġ() Ġ-> ĠUnit ) Ġ= Ġwhen Final ized < Language Project Extension > Ġ{ ĊĠ Ġval Ġextension : ĠLanguage Project Extension Ġ= Ġextensions . getBy Type () ĊĠ Ġ// ĠProject Ġis Ġfully Ġfinal ized Ġonly Ġiff Ġall Ġdependencies Ġare Ġfinal ized Ġas Ġwell ĊĠ Ġextension . stat ix Dependencies Final ized . when All Language Projects Final ized ( closure ) Ċ } Ċ Ċ @ Suppress (" unused ") Ċ open Ġclass ĠLanguage Plugin Ġ: ĠPlugin < Project > Ġ{ ĊĠ Ġoverride Ġfun Ġapply ( project : ĠProject ) Ġ{ ĊĠĠĠ Ġval Ġextension Ġ= ĠLanguage Project Extension ( project ) ĊĠĠĠ Ġproject . extensions . add ( Language Project Extension . id , Ġextension ) ĊĊĠĠĠ Ġproject . plugins . apply ( Java Library Plugin :: class . java ) ĊĠĠĠ Ġproject . plugins . apply (" org . metab org . sp oof ax . gradle . base ") ĊĊĠĠĠ Ġproject . after Evaluate Ġ{ ĊĠĠĠĠĠ Ġextension . stat ix Dependencies Final ized . when All Language Projects Final ized Ġ{ ĊĠĠĠĠĠĠĠ Ġconfigure ( project , Ġextension . settings Final ized ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġconfigure ( project : ĠProject , Ġfinal ized : ĠLanguage Project Final ized ) Ġ{ ĊĠĠĠ Ġconfigure Project ( project , Ġfinal ized ) ĊĠĠĠ Ġconfigure Compile Task ( project , Ġfinal ized ) ĊĠĠĠ Ġconfigure Copy Sp oof ax Language Tasks ( project , Ġfinal ized ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġconfigure Project ( project : ĠProject , Ġfinal ized : ĠLanguage Project Final ized ) Ġ{ ĊĠĠĠ Ġproject . configure Generated Sources ( project . to Sp oof ax Compiler Project (), Ġfinal ized . resource Service ) ĊĠĠĠ Ġfinal ized . compiler . get Dependencies ( final ized . input ). forEach Ġ{ ĊĠĠĠĠĠ Ġit . addTo Dependencies ( project ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġconfigure Compile Task ( project : ĠProject , Ġfinal ized : ĠLanguage Project Final ized ) Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġfinal ized . input ĊĠĠĠ Ġval Ġcompile Task Ġ= Ġproject . tasks . register (" sp oof ax Compile Language Project ") Ġ{ ĊĠĠĠĠĠ Ġgroup Ġ= Ġ" sp oof ax Ġcompiler " ĊĠĠĠĠĠ Ġinputs . property (" input ", Ġinput ) ĊĠĠĠĠĠ Ġoutputs . files ( input . provided Files (). map Ġ{ Ġfinal ized . resource Service . to Local File ( it ) Ġ}) ĊĊĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠ Ġproject . delete Gen Source Sp oof ax Directory ( input . language Project (). project (), Ġfinal ized . resource Service ) ĊĠĠĠĠĠĠĠ Ġfinal ized . compiler . compile ( input ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠMake Ġcompile Java Ġdepend Ġon Ġour Ġtask , Ġbecause Ġwe Ġgenerate ĠJava Ġcode . ĊĠĠĠ Ġproject . tasks . get ByName ( Java Plugin . COMPILE _ JAVA _ TASK _ NAME ). depends On ( compile Task ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġconfigure Copy Sp oof ax Language Tasks ( project : ĠProject , Ġfinal ized : ĠLanguage Project Final ized ) Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġfinal ized . input ĊĠĠĠ Ġval Ġdestination Package Ġ= Ġinput . language Project (). package Path () ĊĠĠĠ Ġval Ġinclude Str ateg o Classes Ġ= Ġinput . str ateg o Runtime (). map Ġ{ Ġit . copy Classes () Ġ}. orElse ( false ) ĊĠĠĠ Ġval Ġcopy Resources Ġ= Ġfinal ized . compiler . get Copy Resources ( input ) ĊĊĠĠĠ Ġ// ĠAdd Ġlanguage Ġdependency . ĊĠĠĠ Ġval Ġlanguage Dependency Ġ= Ġinput . language Specification Dependency (). case Of () ĊĠĠĠĠĠ Ġ. project < Dependency > Ġ{ Ġproject . dependencies . project ( it ) Ġ} ĊĠĠĠĠĠ Ġ. module Ġ{ Ġproject . dependencies . module ( it . to Gradle Not ation ()) Ġ} ĊĠĠĠĠĠ Ġ. files Ġ{ Ġproject . dependencies . create ( project . files ( it )) Ġ} ĊĠĠĠ Ġproject . dependencies . add (" compile Language ", Ġlanguage Dependency ) ĊĊĠĠĠ Ġ// ĠUn pack Ġthe Ġ'. sp oof ax - language ' Ġarchive . ĊĠĠĠ Ġval Ġlanguage Files Ġ= Ġproject . configurations . get ByName (" language Files ") ĊĠĠĠ Ġval Ġunpack Sp oof ax Language Dir Ġ= Ġ"${ project . build Dir }/ unpack ed Sp oof ax Language /" ĊĠĠĠ Ġval Ġunpack Sp oof ax Language Task Ġ= Ġproject . tasks . register < Sync >(" unpack Sp oof ax Language ") Ġ{ ĊĠĠĠĠĠ Ġinputs . property (" input ", Ġinput ) ĊĠĠĠĠĠ Ġdepends On ( language Files ) ĊĠĠĠĠĠ Ġfrom ({ Ġlanguage Files . map Ġ{ Ġproject . zip Tree ( it ) Ġ} Ġ}) Ġ Ġ/* ĠClosure Ġinside Ġ` from ` Ġto Ġdefer Ġevaluation Ġuntil Ġtask Ġexecution Ġtime Ġ*/ ĊĠĠĠĠĠ Ġinto ( unpack Sp oof ax Language Dir ) ĊĊĠĠĠĠĠ Ġval Ġall Copy Resources Ġ= Ġcopy Resources . to Mutable List () ĊĠĠĠĠĠ Ġif ( include Str ateg o Classes ) Ġ{ ĊĠĠĠĠĠĠĠ Ġall Copy Resources . add (" target / metab org / str ateg o . jar ") ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġinclude ( all Copy Resources ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠCopy Ġresources Ġinto Ġ` main Source Set . java . output Dir ` Ġand Ġ` test Source Set . java . output Dir `, Ġso Ġthey Ġend Ġup Ġin Ġthe Ġtarget Ġpackage . ĊĠĠĠ Ġval Ġresources Copy Spec Ġ= Ġproject . copy Spec Ġ{ ĊĠĠĠĠĠ Ġfrom ( unpack Sp oof ax Language Dir ) ĊĠĠĠĠĠ Ġinclude ( copy Resources ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġstr ateg o Copy Spec Ġ= Ġproject . copy Spec Ġ{ ĊĠĠĠĠĠ Ġfrom ( project . zip Tree ("$ unpack Sp oof ax Language Dir / target / metab org / str ateg o . jar ")) ĊĠĠĠĠĠ Ġexclude (" META - INF ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġcopy Main Task Ġ= Ġproject . tasks . register < Copy >(" copy Main Resources ") Ġ{ ĊĠĠĠĠĠ Ġdepends On ( unpack Sp oof ax Language Task ) ĊĠĠĠĠĠ Ġinto ( project . the < Source Set Container >() [" main "]. java . output Dir ) ĊĠĠĠĠĠ Ġinto ( destination Package ) Ġ{ Ġwith ( resources Copy Spec ) Ġ} ĊĠĠĠĠĠ Ġif ( include Str ateg o Classes ) Ġ{ ĊĠĠĠĠĠĠĠ Ġinto (".") Ġ{ Ġwith ( str ateg o Copy Spec ) Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġproject . tasks . get ByName ( Java Plugin . CLASSES _ TASK _ NAME ). depends On ( copy Main Task ) ĊĠĠĠ Ġval Ġcopy Test Task Ġ= Ġproject . tasks . register < Copy >(" copy Test Resources ") Ġ{ ĊĠĠĠĠĠ Ġdepends On ( unpack Sp oof ax Language Task ) ĊĠĠĠĠĠ Ġinto ( project . the < Source Set Container >() [" test "]. java . output Dir ) ĊĠĠĠĠĠ Ġinto ( destination Package ) Ġ{ Ġwith ( resources Copy Spec ) Ġ} ĊĠĠĠĠĠ Ġif ( include Str ateg o Classes ) Ġ{ ĊĠĠĠĠĠĠĠ Ġinto (".") Ġ{ Ġwith ( str ateg o Copy Spec ) Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġproject . tasks . get ByName ( Java Plugin . TEST _ CLASSES _ TASK _ NAME ). depends On ( copy Test Task ) ĊĠ Ġ} Ċ } Ċ Ċ internal Ġfun ĠList < Project >. when All Language Projects Final ized ( closure : Ġ() Ġ-> ĠUnit ) Ġ{ ĊĠ Ġif ( isEmpty ()) Ġ{ ĊĠĠĠ Ġ// ĠNo Ġdependencies Ġto Ġwait Ġfor , Ġso Ġexecute Ġimmediately ĊĠĠĠ Ġclosure () ĊĠ Ġ} Ġelse Ġ{ ĊĠĠĠ Ġ// ĠAfter Ġfirst Ġproject Ġin Ġlist Ġis Ġfinal ized , Ġinvoke Ġwait Ġfor Ġthe Ġothers ĊĠĠĠ Ġfirst (). when Language Project Final ized Ġ{ ĊĠĠĠĠĠ Ġdrop ( 1 ). when All Language Projects Final ized ( closure ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ