More info on Slack Incoming Webhooks and how to generate them here.Īnd now to run this task from command line type. In this case, I’m going to depend on okHttp to do the networking. We will use it to set up the Gradle Kotlin plugin and library dependencies that our custom task will use. This folder is automatically detected by Gradle so you don’t need to configure it anywhere. Hence I decided to write my own tutorial.įirst, create a folder called buildSrc in your project’s root. Most of the tutorials I found were talking about creating a Gradle plugin project with Kotlin and then there was the Gradle Kotlin DSL project, etc. Surprisingly, I couldn’t find anything about how to hook up Kotlin with Gradle in the buildSrc setup. This option felt like the way to go in this case. The last option is to have a folder called buildSrc in your project’s root folder and put everything there. That might have been my first choice, but I planned on having only one class that defines the custom task and less code is always better. I’ll definitely have another look when the DSL matures.Īnother option is to make a standalone Gradle plugin project. Although there’s a Gradle Kotlin DSL work-in-progress, but after checking out the examples, I decided not to try it since it looks like it adds more code to adle than it reduces and overall the DSL doesn’t look as nice as it looks in Groovy (just my opinion). You can just write Groovy code in your adle or make it a bit nicer and have it in a separate Gradle file, say adle, and apply it to your app’s adle with apply from: 'adle'. Project structureĬreating a custom Gradle task can be done in different ways. So I decided to create my own custom task to do that and while I’m at it have it written in Kotlin (of course :P). I found one, but it wasn’t flexible enough as I wanted it to be. The first thing I did was to look for a pre-made solution in the form of a Gradle plugin. Since Android is built with Gradle and in my opinion Gradle is just pure awesomeness, I thought why not just have a task that does just that. Recently, I had the need to send a Slack message from our CI server during our Android app build.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |