blob: 842c1b9dd1b3844ca7d50e9e576c2ba50d7e5c18 [file] [log] [blame]
Jiayu Liu6c002b62022-05-07 00:40:03 +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 {
21 kotlin("jvm")
22 id("com.ncorti.ktfmt.gradle")
23}
24
25repositories {
26 mavenCentral()
27}
28
29dependencies {
30 implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
31 implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
Jiayu Liu6c002b62022-05-07 00:40:03 +080032 implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.1")
Jiayu Liu6c002b62022-05-07 00:40:03 +080033 implementation("org.apache.thrift:libthrift:INCLUDED")
34 testImplementation(kotlin("test"))
35}
36
37tasks {
38 ktfmt {
39 kotlinLangStyle()
40 }
41
42 test {
43 useJUnitPlatform()
44 }
45
46 task<Exec>("compileThrift") {
47 val thriftBin = if (hasProperty("thrift.compiler")) {
48 file(property("thrift.compiler"))
49 } else {
50 project.rootDir.resolve("../../compiler/cpp/thrift")
51 }
52 val outputDir = layout.buildDirectory.dir("generated-sources")
53 doFirst {
54 mkdir(outputDir)
55 }
56 commandLine = listOf(
57 thriftBin.absolutePath,
58 "-gen",
59 "kotlin",
60 "-out",
61 outputDir.get().toString(),
62 layout.projectDirectory.file("src/test/resources/AnnotationTest.thrift").asFile.absolutePath
63 )
64 group = LifecycleBasePlugin.BUILD_GROUP
65 }
66
67 compileKotlin {
68 dependsOn("compileThrift")
69 }
70}
71
72sourceSets["main"].java {
73 srcDir(layout.buildDirectory.dir("generated-sources"))
74}