如何在Gradle和IntelliJ中将生成的源文件夹添加到源路径?
我使用thrift并在构建目录下生成一些源java文件(接口) (build/generated-sources/thrift//)
但在我的src/main/java
我有我的类具有相同的包定义在生成的java文件中,我的类也实现了thrift生成的接口,所以如何在build.gradle中配置它,以便它可以在i ntelliJ和build上工作
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'
gradle构建应该自动运行。 要使其在Intellij上运行,请尝试将以下内容添加到build.gradle中。
idea.module.sourceDirs += file("$buildDir/generated-sources/thrift")
不要忘记刷新您的gradle项目。
- CTRL + C w / Spring Boot&Gradle Kills Gradle Daemon
- 如何为Gradle Java插件设置compileOptions?
- 在Gradle Android Studio中排除一个类文件
- 在Ubuntu上找不到Java Application主类
- 拆分Gradle中的所有输出目录
- Gradle Multiproject Build:如何在不创建伪项目的情况下将WAR项目的JAR包含到另一个WAR中
- 如何读取属性文件并使用项目Gradle脚本中的值?
- Gradle:多个java项目的公共资源依赖项
- 使用spock junit测试和gradle构建系统在控制台上输出unit testing结果