import Ġorg . jetbrains . kotlin . gradle . tasks . Kotlin Compile Ċ Ċ plugins Ġ{ ĊĠ Ġantlr ĊĠ Ġ` java - library ` ĊĠ Ġkotlin (" jvm ") ĊĠ Ġkotlin (" k apt ") Ċ } Ċ Ċ dependencies Ġ{ ĊĠ Ġadd (" antlr ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . antlr . antlr ")) ĊĠ Ġadd (" implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . kotlin . std Lib ")) ĊĠ Ġadd (" implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . mos hi . adapters ")) ĊĠ Ġadd (" implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . mos hi . mos hi ")) ĊĠ Ġadd (" implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . po et . java ")) ĊĠ Ġadd (" implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . po et . kotlin ")) ĊĠ Ġadd (" implementation ", Ġproject (": apollo - api ")) ĊĊĠ Ġadd (" k apt ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . mos hi . kotlin Code gen ")) ĊĊĊĠ Ġadd (" test Implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . compile testing ")) ĊĠ Ġadd (" test Implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . kotlin Compile Testing ")) ĊĠ Ġadd (" test Implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . junit ")) ĊĠ Ġadd (" test Implementation ", Ġgro ovy . util . Eval . x ( project , Ġ" x . dep . truth ")) Ċ } Ċ Ċ abstract Ġclass ĠGenerate Plugin Version Ġ: ĠDefault Task () Ġ{ ĊĠ Ġ@ get : org . gradle . api . tasks . Input ĊĠ Ġabstract Ġval Ġversion : ĠProperty < String > ĊĊĠ Ġ@ get : org . gradle . api . tasks . OutputFile ĊĠ Ġabstract Ġval ĠoutputFile : ĠRegular File Property ĊĊĠ Ġ@ org . gradle . api . tasks . Task Action ĊĠ Ġfun Ġtask Action () Ġ{ ĊĠĠĠ Ġval Ġversion File Ġ= ĠoutputFile . as File . get () ĊĠĠĠ Ġversion File . parent File . mkdir s () ĊĠĠĠ Ġversion File . write Text (""" // ĠGenerated Ġfile . ĠDo Ġnot Ġedit ! Ċ package Ġcom . ap ol log raph ql . apollo . compiler Ċ val ĠVERSION Ġ= Ġ"${ project . version }" Ċ """) ĊĠ Ġ} Ċ } Ċ Ċ val Ġplugin Version Task Provider Ġ= Ġtasks . register (" plugin Version ", ĠGenerate Plugin Version :: class . java ) Ġ{ ĊĠ ĠoutputFile . set ( project . layout . build Directory . file (" generated / kotlin / com / ap ol log raph ql / apollo / compiler / Version . kt ")) ĊĠ Ġversion . set ( project . version . toString ()) Ċ } Ċ Ċ tasks . with Type ( Kotlin Compile :: class . java ) Ġ{ ĊĠ Ġval Ġversion File Provider Ġ= Ġplugin Version Task Provider . flatMap Ġ{ Ġit . outputFile Ġ} ĊĠ Ġsource ( version File Provider ) Ċ } Ċ Ċ tasks . with Type < Check style > Ġ{ ĊĠ Ġexclude (" ** com / ap ol log raph ql / apollo / compiler / parser / antlr /** ") Ċ } Ċ Ċ // Ġsince Ġtest / graphql Ġis Ġnot Ġan Ġinput Ġto ĠTest Ġtasks , Ġthey 're Ġnot Ġrun Ġwith Ġthe Ġchanges Ġmade Ġin Ġthere . Ċ tasks . with Type < Test >(). configure Each Ġ{ Ġoutputs . up ToDate When Ġ{ Ġfalse Ġ} Ġ} Ċ