简体   繁体   English

由IntelliJ在另一个模块中看不到由gradle生成的ProtoBuffer类

[英]ProtoBuffer generated classes by gradle are not visible in another module by IntelliJ

Hi I have one Gradle module which generates Protocol Buffer's classes according .proto files and packs it as .jar and another module which imports that jar. 嗨我有一个Gradle模块,根据.proto文件生成协议缓冲区的类,并将其打包为.jar和另一个导入该jar的模块。 Generated classes are present in jar but IntelliJ does not see them. 生成的类存在于jar中,但IntelliJ没有看到它们。

Models module with .proto definitions: 带有.proto定义的模型模块:

description = ''

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "com.google.protobuf:protobuf-gradle-plugin:0.7.7"
    }
}

dependencies {
    compile 'com.google.protobuf:protobuf-java:2.6.1'
}

apply plugin: 'java'
apply plugin: "com.google.protobuf"
protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:2.6.1'
    }
}

Controllers module importing models. 控制器模块导入模型。

description = ''

dependencies {
    compile project(':models')
}

The problem is when I try to use generated Models classes in Controllers IntelliJ doesn't see them. 问题是当我尝试在控制器中使用生成的Models类时,IntelliJ看不到它们。

Solution I found: 解决方案我发现:

Adding to the build following lines: 添加到以下行的构建:

sourceSets {
    main {
        java {
            srcDirs = ["src/main/java", "${protobuf.generatedFilesBaseDir}/main/java"]
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM