/* Ċ Ġ* ĠCopyright Ġ 2 0 1 9 ĠNet flix , ĠInc . Ċ Ġ* Ċ Ġ* Ġ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 Ġcom . netflix . spin n aker . gradle . extension Ċ Ċ import Ġcom . netflix . spin n aker . gradle . extension . Plugins . AS SE MB LE _ PLUGIN _ TASK _ NAME Ċ import Ġcom . netflix . spin n aker . gradle . extension . extensions . Sp inn aker Bundle Extension Ċ import Ġcom . netflix . spin n aker . gradle . extension . extensions . Sp inn aker Plugin Extension Ċ import Ġcom . netflix . spin n aker . gradle . extension . tasks . As semble Java Plugin Zip Task Ċ import Ġorg . gradle . api . Plugin Ċ import Ġorg . gradle . api . Project Ċ import Ġorg . gradle . api . plugins . Java Plugin Ċ import Ġorg . gradle . api . tasks . bund ling . Jar Ċ import Ġjava . lang . IllegalStateException Ċ Ċ /** Ċ Ġ* ĠGradle Ġplugin Ġto Ġsupport Ġsp inn aker Ġservice Ġplugin Ġbund ling Ġaspects . Ċ Ġ* Ċ Ġ* ĠTODO ( rz ): ĠAdd Ġsp inn aker Ġbin tray Ġto Ġrepositories Ċ Ġ* ĠTODO ( rz ): ĠConfigure Ġplugin Ġmanifest Ċ Ġ* ĠTODO ( rz ): ĠAuto - add Ġ` annotation Processor Ġ" org . pf 4 j : pf 4 j : 3 . 2 . 0 "` Ċ Ġ*/ Ċ class ĠSp inn aker Service Extension Plugin Ġ: ĠPlugin < Project > Ġ{ ĊĊĠ Ġoverride Ġfun Ġapply ( project : ĠProject ) Ġ{ ĊĠĠĠ Ġproject . plugins . apply ( Java Plugin :: class . java ) ĊĠĠĠ Ġproject . extensions . create (" spin n aker Plugin ", ĠSp inn aker Plugin Extension :: class . java ) ĊĠĠĠ Ġproject . tasks . register ( AS SE MB LE _ PLUGIN _ TASK _ NAME , ĠAs semble Java Plugin Zip Task :: class . java ) ĊĊĠĠĠ Ġproject . tasks . get ByName (" jar ") ĊĠĠĠĠĠ Ġ. do First Ġ{ ĊĠĠĠĠĠĠĠ Ġ( it Ġas ĠJar ). create Plugin Manifest ( project ) ĊĠĠĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠJar . create Plugin Manifest ( project : ĠProject ) Ġ{ ĊĠĠĠ Ġval Ġplugin Ext Ġ= Ġproject . extensions . findBy Type ( Sp inn aker Plugin Extension :: class . java ) ĊĠĠĠĠĠ Ġ?: Ġthrow ĠIllegalStateException (" A Ġ' spin n aker Plugin ' Ġconfiguration Ġblock Ġis Ġrequired ") ĊĊĠĠĠ Ġval Ġbundle Ext Ġ= Ġproject . root Project . extensions . findBy Type ( Sp inn aker Bundle Extension :: class . java ) ĊĠĠĠĠĠ Ġ?: Ġthrow ĠIllegalStateException (" A Ġ' spin n aker Bundle ' Ġconfiguration Ġblock Ġis Ġrequired ") ĊĊĠĠĠ Ġval Ġattributes Ġ= Ġmutable Map Of < String , ĠString >() ĊĊĠĠĠ Ġapply Attribute If Set ( attributes , Ġ" Plugin - Class ", Ġplugin Ext . plugin Class ) ĊĠĠĠ Ġapply Attribute If Set ( attributes , Ġ" Plugin - Id ", Ġ"${ bundle Ext . plugin Id }-${ plugin Ext . serviceName }") ĊĠĠĠ Ġapply Attribute If Set ( attributes , Ġ" Plugin - Version ", Ġbundle Ext . version ) ĊĠĠĠ Ġapply Attribute If Set ( attributes , Ġ" Plugin - Dependencies ", Ġplugin Ext . dependencies ) ĊĠĠĠ Ġapply Attribute If Set ( attributes , Ġ" Plugin - Description ", Ġbundle Ext . description ) ĊĠĠĠ Ġapply Attribute If Set ( attributes , Ġ" Plugin - Provider ", Ġbundle Ext . provider ) ĊĠĠĠ Ġapply Attribute If Set ( attributes , Ġ" Plugin - License ", Ġbundle Ext . license ) ĊĊĠĠĠ Ġmanifest . attributes ( attributes ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġapply Attribute If Set ( attributes : ĠMutable Map < String , ĠString >, Ġkey : ĠString , Ġvalue : ĠString ?) Ġ{ ĊĠĠĠ Ġif Ġ( value Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠ Ġattributes [ key ] Ġ= Ġvalue ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ