▸ A step for a workflow ▸ Open a pull request in Mercari repository ▸ Overwrite the version with the latest one ▸ git merge and push to create a pull request ▸ Static code analysis result aggregation Shibuya.apk #36 14
Gradle Custom Tasks work 1. Put a custom task implementation under buildSrc 2. Register the custom task in build.gradle of project root 3. Run the Gradle command! Shibuya.apk #36 15
custom task in Kotlin open class MyCustomTask : DefaultTask() { @Input lateinit var parameter: String @TaskAction fun execute() { println(parameter) } } 18 Shibuya.apk #36
be open open class MyCustomTask : DefaultTask() { @Input lateinit var parameter: String @TaskAction fun execute() { println(parameter) } } 19 Shibuya.apk #36
fun aggregate() { // 2. Create a file for aggregation val aggregatedFile = File(“${project.rootDir}/result.xml”) if (aggregatedFile.exists().not()) { aggregatedFile.createNewFile())( } } 34 Shibuya.apk #36
fun aggregate() { // 3. Copy <issue> nodes in each file to aggregated file val rootNode = Node( null, “issues”, mapOf(“format” to “5”, “by” to “lint 3.4.0”) ) } 36 Shibuya.apk #36
fun aggregate() { // 3. Copy <issue> nodes in each file to aggregated file val rootNode = // …… reports.forEach { report -> val elements = XmlParser().parse(report).children() if (elements.isEmpty()) { return@forEach } } } 37 Shibuya.apk #36
What’s good? ▸ No change on static code analysis configuration when you have a new module ▸ e.g. Danger to report the Lint issues Shibuya.apk #36 41 android_lint.report_file = “./reports.xml” android_lint.filtering = true android_lint.lint(inline_mode: true)
Gradle Custom Tasks work 1. Put a custom task implementation under buildSrc 2. Register the custom task in build.gradle of project root 3. Run the Gradle command! Shibuya.apk #36 42
Is it OK to do some Network I/O? ▸ Definitely! ▸ You can enhance your task with Web APIs (e.g. GitHub API, CircleCI API) ▸ Can I use Git commands from the task? ▸ Yes! ▸ Use org.eclipse.jgit library to make it easier Shibuya.apk #36 43