blob: 7a0c48b39817eb0877b8fdada97d65036b1bcef7 [file] [log] [blame]
Jiayu Liu49b2d6b2022-04-06 16:49:09 +08001/*
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
20plugins {
Jiayu Liu6c002b62022-05-07 00:40:03 +080021 kotlin("jvm")
22 id("com.ncorti.ktfmt.gradle")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080023 java
24 application
25}
26
27repositories {
28 mavenCentral()
29}
30
Jiayu Liueb62fa82022-05-08 13:01:41 +080031val slf4jVersion: String by project
32val httpcoreVersion: String by project
33val logbackVersion: String by project
34val kotlinxCoroutinesJdk8Version: String by project
Jiayu Liu5fdfd0c2022-05-09 10:52:26 +080035val cliktVersion: String by project
Jiayu Liueb62fa82022-05-08 13:01:41 +080036
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080037dependencies {
38 implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
39 implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
Jiayu Liu5fdfd0c2022-05-09 10:52:26 +080040 // clikt is used to drive command line parsing and validation
41 implementation("com.github.ajalt.clikt:clikt:$cliktVersion")
Jiayu Liueb62fa82022-05-08 13:01:41 +080042 implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxCoroutinesJdk8Version")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080043 implementation("org.apache.thrift:libthrift:INCLUDED")
Jiayu Liueb62fa82022-05-08 13:01:41 +080044 implementation("org.slf4j:slf4j-api:$slf4jVersion")
45 implementation("org.apache.httpcomponents:httpcore:$httpcoreVersion")
Jiayu Liueb62fa82022-05-08 13:01:41 +080046 implementation("ch.qos.logback:logback-classic:$logbackVersion")
47 testImplementation("org.jetbrains.kotlin:kotlin-test")
48 testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080049}
50
51tasks {
52 application {
53 applicationName = "TestServer"
54 mainClass.set("org.apache.thrift.test.TestServerKt")
55 }
56
57 ktfmt {
58 kotlinLangStyle()
59 }
60
61 task<Exec>("compileThrift") {
62 val thriftBin = if (hasProperty("thrift.compiler")) {
63 file(property("thrift.compiler"))
64 } else {
65 project.rootDir.resolve("../../compiler/cpp/thrift")
66 }
67 val outputDir = layout.buildDirectory.dir("generated-sources")
68 doFirst {
69 mkdir(outputDir)
70 }
71 commandLine = listOf(
72 thriftBin.absolutePath,
73 "-gen",
74 "kotlin",
75 "-out",
76 outputDir.get().toString(),
77 project.rootDir.resolve("../../test/ThriftTest.thrift").absolutePath
78 )
79 group = LifecycleBasePlugin.BUILD_GROUP
80 }
81
82 compileKotlin {
83 dependsOn("compileThrift")
84 }
85}
86
87sourceSets["main"].java {
88 srcDir(layout.buildDirectory.dir("generated-sources"))
89}