@ file : Jvm Name (" Main Kt ") Ċ Ċ package Ġcom . github . r ong i . generator Ċ Ċ import Ġjava . io . File Ċ import Ġjava . io . FileInputStream Ċ import Ġjava . io . IOException Ċ import Ġjava . io . PrintWriter Ċ import Ġjava . util .* Ċ import Ġkotlin . system . exit Process Ċ Ċ private Ġconst Ġval ĠDEFAULT _ CONFIG _ FILE Ġ= Ġ" di k ter . properties " Ċ Ċ fun Ġmain ( args : ĠArray < String >) Ġ{ Ċ ĉ val Ġdomain Package : ĠString Ċ ĉ val Ġentity Package : ĠString Ċ ĉ val Ġtransform Package : ĠString ĊĊ ĉ val Ġoutput Dir : ĠString Ċ ĉ val ĠfileName : ĠString ĊĊ ĉ val Ġconfig File Ġ= ĠFile ( DEFAULT _ CONFIG _ FILE ); ĊĊ ĉ if Ġ( args . size Ġ>= Ġ 1 Ġ&& Ġargs [ 0 ] Ġ== Ġ"-- init ") Ġ{ Ċĉ ĉ init Environment () Ċĉ ĉ return Ċ ĉ } ĊĊ ĉ if Ġ( configFile . exists () Ġ&& Ġ! configFile . isDirectory ) Ġ{ Ċĉ ĉ val Ġproperties Ġ= Ġread Properties () ĊĊĉ ĉ domain Package Ġ= Ġproperties . getProperty (" domain Package ") Ċĉ ĉ entity Package Ġ= Ġproperties . getProperty (" entity Package ") Ċĉ ĉ transform Package Ġ= Ġproperties . getProperty (" transform Package ") Ċĉ ĉ output Dir Ġ= Ġproperties . getProperty (" src ") ĊĊĉ ĉ if Ġ( args . size Ġ< Ġ 1 ) Ġexit With Help Message () Ċĉ ĉ fileName Ġ= Ġargs [ 0 ] Ċ ĉ } Ġelse Ġ{ Ċĉ ĉ if Ġ( args . size Ġ< Ġ 4 ) Ġexit With Help Message () ĊĊĉ ĉ domain Package Ġ= Ġargs [ 1 ] Ċĉ ĉ entity Package Ġ= Ġargs [ 2 ] Ċĉ ĉ transform Package Ġ= Ġargs [ 3 ] Ċĉ ĉ output Dir Ġ= Ġ"." ĊĊĉ ĉ fileName Ġ= Ġargs [ 0 ] Ċ ĉ } ĊĊ ĉ val Ġgenerated Ġ= Ġgenerate ( fileName . as File (), Ġdomain Package , Ġentity Package , Ġtransform Package ) Ċ ĉ generated . dump Re cursively ( output Dir ) Ċ } Ċ Ċ fun ĠGenerated . dump Re cursively ( output Dir : ĠString ) Ġ{ Ċ ĉ val Ġoutput Dir File Ġ= Ġoutput Dir . as File () ĊĊ ĉ domain . writeTo ( output Dir File ) Ċ ĉ println (" Po ured : Ġ${ domain . to Java FileObject (). name }") ĊĊ ĉ entity . writeTo ( output Dir File ) Ċ ĉ println (" Po ured : Ġ${ entity . to Java FileObject (). name }") ĊĊ ĉ transform . writeTo ( output Dir File ) Ċ ĉ println (" Po ured : Ġ${ transform . to Java FileObject (). name }") ĊĊ ĉ from Children . forEach Ġ{ Ġit . dump Re cursively ( output Dir ) Ġ} Ċ } Ċ Ċ fun Ġexit With Help Message () Ġ{ Ċ ĉ exit With Message (" usage : Ġ\ n " Ġ+ Ċĉ ĉ " di k ter Ġ< json _ file > Ġ< path _ where _ to _ generate > Ġ< domain _ package > Ġ< entity _ package > Ġ< transform _ package >\ n " Ġ+ Ċĉ ĉ " or \ n " Ġ+ Ċĉ ĉ " di k ter Ġ< json _ file >\ n " Ġ+ Ċĉ ĉ " if Ġyou Ġhave Ġfile Ġd ik ter . properties Ġin Ġthe Ġworking Ġdirectory \ n " Ġ+ Ċĉ ĉ " with Ġproperties : Ġsrc , Ġdomain Package , Ġentity Package , Ġthen Ġuse Ġthis Ġutil Ġwith :\ n " Ġ+ Ċĉ ĉ " di k ter Ġ-- init \ n " Ġ+ Ċĉ ĉ " Creates Ġproperties Ġfile \ n ") Ċ } Ċ Ċ private Ġfun Ġexit With Message ( message : ĠString ) Ġ{ Ċ ĉ println ( message ) Ċ ĉ exit Process ( 0 ) Ċ } ĊĊ Ċ fun Ġread Properties (): ĠProperties Ġ{ Ċ ĉ val Ġproperties Ġ= ĠProperties () ĊĊ ĉ try Ġ{ Ċĉ ĉ val Ġinput Ġ= ĠFileInputStream ( DEFAULT _ CONFIG _ FILE ) Ċĉ ĉ properties . load ( input ) Ċĉ ĉ input . close () Ċ ĉ } Ġcatch Ġ( ex : ĠIOException ) Ġ{ Ċĉ ĉ ex . printStackTrace () Ċ ĉ } ĊĊ ĉ return Ġproperties Ċ } Ċ Ċ fun Ġinit Environment () Ġ{ Ċ ĉ val ĠINITIAL _ PROPERTIES Ġ= Ġ""" Ċĉĉĉĉĉ ĉ src = project / src / main / java / Ċĉĉĉĉĉ ĉ domain Package = com . example . test . domain Ċĉĉĉĉĉ ĉ entity Package = com . example . test . entities Ċĉĉĉĉĉ ĉ transform Package = com . example . test . transform """. trim Indent () ĊĊ ĉ val Ġout Ġ= ĠPrintWriter ( DEFAULT _ CONFIG _ FILE ) Ċ ĉ out . println ( INITIAL _ PROPERTIES ) Ċ ĉ out . close () ĊĊ ĉ println (" di k ter Ġproperties Ġcreated ") Ċ }