• Automate simple parts of your build process • Provide the framework to use outside tools in your build • Extract useful information about the build process
files to define the configuration of the app ◦ Cross-platform between iOS and Android • Some of the configurable elements: ◦ Server endpoints (and other various networking pieces) ◦ UI Elements (Individual layouts, Drawer items, colors) ◦ Core features (User signup) • These JSON files come from third-party teams • The people who make these JSON files may not be in technical roles
you just use an online JSON formatter? • These JSON files change often • We deal with third-party developers in our codebase • These are dumb, painful mistakes that can be prevented
in Java, Kotlin, or Groovy • You will always have Gradle when building your Android app • Use all the Java libraries and tools in your plugin • Build on top of other Gradle plugins • Integrate into your build
with an exception. * What went wrong: A problem occurred configuring project ':consumer'. > Could not resolve all dependencies for configuration ':consumer:classpath'. > Could not find ninja.bryansills:gradle-json-verify:0.0.1. Searched in the following locations: https://jcenter.bintray.com/ninja/bryansills/gradle-json-verify/0.0.1/gradle-json-verify-0.0.1.pom https://jcenter.bintray.com/ninja/bryansills/gradle-json-verify/0.0.1/gradle-json-verify-0.0.1.jar Required by: project :consumer * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 2.826 secs
lifecycle: ◦ Initialization ◦ Configuration ◦ Execution • All projects need to configured before they are executed… • But the consumer needs a compiled plugin… • So...
and upload the .jar to a local or remote repository • Solves the configuration phase issue • A little tedious while doing iterative development on the plugin ◦ Ughhhhhhhhhhhhh 2 different commands
'./gradle-json-verify' • Fairly new feature in Gradle (Added in late 2016) • A composite build is simply a build that includes other builds • Allows the plugin to be fully built before the consumer needs it
"price": 12.50, "tags": ["home", "green"], } $ ./gradlew :consumer:preBuild [composite-build] Configuring build: /Users/bsills/android/backup/gradle-json-verify :gradle-json-verify:compileJava :gradle-json-verify:pluginDescriptors UP-TO-DATE :gradle-json-verify:processResources UP-TO-DATE :gradle-json-verify:classes :gradle-json-verify:jar :consumer:jsonVerify FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':consumer:jsonVerify'. > Expected name at path $.tags in file: sample.json * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 1.129 secs