Created
September 5, 2018 10:48
-
-
Save jmfayard/d17c9142f065ea7d5dbae9f359372b39 to your computer and use it in GitHub Desktop.
Custom task with gradle kotlin buildSrc
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
| // app/build.gradle | |
| task updatewhatsnew << { | |
| GooglePlay.updateWhatsNew(project.projectDir, niceVersion) | |
| } | |
| tasks.whenTaskAdded { task -> | |
| if (task.name == "publishListingProductionRelease") { | |
| task.dependsOn updatewhatsnew | |
| } | |
| } |
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
| // buildSrc/build.gradle.ktsbuildSrc/build.gradle.kts | |
| plugins { | |
| `kotlin-dsl` | |
| } | |
| repositories { | |
| jcenter() | |
| } | |
| dependencies { | |
| //... | |
| } |
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
| // buildSrc/src/main/java/GooglePlay.kt | |
| import java.io.File | |
| object GooglePlay { | |
| @JvmStatic | |
| fun updateWhatsNew(projectDir: File, version: String) { | |
| val files: List<File> = listOf( | |
| "src/production/play/en-US/listing/whatsnew-alpha", | |
| "src/production/play/en-US/whatsnew", | |
| "src/production/play/en-US/whatsnew-alpha" | |
| ).map { projectDir.resolve(it) } | |
| val fileContent = "KartaunBele $version" | |
| for (file in files) { | |
| check(file.canWrite()) { "Cannot write on ${file.absolutePath}" } | |
| println("Updating ${file.absolutePath} with content [$fileContent]") | |
| file.writeText("KartaunBele $version") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment