Created
May 2, 2020 12:09
-
-
Save PaoloMilano/4ebda4ab66b3f3cf193dfff412ee0fb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyFirstPlugin : Plugin<Project> { | |
| override fun apply(project: Project) { | |
| project.android().variants().all { variant -> | |
| // Make a task for each combination of build type and product flavor | |
| val myTask = "myFirstTask${variant.name.capitalize()}" | |
| // Register a simple task as a lambda. We can later move this to its own | |
| // class to make our code cleaner and also add some niceties. | |
| project.tasks.create(myTask){task -> | |
| // Group all our plugin's tasks together | |
| task.group = "MyPluginTasks" | |
| task.doLast { | |
| File("${project.projectDir.path}/myFirstGeneratedFile.txt").apply { | |
| writeText("Hello Gradle!\nPrinted at: ${SimpleDateFormat("HH:mm:ss").format(Date())}") | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment