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

Gradle Convention Plugins

Matsuda Jumpei
September 14, 2023

Gradle Convention Plugins

DroidKaigi 2023 Day.1 Bunblemee 11:20-12:00

Submitted description ->

Gradle Convention Plugins allow us to easily/effectively apply shared configurations across projects a.k.a modules especially for Android developers. Convention plugins have some advantages in build phases much more than shared build scripts. However, we have to implement plugins *correctly* to get the advantages because wrong implementations/configurations may bring negative impacts to Gradle's build features like configuration cache.

This presentation will explain why Gradle Convention Plugins are good to know for Android developers, and show how to build Gradle plugins from scratch and some plugin examples that collaborate with Android Gradle Plugin.

Keywords: Gradle plugin, convention plugin, build logic, precompiled script plugins

Matsuda Jumpei

September 14, 2023
Tweet

More Decks by Matsuda Jumpei

Other Decks in Programming

Transcript

  1. 3 Jumpei Matsuda @red_fat_daruma Software Architect at DeployGate, Inc. Android

    App and SDK Development Gradle Plugin Development Development Productivity Engineering and more... .F https://deploygate.com
  2. 6OXBOUFE$POWFOUJPO1MVHJOT w )JHIGSFRVFOUBOEPSIFBWZSFDPNQJMBUJPO w *ODSFNFOUBMCVJMETBSFOPUTVQQPSUFE w 3FDPNQJMBUJPOOFFETUPSVOXJUIPVUDPEFNPEJ fi DBUJPO w

    -FTTDBDIFEEVFUPVTFPG"1*TMJLF4ZTUFNHFUFOW 4USJOH  w 8*--.",&)*()&3$0454< > w 4MPXMPDBM$*CVJMETBMTPEBNBHFZPVSQSPEVDUJWJUZ 20 [1] https://github.blog/2022-12-08-experiment-the-hidden-costs-of-waiting-on-slow-build-times/ [2] https://gradle.com/blog/quantifying-the-costs-of-builds/
  3. $PNQPTJUF#VJMETº1MVHJOXSJUJOH w )PXUPFOBCMF$PNQPTJUF#VJMET w 6TFQSFEF fi OFEEJSFDUPSZPSNBOVBMSFHJTUSBUJPO w 1MVHJOXSJUJOH w

    1SFDPNQJMFETDSJQUQMVHJOPSTUBOEBMPOFQMVHJO w 1SPHSBNNJOH-BOHVBHFT w 1SFGFSSBCMF"1*TBOEDPEFTNFMMT 29
  4. w :PVDBODBMMJODMVEF#VJME 4USJOH NVMUJQMFUJNFT w JF:PVDBODSFBUFNVMUJQMFQMVHJOTJONVMUJQMFQSPKFDUT w )PXFWFS JUNBZNBLFUIFDPO fi

    HVSBUJPOQIBTFMPOHFSUIBOCVJME4SD w "UUIFFOEPG 4RVBSFSFQPSUFEEFHSBEFEVFUPTJOHMF UISFBEFEEFQFOEFODZSFTPMVUJPOJO$PNQPTJUF#VJMET<> w /05&4RVBSFHBWF GPSDPOWFOUJPOQMVHJOT .VMUJQMFJODMVEF#VJMEDBMMTNBZCF 35 [1] https://developer.squareup.com/blog/herding-elephants/
  5. $PNQPTJUF#VJMETº1MVHJOXSJUJOH w )PXUPFOBCMF$PNQPTJUF#VJMET w CVJME4SDJODMVEF#VJME"1*BSF fi OFCVUTJOHMFCVJMEJTQSFGFSSFE w 1MVHJOXSJUJOH w

    1MVHJOQSPKFDUTUZMFT w 1SPHSBNNJOH-BOHVBHFT w 1SFGFSBCMF"1*TBOEDPEFTNFMMT w "OESPJE(SBEMF1MVHJODPMMBCPSBUJPO 36
  6. 1MVHJOXSJUJOH w 1SFDPNQJMFETDSJQUQMVHJOPSTUBOEBMPOFQMVHJOBLBCJOBSZQMVHJO w 4UBOEBMPOFQMVHJODBOHFUCFOF fi UTPGCVJMEDBDIFFOPVHI w 1SPHSBNNJOH-BOHVBHFT w

    4UBUJDUZQFE+7.MBOHVBHFTPSVTF$PNQJMF4UBUJDJO(SPPWZ w 1SFGFSBCMF"1*TBOEDPEFTNFMMT w "OESPJE(SBEMF1MVHJODPMMBCPSBUJPO 43
  7. 1SFGFSBCMF"1*TBOEDPEFTNFMMT w 2%PDPOWFOUJPOQMVHJOTOFFETQFDJBM(SBEMF"1*T  w "/P JUTKVTUBDPNNPOQMVHJOEFWFMPQNFOU w 2%PDPOWFOUJPOQMVHJOTDBSFTQFDJBMMZ 

    w ":FT ZPVTIPVME*UTNFBOJOHMFTTJG$PNQPTJUF#VJMETUBLFUJN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SUIBOPUIFST w 6TF(SBEMF&OUFSQSJTFUPEFUFDUJTTVFTZPVTIPVMEBEESFTT 53 [1] https://developer.squareup.com/blog/herding-elephants/
  11. 8SBQVQ  w 6OEFSTUBOEJOH(SBEMFTCVJMENFDIBOJTNXJMMCFZPVSIFMQ w $PNQPTJUF#VJMET -B[Z"1* "OESPJE(SBEMF1MVHJOJOUFSGBDFTFUD w %POUGPSHFUUIBUUIFCFTUQSBDUJDFTBMXBZDBSFDBDIJOH

    w (FUJOUPVDIXJUINFBUUIF&YIJCJUJPO"SFBGPS0 ff i DF)PVSBOEPS UBMLJOQFSTPOBUUIF"GUFS1BSUZ🍻 w 5IBOLZPVTPNVDIGPSMJTUFOJOHUPNZQSFTFOUBUJPO 55