Hello everyone, I got problems with deploy my Ktor...
# ktor
h
Hello everyone, I got problems with deploy my Ktor application to Google App Engine. I followed this tutorial, which is from Google Cloud Community, I stuck with gradle setting. It showed “Could not get unknown property ‘appengineRun’ for root project” at last line of the gradle. Here is my gradle
Copy code
buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.cloud.tools:appengine-gradle-plugin:$appengine_plugin_version"
    }
}

apply plugin: 'kotlin'
apply plugin: 'war'
apply plugin: 'application'
apply plugin: 'com.google.cloud.tools.appengine'

appengine.deploy.projectId = 'GCLOUD_CONFIG'
appengine.deploy.version = 'GCLOUD_CONFIG'

group 'dev.hankli'
version '1.0.0'
mainClassName = "io.ktor.server.netty.EngineMain"

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

webAppDirName = 'webapp'

repositories {
    mavenLocal()
    jcenter()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "io.ktor:ktor-server-netty:$ktor_version"
    implementation "ch.qos.logback:logback-classic:$logback_version"
    implementation "io.ktor:ktor-server-core:$ktor_version"
    implementation "io.ktor:ktor-locations:$ktor_version"
    implementation "io.ktor:ktor-server-sessions:$ktor_version"
    implementation "io.ktor:ktor-auth:$ktor_version"
    implementation "io.ktor:ktor-auth-jwt:$ktor_version"
    implementation "io.ktor:ktor-gson:$ktor_version"
    implementation 'com.google.firebase:firebase-admin:6.14.0'
    implementation "com.desmondtzq.ktor:ktor-auth-firebase:1.0.1"
    testImplementation "io.ktor:ktor-server-tests:$ktor_version"

    implementation "org.jetbrains.exposed:exposed-core:$exposed_version"
    implementation "org.jetbrains.exposed:exposed-dao:$exposed_version"
    implementation "org.jetbrains.exposed:exposed-jdbc:$exposed_version"
    implementation "org.jetbrains.exposed:exposed-jodatime:$exposed_version"
    implementation "org.postgresql:postgresql:$postgres_version"
    implementation "com.zaxxer:HikariCP:$hikaricp_version"

    providedCompile "com.google.appengine:appengine:$appengine_version"
}

task run(dependsOn: appengineRun) // Could not get unknown property 'appengineRun' for root project
And I’ve tried to use the Cloud Code plugin in IntelliJ IDE to run my code and there was an error that showed “Please first confirm that there is a properly placed appengine-web.xml file”, even though I’ve set the directions. Is anyone can help me out or give me some suggestions, really appreciate.🙏
j
Hey Chun-Yi, I think I faced the same problem but it was a long time ago. Could you try commenting out these two:
Copy code
appengine.deploy.projectId = 'GCLOUD_CONFIG'
appengine.deploy.version = 'GCLOUD_CONFIG'
You are now going to setup the configuration for appengine differently as documented on https://cloud.google.com/appengine/docs/standard/java/tools/gradle-reference So now replace:
Copy code
task run(dependsOn: appengineRun)
with this piece of code at the bottom of your build.gradle:
appengine {  // App Engine tasks configuration
deploy {   // deploy configuration
version = "GCLOUD_CONFIG"
projectId = "GCLOUD_CONFIG"
stopPreviousVersion = true  // default - stop the current version
promote = true              // default - & make this the current version
}
}
Cheers 🙂 Let me know if it works for you.
m
https://medium.com/@marctatham/a-ktor-api-on-google-app-engines-java-11-standard-environment-bbc5f4be56d1 Don't know if that's what you are looking for, but it worked on the spot for me!!!
h
Thank you both. I’ll check them out.