blob: 6e944b0e55fe4ea0ba9dcec3788345940b336773 [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")
32 // https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-jdk8
33 implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.1")
34 // https://mvnrepository.com/artifact/org.apache.thrift/libthrift
35 implementation("org.apache.thrift:libthrift:INCLUDED")
36 testImplementation(kotlin("test"))
37}
38
39tasks {
40 ktfmt {
41 kotlinLangStyle()
42 }
43
44 test {
45 useJUnitPlatform()
46 }
47
48 task<Exec>("compileThrift") {
49 val thriftBin = if (hasProperty("thrift.compiler")) {
50 file(property("thrift.compiler"))
51 } else {
52 project.rootDir.resolve("../../compiler/cpp/thrift")
53 }
54 val outputDir = layout.buildDirectory.dir("generated-sources")
55 doFirst {
56 mkdir(outputDir)
57 }
58 commandLine = listOf(
59 thriftBin.absolutePath,
60 "-gen",
61 "kotlin",
62 "-out",
63 outputDir.get().toString(),
64 layout.projectDirectory.file("src/test/resources/AnnotationTest.thrift").asFile.absolutePath
65 )
66 group = LifecycleBasePlugin.BUILD_GROUP
67 }
68
69 compileKotlin {
70 dependsOn("compileThrift")
71 }
72}
73
74sourceSets["main"].java {
75 srcDir(layout.buildDirectory.dir("generated-sources"))
76}