Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | plugins { |
Jiayu Liu | 6c002b6 | 2022-05-07 00:40:03 +0800 | [diff] [blame] | 21 | kotlin("jvm") |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 22 | java |
| 23 | application |
Jiayu Liu | 5b15838 | 2022-05-12 00:20:37 +0800 | [diff] [blame] | 24 | id("com.ncorti.ktfmt.gradle") |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 25 | } |
| 26 | |
dependabot[bot] | 5501e8f | 2025-09-05 16:37:40 -0400 | [diff] [blame] | 27 | repositories { mavenCentral() } |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 28 | |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 29 | val slf4jVersion: String by project |
| 30 | val httpclientVersion: String by project |
| 31 | val httpcoreVersion: String by project |
| 32 | val logbackVersion: String by project |
| 33 | val kotlinxCoroutinesJdk8Version: String by project |
Jiayu Liu | 5fdfd0c | 2022-05-09 10:52:26 +0800 | [diff] [blame] | 34 | val cliktVersion: String by project |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 35 | |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 36 | dependencies { |
| 37 | implementation(platform("org.jetbrains.kotlin:kotlin-bom")) |
| 38 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") |
Jiayu Liu | 5fdfd0c | 2022-05-09 10:52:26 +0800 | [diff] [blame] | 39 | // clikt is used to drive command line parsing and validation |
| 40 | implementation("com.github.ajalt.clikt:clikt:$cliktVersion") |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 41 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxCoroutinesJdk8Version") |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 42 | implementation("org.apache.thrift:libthrift:INCLUDED") |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 43 | implementation("org.slf4j:slf4j-api:$slf4jVersion") |
| 44 | implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") |
| 45 | implementation("org.apache.httpcomponents:httpcore:$httpcoreVersion") |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 46 | implementation("ch.qos.logback:logback-classic:$logbackVersion") |
| 47 | testImplementation("org.jetbrains.kotlin:kotlin-test") |
| 48 | testImplementation("org.jetbrains.kotlin:kotlin-test-junit") |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 49 | } |
| 50 | |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 51 | tasks { |
| 52 | application { |
| 53 | applicationName = "TestClient" |
| 54 | mainClass.set("org.apache.thrift.test.TestClientKt") |
| 55 | } |
| 56 | |
Jiayu Liu | 5b15838 | 2022-05-12 00:20:37 +0800 | [diff] [blame] | 57 | if (JavaVersion.current().isJava11Compatible) { |
dependabot[bot] | 5501e8f | 2025-09-05 16:37:40 -0400 | [diff] [blame] | 58 | ktfmt { kotlinLangStyle() } |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | task<Exec>("compileThrift") { |
dependabot[bot] | 5501e8f | 2025-09-05 16:37:40 -0400 | [diff] [blame] | 62 | val thriftBin = |
| 63 | if (hasProperty("thrift.compiler")) { |
| 64 | file(property("thrift.compiler")!!) |
| 65 | } else { |
| 66 | project.rootDir.resolve("../../compiler/cpp/thrift") |
| 67 | } |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 68 | val outputDir = layout.buildDirectory.dir("generated-sources") |
dependabot[bot] | 5501e8f | 2025-09-05 16:37:40 -0400 | [diff] [blame] | 69 | doFirst { mkdir(outputDir) } |
| 70 | commandLine = |
| 71 | listOf( |
| 72 | thriftBin.absolutePath, |
| 73 | "-gen", |
| 74 | "kotlin", |
| 75 | "-out", |
| 76 | outputDir.get().toString(), |
| 77 | project.rootDir.resolve("../../test/ThriftTest.thrift").absolutePath, |
| 78 | ) |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 79 | group = LifecycleBasePlugin.BUILD_GROUP |
| 80 | } |
| 81 | |
dependabot[bot] | 5501e8f | 2025-09-05 16:37:40 -0400 | [diff] [blame] | 82 | compileKotlin { dependsOn("compileThrift") } |
Jiayu Liu | 49b2d6b | 2022-04-06 16:49:09 +0800 | [diff] [blame] | 83 | } |
| 84 | |
dependabot[bot] | 5501e8f | 2025-09-05 16:37:40 -0400 | [diff] [blame] | 85 | sourceSets["main"].java { srcDir(layout.buildDirectory.dir("generated-sources")) } |