Server-Side Kotlin with Ktor · Deploy to Heroku |

This is a companion discussion topic for the original entry at

in my case my application is inside the emojiphrasesExample folder and in heroku as emojiphrases-ramat, what should my Procfile file look like?

@macsimus Can you please help with this when you get a chance? Thank you - much appreciated! :]


I’ve got a problem deploying emojiphrases to Heroku. I’m getting the following error:

remote:        FAILURE: Build failed with an exception.
remote:        * Where:
remote:        Build file '/tmp/build_62a5ecce091c4ad342e27301ab79959b/build.gradle' line: 11
remote:        * What went wrong:
remote:        A problem occurred evaluating root project 'emojiphrases'.
remote:        > Current version of Gradle Gradle 2.0 is not compatible with Kotlin plugin. Please use Gradle Gradle 4.1 or newer or previous version of Kotlin plugin.
remote:        * Try:
remote:        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
remote:        BUILD FAILED
remote:        Total time: 24.911 secs
remote:  !     ERROR: Failed to run Gradle!
remote:        We're sorry this build is failing. If you can't find the issue in application
remote:        code, please submit a ticket so we can help:
remote:        You can also try reverting to the previous version of the buildpack by running
remote:        $ heroku buildpacks:set
remote:        Thanks,
remote:        Heroku
remote:  !     Push rejected, failed to compile Gradle app.
remote:  !     Push failed
remote: Verifying deploy...
remote: !	Push rejected to emojiphrases-rafa.

My build.gradle looks like:

buildscript {
    repositories {
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

apply plugin: 'kotlin'
apply plugin: 'application'

group 'com.rafag'
version '0.0.1'
mainClassName = "io.ktor.server.netty.EngineMain"

sourceSets {
    main.kotlin.srcDirs = = ['src']
    test.kotlin.srcDirs = = ['test']
    main.resources.srcDirs = ['resources']
    test.resources.srcDirs = ['testresources']

repositories {

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    compile "io.ktor:ktor-server-netty:$ktor_version"
    compile "io.ktor:ktor-gson:$ktor_version"
    compile "ch.qos.logback:logback-classic:$logback_version"
    compile "io.ktor:ktor-freemarker:$ktor_version"
    compile "io.ktor:ktor-auth:$ktor_version"
    compile "io.ktor:ktor-locations:$ktor_version"
    compile "io.ktor:ktor-auth-jwt:$ktor_version"
    compile "$exposed_version"
    compile "com.h2database:h2:$h2_version"
    compile "com.zaxxer:HikariCP:$hikaricp_version"
    compile "org.postgresql:postgresql:$postgres_version"
    testCompile "io.ktor:ktor-server-tests:$ktor_version"

task stage(dependsOn: ['installDist'])

The problem seems to be the Gradle version. However, when I run ./gradlew --version in the terminal I get:

Gradle 4.10

Build time:   2018-08-27 18:35:06 UTC
Revision:     ee3751ed9f2034effc1f0072c2b2ee74b5dce67d

Kotlin DSL:   1.0-rc-3
Kotlin:       1.2.60
Groovy:       2.4.15
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_144 (Oracle Corporation 25.144-b01)
OS:           Mac OS X 10.14.6 x86_64

It looks like the gradle wrapper is not being used remotely :thinking:

FIXED IT: Leaving for the record in case anyone runs into a similar problem. For some reason git was ignoring the gradle wrapper files, meaning Heroku couldn’t find them and thus it would download gradle 2.0 automatically. Forcing git to add the needed files did the job :dancer:

@rafag7 Thank you for sharing your solution - much appreciated! :]

./build/install/emojiphrases/bin/emojiphrases doesnt exist for me? Im on windows and the main directory of the project only has .gradle, .idea, build, resources, gradle and src dirs?

ERROR: Failed to run Gradle!
remote: It looks like your project does not contain a ‘stage’ task, , which Heroku needs in order to build your app. Our Dev Center article on preparing a Gradle application for Heroku
describes how to create this task:

can anyone tell me what i put in the procfile? im going to ./build/libs/example-0.0.1.jar at present. doesnt seem to be able to find this file. there is no file at this location ./build/libs/emoji_phrases/bin/example

Thanks for the questions @eoin_a! Are you using the Windows Subsystem for Linux? If not, that may be your best bet for getting this Ktor app running on Windows.