import Ġcom . github . jen gel man . gradle . plugins . shadow . tasks . Shadow Jar Ċ import Ġcom . github . jen gel man . gradle . plugins . shadow . transformers . Components Xml Resource Transformer Ċ import Ġorg . gradle . internal . jvm . Jvm Ċ Ċ description Ġ= Ġ" Sh aded ĠMaven Ġdependencies Ġresolver " Ċ Ċ val ĠJDK _ 1 8 : ĠString Ġby Ġroot Project . extra Ċ val Ġjar Base Name Ġ= Ġproperty (" archives Base Name ") Ġas ĠString Ċ Ċ val Ġembedded Ġby Ġconfigurations Ċ Ċ embedded . apply Ġ{ ĊĠĠĠ Ġexclude (" org . slf 4 j ", Ġ" slf 4 j - api ") ĊĠĠĠ Ġexclude (" org . eclipse . ae ther ", Ġ" ae ther - api ") ĊĠĠĠ Ġexclude (" org . eclipse . ae ther ", Ġ" ae ther - util ") ĊĠĠĠ Ġexclude (" org . eclipse . ae ther ", Ġ" ae ther - spi ") Ċ } Ċ Ċ plugins Ġ{ ĊĠĠĠ Ġkotlin (" jvm ") ĊĠĠĠ Ġid (" j ps - compatible ") Ċ } Ċ Ċ dependencies Ġ{ ĊĠĠĠ Ġembedded ( project (": kotlin - script ing - dependencies - maven ")) Ġ{ Ġis Trans itive Ġ= Ġfalse Ġ} ĊĠĠĠ Ġembedded ( project (": kotlin - script ing - dependencies ")) Ġ{ Ġis Trans itive Ġ= Ġfalse Ġ} ĊĊĠĠĠ Ġembedded (" org . eclipse . ae ther : ae ther - connector - basic : 1 . 1 . 0 ") ĊĠĠĠ Ġembedded (" org . eclipse . ae ther : ae ther - transport - w agon : 1 . 1 . 0 ") ĊĠĠĠ Ġembedded (" org . eclipse . ae ther : ae ther - transport - file : 1 . 1 . 0 ") ĊĠĠĠ Ġembedded (" org . apache . maven : maven - core : 3 . 8 . 1 ") ĊĠĠĠ Ġembedded (" org . apache . maven . w agon : w agon - http : 3 . 4 . 3 ") Ċ } Ċ Ċ source Sets Ġ{ ĊĠĠĠ Ġ" main " Ġ{} ĊĠĠĠ Ġ" test " Ġ{} Ċ } Ċ Ċ publish () Ċ Ċ no Default Jar () Ċ sources Jar () Ċ javadoc Jar () Ċ Ċ val Ġmaven Packages To Re locate Ġ= ĠlistOf ( ĊĠĠĠ Ġ" org . eclipse ", ĊĠĠĠ Ġ" org . codehaus ", Ċ ) Ċ Ċ val Ġre located Jar Ġby Ġtask < Shadow Jar > Ġ{ ĊĠĠĠ Ġconfigurations Ġ= ĠlistOf ( embedded ) ĊĠĠĠ Ġduplicates Strategy Ġ= ĠD uplicates Strategy . INCLUDE ĊĠĠĠ Ġdestination Directory . set ( File ( build Dir , Ġ" libs ")) ĊĠĠĠ Ġarchive Classifier . set (" re located ") ĊĊĠĠĠ Ġtransform ( Components Xml Resource Transformer ()) ĊĊĠĠĠ Ġif Ġ( kotlin Build Properties . re location ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ( packages To Re locate Ġ+ Ġmaven Packages To Re locate ). forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġre locate ( it , Ġ"$ kotlin Embed d able Root Package .$ it ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ val Ġnormalize Components Xml End ings Ġby Ġtasks . register ing Ġ{ ĊĠĠĠ Ġdepends On ( re located Jar ) ĊĠĠĠ Ġval Ġoutput Directory Ġ= Ġbuild Dir . resolve ( name ) ĊĠĠĠ Ġval ĠoutputFile Ġ= Ġoutput Directory . resolve ( Components Xml Resource Transformer . COMPONENTS _ XML _ PATH ) ĊĠĠĠ Ġoutputs . file ( outputFile ) ĊĊĠĠĠ Ġdo First Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcomponents Xml Ġ= Ġzip Tree ( re located Jar . get (). single OutputFile ()). matching Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinclude Ġ{ Ġit . path Ġ== ĠComponents Xml Resource Transformer . COMPONENTS _ XML _ PATH Ġ} ĊĠĠĠĠĠĠĠ Ġ}. single (). read Text () ĊĠĠĠĠĠĠĠ Ġval Ġprocessed Components Xml Ġ= Ġcomponents Xml . replace ("\ r \ n ", Ġ"\ n ") ĊĠĠĠĠĠĠĠ Ġoutput Directory . mkdir s () ĊĠĠĠĠĠĠĠ ĠoutputFile . write Text ( processed Components Xml ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ val Ġnormalized Jar Ġby Ġtask < Jar > Ġ{ ĊĠĠĠ Ġdepends On ( re located Jar ) ĊĠĠĠ Ġdepends On ( normalize Components Xml End ings ) ĊĊĠĠĠ Ġarchive Classifier . set (" normalized ") ĊĊĠĠĠ Ġfrom Ġ{ ĊĠĠĠĠĠĠĠ Ġzip Tree ( re located Jar . get (). single OutputFile ()). matching Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexclude ( Components Xml Resource Transformer . COMPONENTS _ XML _ PATH ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinto ( Components Xml Resource Transformer . COMPONENTS _ XML _ PATH . substring Before Last ("/ ")) Ġ{ ĊĠĠĠĠĠĠĠ Ġfrom Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnormalize Components Xml End ings . get (). single OutputFile () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ val Ġpro guard Ġby Ġtask < Cache able Pro guard Task > Ġ{ ĊĠĠĠ Ġdepends On ( normalized Jar ) ĊĠĠĠ Ġconfiguration (" dependencies - maven . pro ") ĊĊĠĠĠ Ġinj ars ( map Of (" filter " Ġto Ġ"! META - INF / versions /** , ! kotlin x / coroutines / debug /** "), Ġnormalized Jar . get (). outputs . files ) ĊĊĠĠĠ Ġout j ars ( file From ( build Dir , Ġ" libs ", Ġ"$ jar Base Name -$ version - after - pro guard . jar ")) ĊĊĠĠĠ Ġjava Launcher . set ( project . get Tool chain Launcher For ( J dk Major Version . JDK _ 1 _ 8 )) ĊĊĠĠĠ Ġlibrary j ars ( ĊĠĠĠĠĠĠĠ Ġfiles ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġjava Launcher . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfirst From Java Home That Exists ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" jre / lib / rt . jar ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"../ Classes / classes . jar ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġj dk Home Ġ= Ġit . metadata . installation Path . as File ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġjava Launcher . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfirst From Java Home That Exists ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" jre / lib / js se . jar ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"../ Classes / js se . jar ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġj dk Home Ġ= Ġit . metadata . installation Path . as File ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġjava Launcher . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠJ vm . for Home ( it . metadata . installation Path . as File ). tools Jar ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) Ċ } Ċ Ċ val Ġresult Jar Ġby Ġtask < Jar > Ġ{ ĊĠĠĠ Ġval Ġpack Ġ= Ġif Ġ( kotlin Build Properties . pro guard ) Ġpro guard Ġelse Ġnormalized Jar ĊĠĠĠ Ġdepends On ( pack ) ĊĠĠĠ Ġsetup Public Jar ( jar Base Name ) ĊĠĠĠ Ġfrom Ġ{ ĊĠĠĠĠĠĠĠ Ġzip Tree ( pack . get (). single OutputFile ()) ĊĠĠĠ Ġ} Ċ } ĊĊ Ċ add Artifact (" runtime ", Ġresult Jar ) Ċ add Artifact (" runtime Elements ", Ġresult Jar ) Ċ add Artifact (" archives ", Ġresult Jar ) Ċ