Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin Annotation Processor Tools(kapt)

Kotlin Annotation Processor Tools(kapt)

TISとのLTでのKotlin Annotation Processor Tools(kapt)の話
kapt1、kapt2、dagger2のworkaroundとか動作とか調べたやつ

4b521e2af229c69fa0f20b29b14c3edc?s=128

Naohiro Yoshida

March 07, 2017
Tweet

Transcript

  1. ,PUMJO"OOPUBUJPO1SPDFTTPS5PPMT ,BQU .BSDI  ! /BPIJSP:PTIJEB 3FDSVJU5FDIOPMPHJFT$P -UE

  2. %*$POUBJOFSJTSFRVJSFE
 0UIFSGSBNFXPSLTUPSFEVDFCPJMFSQMBUFDPEFJTSFRVJSFE "OESPJEJTOPUKVTUBGSPOUFOE
 CVUBGVMMTUBDLBQQMJDBUJPO "OESPJE $MFBO"SDIJUFDUVSF

  3. "WPJESFqFDUJPO ˚+%,%ZOBNJD1SPYZ ! +BWBCZUFDPEFNBOJQVMBUJPOBUSVOUJNF
 JTHFOFSBMMZVOBWBJMBCMF º$(-JC "TQFDU+-58 MPBEUJNFXFBWJOH  "OESPJE5IFPSZ

  4. "OOPUBUJPO1SPDFTTJOH +43  (FOFSBUFKBWBTPVSDFDPEFGSPNPSJHJOBMKBWBTPVSDF "DUJWJUZKBWB "DUJWJUZ@.FNCFST*OKFDUPS
 KBWB !*OKFDU (FOFSBUFE'JMF ˞MPNCPLEPFT`UHFOFSBUFTPVSDFDPEFCVUUSBOTGPSN"45

    BCTUSBDUTZOUBYUSFF  KBWBD
  5. ,PUMJO -JHIUXFJHIU"MU+BWB OVMMTBGF DPNQJMFFSSPS WBSNPEFM.PEFMOVMM
 GVOFYFDVU IPHF.PEFM \NPEFMIPHF^
 DPNQJMFFSSPS 

    WBSNPEFM.PEFM OVMM
 GVOFYFDVUF IPHF4USJOH NPEFM FYFDVUF IPHF  $PNQJMF&SSPS 4VQQSFTT/VMMBCMF&YFDVUJPO
  6. ,PUMJO KBWBJOUFSPQFSBUCJMJUZ (FOFSBUFDMBTTCZ"4.MJLFTDBMB DMPKVSF generate stub for javac javac kotlinc

    LU DPNQJMFKBWB XJUITUVC DPNQJMFLI XJUIKBWBDMBTT TUVC
  7. 1SPCMFN "DUJWJUZLU !*OKFDU "DUJWJUZ@.FNCFST*OKFDUPSLU LU LU º(FOFSBUFE "DUJWJUZLU !*OKFDU "DUJWJUZ@.FNCFST*OKFDUPSKBWB

    LU º(FOFSBUFE LPUMJOD KBWBD XJUI+43 LPUMJODEPFTO`UTVQQPSU+43
 KBWBDDBO`USFBEBOOPUBUJPOPGLU
  8. ,BQU "OOPUBUJPO1SPDFTTPSGPSLPUMJO -FUKBWBDSFBELUBOOPUBUJPO "DUJWJUZLU "DUJWJUZ@.FNCFST*OKFDUPS
 KBWB !*OKFDU (FOFSBUFE'JMF LBQU BOEKBWBD

  9. ,BQU LU BOOPUBUJPO
 YYYUYU generate stub javac kotlinc "OOPUBUJPO 1SPDFTTPS

    XSBQQFE SVOBTHSBEMFUBTL EBHHFS EBUBCJOEJOH PSNB ʜ TUVC BEEBOOPUBUJPOJOGPUPDMBTT DBMMVOXSBQQFEBOOPUBUJPOQSPDFTTPS
  10. 6OTUBCMF Τϥʔ NonExistentClassʹΞΫηεͰ͖·ͤΜ error.NonExistentClassͷΫϥεɾϑΝΠϧ͕ݟ͔ͭΓ·ͤΜ ৄࡉ͸࣍ͷελοΫɾτϨʔεͰௐ͍ࠪͯͩ͘͠͞ɻ com.sun.tools.javac.code.Symbol$CompletionFailure: error.NonExistentClassͷΫϥεɾϑΝΠϧ͕ݟ͔ͭΓ·ͤΜ Τϥʔݸ :PVIBWFUZQFTHFOFSBUFECZ"OOPUBUJPO1SPDFTTJOHJOZPVSEFDMBSBUJPOTJHOBUVSFT MJLFGVO

    QSPWJEF0SNB%BUBCBTF DPOUFYU$POUFYU PSMBUFJOJUWBSPSNB0SNB%BUBCBTF#FDBVTF,PUMJO NBLFTJUTTUVCTCFGPSF+BWB"OOPUBUJPO1SPDFTTJOHSVOT ,PUMJOLOPX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