Iterate Fast With Ktor ---------------------- In _part 1_ I outlined how to deploy an AppEngine app by deploying a **.jar** file. Since then Google has listened to mobile devs needing to build server side solutions and has launched [Kotlin on Google Cloud Platform](https://cloud.google.com/kotlin/). [**Deploy A Backend App As An Android Engineer** _With the Skills You Already Have_hackernoon.com](https://hackernoon.com/deploy-a-backend-app-as-an-android-engineer-49bd94b4c367 "https://hackernoon.com/deploy-a-backend-app-as-an-android-engineer-49bd94b4c367")[](https://hackernoon.com/deploy-a-backend-app-as-an-android-engineer-49bd94b4c367) One of the highlighted solutions is Ktor, which allows a standalone backend app in Kotlin that can interact with other libraries just as one would on the client side. The great thing about Ktor is [obscure library compatibility issues like this one](https://stackoverflow.com/questions/52881622/guava-breaking-kotlin-jar-how-to-handle-versioning) with Guava, which is still a mystery, are less of an issue because the code runs similar to how it would on an IDE in that you can define the main method of the app and let it run. The Google Cloud Platform documentation has room for improvement. I went through 2 other configuration tutorials, _Standard_ and _Flexible_ AppEngine setups in order to realize Ktor was what I needed to deploy a Kotlin app to run server tasks without endpoints. Despite Jars being slow to work with I still am using a Jar deploy for some use cases. For instance, authenticating with Firebase is straightforward and reliable with service accounts used in Jars, whereas with ktor there is [this issue](https://stackoverflow.com/questions/52922552/firebase-auth-not-working-with-ktor-app-on-appengine) with authentication that I’ve discovered. **Jars are Janky** * ~10–20 min deploy times. * Must rebuild .jar every time to test new code or different environment types. * Library incompatibility issues. ### **Tutorial:** [**Run a Kotlin Ktor app on Google App Engine Standard**](https://cloud.google.com/community/tutorials/kotlin-ktor-app-engine-java8) This tutorial was quick, clear, and concise. I highly recommend it! One aspect it left out is versioning which is important as I like to have a _staging_ and _production_ version deployed to AppEngine. #### File Notes _build.gradle_ [App Engine Gradle Plugin Tasks and Properties](https://cloud.google.com/appengine/docs/flexible/java/gradle-reference) Find latest version of Ktor to use: [github.com/ktorio/ktor/releases](https://github.com/ktorio/ktor/releases). buildscript { ext.ktor\_version = '_1.0.0_' **...**} Defining AppEngine version: appengine { deploy { version = '1-2-0' }} _ClassWithMainMethod.kt_ In order to run the **main** method from your IDE such as IntelliJ you need to comment out the **Application.main** method and use a main method within an Object IntelliJ can configure from _Run/Debug Configurations._ In order to run with AppEngine and deploy use the **Application.main** method. import io.ktor.application.Application fun Application.main() { // App logic here. } Run with IntelliJ: object Initialization { @JvmStatic fun main(args: Array<String>) { // App logic here. } } [_appengine-web.xml_](https://cloud.google.com/appengine/docs/standard/java/config/appref) sample uses: * [Specify Java 8 runtime](https://cloud.google.com/appengine/docs/standard/java/migrating-to-java8) * Scaling * Resource files using include * SSL enabled (HTTP vs HTTPs) [_web.xml_](https://cloud.google.com/appengine/docs/standard/java/config/webxml): Under _src/main/webapp/WEB-INF/_ sample use: * web.xml: defines mappings between URL paths and the servlets that handle requests with those paths ### [Managing SDK Configurations](https://cloud.google.com/sdk/docs/configurations) Rather than building artifacts in IntelliJ repeatedly the command line can quickly help you create and navigate between AppEngine projects, run your app to test, and deploy to the server. See this [terminal commands guide](https://github.com/AdamSHurwitz/open-dev-guide/blob/master/gcp/gcp.md#terminal-commands) to make use of this. _I’m Adam Hurwitz — hit the clapping hands icon and check out the rest of my_ [_writing_](https://medium.com/@AdamHurwitz) _if you enjoyed the above. Thanks for reading!_  ### Resources **GCP** * [Install the latest Cloud Tools…](https://cloud.google.com/sdk/docs/#install_the_latest_cloud_tools_version_cloudsdk_current_version) * [Quickstart](https://cloud.google.com/tools/intellij/docs/quickstart-IDEA) * [GCP console](https://console.cloud.google.com/cloud-resource-manager) * [AppEngine Pricing](https://cloud.google.com/appengine/pricing) **IntelliJ** * [Configuring your development environment](https://cloud.google.com/appengine/docs/standard/java/building-app/environment-setup#configuring_your_development_environment) * [Creating a new App Engine project](https://cloud.google.com/appengine/docs/standard/java/building-app/environment-setup#creating_a_new_app_engine_project) * [Adding (GCP) Framework Support (to IntelliJ)](https://cloud.google.com/tools/intellij/docs/create-flexible#framework) * [Creating a new (IntelliJ) application (to use with GCP)](https://cloud.google.com/tools/intellij/docs/create-flexible#creating_a_new_application) * [Checking out an existing (IntelliJ) project (to use with GCP)](https://cloud.google.com/tools/intellij/docs/create-flexible#checking_out_an_existing_project) **Kotlin** * [**Run a Kotlin Ktor app on Google App Engine Standard**](https://cloud.google.com/community/tutorials/kotlin-ktor-app-engine-java8) * [App Engine Gradle Plugin Tasks and Properties](https://cloud.google.com/appengine/docs/flexible/java/gradle-reference) * [github.com/ktorio/ktor-samples](http://github.com/ktorio/ktor-samples) * [Logging Console](https://console.cloud.google.com/logs?_ga=2.214847829.-399896800.1533853483) * [ktor](https://ktor.io/) * [Kotlin on Google Cloud Platform](https://cloud.google.com/kotlin/) **Communities** * [Discuss Google Cloud Platform](https://cloud.google.com/support/docs/groups) * [Cloud Connect Community](https://www.cloudconnectcommunity.com/ccc/) * [Google Cloud Platform Support](https://cloud.google.com/support/) * [stackoverflow.com/questions/tagged/google-cloud-kotlin](https://stackoverflow.com/questions/tagged/google-cloud-kotlin) * [Cloud Kotlin Google Group](https://groups.google.com/forum/#!forum/cloud-kotlin) * [github.com/GoogleCloudPlatform/kotlin-samples](https://github.com/GoogleCloudPlatform/kotlin-samples) * [github.com/GoogleApis](https://github.com/googleapis) * [github.com/google-cloud-java](https://github.com/googleapis/google-cloud-java) * [github.com/GoogleCloudPlatform](https://github.com/GoogleCloudPlatform) * [github.com/app-gradle-plugin](https://github.com/GoogleCloudPlatform/app-gradle-plugin)