|
| 1 | +// This module builds and publishes 'armeria-thrift0.23', which is compiled with |
| 2 | +// the source code of ':thrift0.13', ':thrift0.14.0', ':thrift0.21.0'. |
| 3 | + |
| 4 | +dependencies { |
| 5 | + api libs.thrift023 |
| 6 | + |
| 7 | + api libs.javax.annotation |
| 8 | + |
| 9 | + testImplementation project(':prometheus1') |
| 10 | + |
| 11 | + // thrift api depends on httpclient5 |
| 12 | + testImplementation libs.apache.httpclient5 |
| 13 | + |
| 14 | + // Jetty, for testing TServlet interoperability. |
| 15 | + testImplementation libs.jetty11.webapp |
| 16 | + testImplementation libs.jetty11.http2.server |
| 17 | + |
| 18 | + // Dropwizard and Prometheus, for testing metrics integration |
| 19 | + testImplementation libs.dropwizard.metrics.core |
| 20 | + testImplementation libs.prometheus.metrics.exposition.formats |
| 21 | + |
| 22 | + // micrometer tracing |
| 23 | + testImplementation (libs.micrometer.tracing.integration.test) { |
| 24 | + exclude group: "org.mockito" |
| 25 | + } |
| 26 | + testImplementation libs.brave6.instrumentation.http.tests |
| 27 | + testImplementation libs.logback14 |
| 28 | +} |
| 29 | + |
| 30 | +// Use the sources from ':thrift0.13', ':thrift0.14', and ':thrift0.21'. |
| 31 | +// Some modules are empty so no need to copy anything. |
| 32 | +// NB: We should never add these directories using the 'sourceSets' directive because that will make |
| 33 | +// them added to more than one project and having a source directory with more than one output directory |
| 34 | +// will confuse IDEs such as IntelliJ IDEA. |
| 35 | +def thrift013ProjectDir = "${rootProject.projectDir}/thrift/thrift0.13" |
| 36 | +def thrift014ProjectDir = "${rootProject.projectDir}/thrift/thrift0.14" |
| 37 | +def thrift017ProjectDir = "${rootProject.projectDir}/thrift/thrift0.17" |
| 38 | +def thrift018ProjectDir = "${rootProject.projectDir}/thrift/thrift0.18" |
| 39 | +def thrift019ProjectDir = "${rootProject.projectDir}/thrift/thrift0.19" |
| 40 | +def thrift021ProjectDir = "${rootProject.projectDir}/thrift/thrift0.21" |
| 41 | + |
| 42 | +// Copy common files from ':thrift0.13', ':thrift0.14', and ':thrift0.21' to gen-src directory |
| 43 | +// in order to use them as a source set. |
| 44 | +task generateSources(type: Copy) { |
| 45 | + from("${thrift013ProjectDir}/src/main/java") { |
| 46 | + exclude '**/TByteBufTransport.java' |
| 47 | + exclude '**/ThriftCallService.java' |
| 48 | + exclude '**/ThriftFunction.java' |
| 49 | + exclude '**/ThriftServiceMetadata.java' |
| 50 | + exclude '**/MaskingTProtocol.java' |
| 51 | + exclude '**/UnMaskingTProtocol.java' |
| 52 | + exclude '**/common/thrift/package-info.java' |
| 53 | + exclude '**/server/thrift/package-info.java' |
| 54 | + exclude '**/common/thrift/logging/package-info.java' |
| 55 | + exclude '**/ThriftFieldMaskerSelector.java' |
| 56 | + } |
| 57 | + from("${thrift014ProjectDir}/src/main/java") { |
| 58 | + exclude '**/TByteBufTransport.java' |
| 59 | + exclude '**/internal/common/thrift/package-info.java' |
| 60 | + } |
| 61 | + from "${thrift018ProjectDir}/src/main/java" |
| 62 | + from "${thrift019ProjectDir}/src/main/java" |
| 63 | + from("${thrift021ProjectDir}/src/main/java") { |
| 64 | + exclude '**/internal/common/thrift/package-info.java' |
| 65 | + } |
| 66 | + into "${project.ext.genSrcDir}/main/java" |
| 67 | +} |
| 68 | + |
| 69 | +task generateTestSources(type: Copy) { |
| 70 | + from("${thrift013ProjectDir}/src/test/java") { |
| 71 | + exclude '**/THttp2Client.java' |
| 72 | + exclude '**/ThriftDocServicePluginTest.java' |
| 73 | + exclude '**/ApacheClientUtils.java' |
| 74 | + exclude '**/ServletTestUtils.java' |
| 75 | + } |
| 76 | + from "${thrift014ProjectDir}/src/test/java" |
| 77 | + from "${thrift017ProjectDir}/src/test/java" |
| 78 | + from "${thrift018ProjectDir}/src/test/java" |
| 79 | + from "${thrift019ProjectDir}/src/test/java" |
| 80 | + into "${project.ext.genSrcDir}/test/java" |
| 81 | +} |
| 82 | + |
| 83 | +def thriftFullVersion = libs.thrift023.get().versionConstraint.requiredVersion |
| 84 | +ext { |
| 85 | + thriftVersion = thriftFullVersion.substring(0, thriftFullVersion.lastIndexOf('.')); |
| 86 | + testThriftSrcDirs = ["$thrift013ProjectDir/src/test/thrift", "$projectDir/src/test/thrift", |
| 87 | + "$thrift018ProjectDir/src/test/thrift"] |
| 88 | + enableAnnotationsAsMetadata() |
| 89 | +} |
| 90 | + |
| 91 | +tasks.generateSources.dependsOn(generateTestSources) |
| 92 | +tasks.compileJava.dependsOn(generateSources) |
| 93 | +tasks.compileTestJava.dependsOn(generateSources) |
| 94 | + |
| 95 | +tasks.processResources.from("${thrift013ProjectDir}/src/main/resources") { |
| 96 | + exclude '**/thrift-options.properties' |
| 97 | +} |
| 98 | +tasks.processTestResources.from "${thrift013ProjectDir}/src/test/resources" |
| 99 | +tasks.sourcesJar.from "${thrift013ProjectDir}/src/main/resources" |
| 100 | + |
| 101 | +// Keep the original Guava references in ThriftListenableFuture, |
| 102 | +// which is the only place we expose Guava classes in our public API. |
| 103 | +// NB: Keep this same with ':thrift0.13'. |
| 104 | +tasks.shadedJar.exclude 'com/linecorp/armeria/common/thrift/ThriftListenableFuture*' |
| 105 | +tasks.shadedJar.doLast { |
| 106 | + ant.jar(update: true, destfile: tasks.shadedJar.archiveFile.get().asFile) { |
| 107 | + sourceSets.main.output.classesDirs.each { classesDir -> |
| 108 | + fileset(dir: "$classesDir", |
| 109 | + includes: 'com/linecorp/armeria/common/thrift/ThriftListenableFuture*') |
| 110 | + } |
| 111 | + } |
| 112 | +} |
0 commit comments