我使用Thrift,它会在build目录下生成一些源Java文件(接口)(build/generated-sources/thrift/<package name>/<class>)
,但是在我的src/main/java
中,我有与生成的Java文件相同包定义的类,我的类也实现了Thrift生成的接口。那么我该如何在我的build.gradle中配置,以便在IntelliJ和构建过程中正常工作?
plugins {
id "org.jruyi.thrift" version "0.3.1"
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: "org.jruyi.thrift"
group 'com.hello'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.thrift', name: 'libthrift', version:'0.9.3'
compile 'com.datastax.cassandra:cassandra-driver-core:3.0.0'
compile 'com.datastax.cassandra:cassandra-driver-mapping:3.0.0'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
compileThrift {
thriftExecutable "/usr/local/hello/bin/thrift"
sourceDir "src/main/thrift"
createGenFolder false
}
task thrift(type: Exec) {
commandLine '/usr/local/hello/bin/thrift'
}
compileJava {
dependsOn 'compileThrift'
sourceSets.main.java { srcDir "$buildDir/generated-sources/thrift" }
- RaGe