From 2da706d010d6df9fb7d10b1435cda002520665ba Mon Sep 17 00:00:00 2001 From: Vladimir Sitnikov Date: Mon, 15 Feb 2021 01:01:54 +0300 Subject: [PATCH] Use Kotlin DSL in appengine/ktor sample, bump versions --- appengine/ktor/build.gradle | 51 ----------------------------- appengine/ktor/build.gradle.kts | 52 ++++++++++++++++++++++++++++++ appengine/ktor/gradle.properties | 4 +++ appengine/ktor/settings.gradle.kts | 15 +++++++++ 4 files changed, 71 insertions(+), 51 deletions(-) delete mode 100644 appengine/ktor/build.gradle create mode 100644 appengine/ktor/build.gradle.kts create mode 100644 appengine/ktor/gradle.properties create mode 100644 appengine/ktor/settings.gradle.kts diff --git a/appengine/ktor/build.gradle b/appengine/ktor/build.gradle deleted file mode 100644 index 7c7dbf91..00000000 --- a/appengine/ktor/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -buildscript { - ext.kotlin_version = '1.3.70' - ext.ktor_version = '1.3.2' - ext.appengine_version = '1.9.60' - ext.appengine_plugin_version = '2.1.0' - ext.gce_logback_version = '0.117.0-alpha' - - repositories { - mavenCentral() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "com.google.cloud.tools:appengine-gradle-plugin:$appengine_plugin_version" - } -} - -apply plugin: 'java' -apply plugin: 'kotlin' -apply plugin: 'war' -apply plugin: 'com.google.cloud.tools.appengine' - -appengine.deploy.projectId = 'GCLOUD_CONFIG' -appengine.deploy.version = 'GCLOUD_CONFIG' - -sourceSets { - main.kotlin.srcDirs = [ 'src/main/kotlin' ] -} - -compileKotlin { - kotlinOptions.jvmTarget = "1.8" -} -compileTestKotlin { - kotlinOptions.jvmTarget = "1.8" -} - -repositories { - jcenter() -} - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - compile "io.ktor:ktor-server-servlet:$ktor_version" - compile "io.ktor:ktor-html-builder:$ktor_version" - compile "com.google.cloud:google-cloud-logging-logback:$gce_logback_version" - - providedCompile "com.google.appengine:appengine:$appengine_version" -} - -kotlin.experimental.coroutines = 'enable' - -task run(dependsOn: appengineRun) diff --git a/appengine/ktor/build.gradle.kts b/appengine/ktor/build.gradle.kts new file mode 100644 index 00000000..b5eda4ca --- /dev/null +++ b/appengine/ktor/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + kotlin("jvm") version "1.4.20" + war + id("com.google.cloud.tools.appengine") version "2.4.1" +} + +repositories { + mavenCentral() + // kotlinx-html-jvm is not available in mavenCentral yet + // See https://github.com/Kotlin/kotlinx.html/issues/173 + jcenter { + content { + includeModule("org.jetbrains.kotlinx", "kotlinx-html-jvm") + } + } +} + +require (JavaVersion.current() <= JavaVersion.VERSION_11) { + "AppEngine supports only Java 8 or 11 for now, the current Java is ${JavaVersion.current()}" +} + +dependencies { + implementation(platform("io.ktor:ktor-bom:1.5.1")) + implementation("io.ktor:ktor-server-servlet") + implementation("io.ktor:ktor-html-builder") + implementation("com.google.cloud:google-cloud-logging-logback:0.117.0-alpha") + + runtimeOnly("com.google.appengine:appengine:1.9.86") +} + +appengine { + deploy { + projectId = "GCLOUD_CONFIG" + version = "GCLOUD_CONFIG" + } +} + +tasks { + withType().configureEach { + options.encoding = "UTF-8" + } + + withType().configureEach { + kotlinOptions { + jvmTarget = "1.8" + } + } + + register("run") { + dependsOn("appengineRun") + } +} diff --git a/appengine/ktor/gradle.properties b/appengine/ktor/gradle.properties new file mode 100644 index 00000000..a226e035 --- /dev/null +++ b/appengine/ktor/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.parallel=true + +kotlin.code.style=official +kotlin.parallel.tasks.in.project=true diff --git a/appengine/ktor/settings.gradle.kts b/appengine/ktor/settings.gradle.kts new file mode 100644 index 00000000..200370b2 --- /dev/null +++ b/appengine/ktor/settings.gradle.kts @@ -0,0 +1,15 @@ +pluginManagement { + // resolutionStrategy enables using plugins { id("com.google.cloud.tools.appengine") } syntax + // It won't be needed when the plugin publishes + // com.google.cloud.tools.appengine:com.google.cloud.tools.appengine.gradle.plugin + // artifact to Sonatype OSSRH + resolutionStrategy { + eachPlugin { + if (requested.id.id == "com.google.cloud.tools.appengine") { + useModule("com.google.cloud.tools:appengine-gradle-plugin:${requested.version}") + } + } + } +} + +rootProject.name = "appengine-ktor"