blob: f1970172fa230973a7acdd23a62110a307bb8390 [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")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080022 java
23 application
Jiayu Liu5b158382022-05-12 00:20:37 +080024 id("com.ncorti.ktfmt.gradle")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080025}
26
dependabot[bot]5501e8f2025-09-05 16:37:40 -040027repositories { mavenCentral() }
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080028
Jiayu Liueb62fa82022-05-08 13:01:41 +080029val slf4jVersion: String by project
30val httpcoreVersion: String by project
31val logbackVersion: String by project
32val kotlinxCoroutinesJdk8Version: String by project
Jiayu Liu5fdfd0c2022-05-09 10:52:26 +080033val cliktVersion: String by project
Jiayu Liueb62fa82022-05-08 13:01:41 +080034
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080035dependencies {
36 implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
37 implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
Jiayu Liu5fdfd0c2022-05-09 10:52:26 +080038 // clikt is used to drive command line parsing and validation
39 implementation("com.github.ajalt.clikt:clikt:$cliktVersion")
Jiayu Liueb62fa82022-05-08 13:01:41 +080040 implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxCoroutinesJdk8Version")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080041 implementation("org.apache.thrift:libthrift:INCLUDED")
Jiayu Liueb62fa82022-05-08 13:01:41 +080042 implementation("org.slf4j:slf4j-api:$slf4jVersion")
43 implementation("org.apache.httpcomponents:httpcore:$httpcoreVersion")
Jiayu Liueb62fa82022-05-08 13:01:41 +080044 implementation("ch.qos.logback:logback-classic:$logbackVersion")
45 testImplementation("org.jetbrains.kotlin:kotlin-test")
46 testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080047}
48
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080049tasks {
50 application {
51 applicationName = "TestServer"
52 mainClass.set("org.apache.thrift.test.TestServerKt")
53 }
54
Jiayu Liu5b158382022-05-12 00:20:37 +080055 if (JavaVersion.current().isJava11Compatible) {
dependabot[bot]5501e8f2025-09-05 16:37:40 -040056 ktfmt { kotlinLangStyle() }
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080057 }
58
59 task<Exec>("compileThrift") {
dependabot[bot]5501e8f2025-09-05 16:37:40 -040060 val thriftBin =
61 if (hasProperty("thrift.compiler")) {
62 file(property("thrift.compiler")!!)
63 } else {
64 project.rootDir.resolve("../../compiler/cpp/thrift")
65 }
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080066 val outputDir = layout.buildDirectory.dir("generated-sources")
dependabot[bot]5501e8f2025-09-05 16:37:40 -040067 doFirst { mkdir(outputDir) }
68 commandLine =
69 listOf(
70 thriftBin.absolutePath,
71 "-gen",
72 "kotlin",
73 "-out",
74 outputDir.get().toString(),
75 project.rootDir.resolve("../../test/ThriftTest.thrift").absolutePath,
76 )
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080077 group = LifecycleBasePlugin.BUILD_GROUP
78 }
79
dependabot[bot]5501e8f2025-09-05 16:37:40 -040080 compileKotlin { dependsOn("compileThrift") }
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080081}
82
dependabot[bot]5501e8f2025-09-05 16:37:40 -040083sourceSets["main"].java { srcDir(layout.buildDirectory.dir("generated-sources")) }