1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 <lambda>null20plugins { 21 kotlin("jvm") 22 java 23 application 24 id("com.ncorti.ktfmt.gradle") 25 } 26 <lambda>null27repositories { 28 mavenCentral() 29 } 30 31 val slf4jVersion: String by project 32 val httpcoreVersion: String by project 33 val logbackVersion: String by project 34 val kotlinxCoroutinesJdk8Version: String by project 35 val cliktVersion: String by project 36 <lambda>null37dependencies { 38 implementation(platform("org.jetbrains.kotlin:kotlin-bom")) 39 implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 40 // clikt is used to drive command line parsing and validation 41 implementation("com.github.ajalt.clikt:clikt:$cliktVersion") 42 implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxCoroutinesJdk8Version") 43 implementation("org.apache.thrift:libthrift:INCLUDED") 44 implementation("org.slf4j:slf4j-api:$slf4jVersion") 45 implementation("org.apache.httpcomponents:httpcore:$httpcoreVersion") 46 implementation("ch.qos.logback:logback-classic:$logbackVersion") 47 testImplementation("org.jetbrains.kotlin:kotlin-test") 48 testImplementation("org.jetbrains.kotlin:kotlin-test-junit") 49 } 50 <lambda>null51kotlin { 52 jvmToolchain { 53 (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11)) 54 } 55 } 56 <lambda>null57tasks { 58 application { 59 applicationName = "TestServer" 60 mainClass.set("org.apache.thrift.test.TestServerKt") 61 } 62 63 if (JavaVersion.current().isJava11Compatible) { 64 ktfmt { 65 kotlinLangStyle() 66 } 67 } 68 69 task<Exec>("compileThrift") { 70 val thriftBin = if (hasProperty("thrift.compiler")) { 71 file(property("thrift.compiler")) 72 } else { 73 project.rootDir.resolve("../../compiler/cpp/thrift") 74 } 75 val outputDir = layout.buildDirectory.dir("generated-sources") 76 doFirst { 77 mkdir(outputDir) 78 } 79 commandLine = listOf( 80 thriftBin.absolutePath, 81 "-gen", 82 "kotlin", 83 "-out", 84 outputDir.get().toString(), 85 project.rootDir.resolve("../../test/ThriftTest.thrift").absolutePath 86 ) 87 group = LifecycleBasePlugin.BUILD_GROUP 88 } 89 90 compileKotlin { 91 dependsOn("compileThrift") 92 } 93 } 94 <lambda>null95sourceSets["main"].java { 96 srcDir(layout.buildDirectory.dir("generated-sources")) 97 } 98