blob: e5f87dd69d8180973d9cff7551c5c606eb722aa0 [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
31dependencies {
32 implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
33 implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
34 // https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-jdk8
35 implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.1")
36 // https://mvnrepository.com/artifact/org.apache.thrift/libthrift
37 implementation("org.apache.thrift:libthrift:INCLUDED")
38 // https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
39 implementation("ch.qos.logback:logback-classic:1.3.0-alpha14")
Jiayu Liu49b2d6b2022-04-06 16:49:09 +080040}
41
42tasks {
43 application {
44 applicationName = "TestClient"
45 mainClass.set("org.apache.thrift.test.TestClientKt")
46 }
47
48 ktfmt {
49 kotlinLangStyle()
50 }
51
52 task<Exec>("compileThrift") {
53 val thriftBin = if (hasProperty("thrift.compiler")) {
54 file(property("thrift.compiler"))
55 } else {
56 project.rootDir.resolve("../../compiler/cpp/thrift")
57 }
58 val outputDir = layout.buildDirectory.dir("generated-sources")
59 doFirst {
60 mkdir(outputDir)
61 }
62 commandLine = listOf(
63 thriftBin.absolutePath,
64 "-gen",
65 "kotlin",
66 "-out",
67 outputDir.get().toString(),
68 project.rootDir.resolve("../../test/ThriftTest.thrift").absolutePath
69 )
70 group = LifecycleBasePlugin.BUILD_GROUP
71 }
72
73 compileKotlin {
74 dependsOn("compileThrift")
75 }
76}
77
78sourceSets["main"].java {
79 srcDir(layout.buildDirectory.dir("generated-sources"))
80}