Protobuf subproject dependency not working

I’m trying to include a gradle project that builds from protobuf files in another project. The project build.gradle looks like this:

apply plugin: 'java'
apply plugin: 'com.google.protobuf'

sourceCompatibility = 1.8

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

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    // https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
    compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.5.0'
}

And it works as I would expect, when I build I get a working .jar in the build/libs folder.

When I now declare that project as a compile dependency like this:
compile project(":protobuf")

In the setting.gradle I have the following lines:

include ':protobuf'
project(":protobuf").projectDir = "$rootDir/../protobuf" as File

I can’t use any of the classes the protoc compiler generated for me. Has anyone had this problem before or any idea what I’m doing wrong?

1 Like

So the problem here isn’t actually gradle its my IDE intellj IDEA that dosen’t understand where to find the dependencys and says its unknown, but acutally everything compiles and works.