gogradle icon indicating copy to clipboard operation
gogradle copied to clipboard

Local subproject dependency

Open fiftoine opened this issue 6 years ago • 1 comments

Hi,

Here is the situation I'd like :

  • project
    • subProjectA
    • subProjectB

subProjectA is a golang project and must be compiled into a docker image (until here no problem) subProjectB is a grpc/protobuf project that generates .pb.go files (generation is fine).

Is it then possible to reference the .pb.go files generated in subProjectB into subProjectA?

Something like the build.gradle file of subProjectA :

...
dependencies{
    golang{
        build ...
        // How to translate this line into something gogradle plugin can handle?
        compile project(':subProjectB')
    }
}
...

Thanks in advance

fiftoine avatar Aug 29 '18 09:08 fiftoine

If I understand you correctly, you want to generate something in subprojectB and use the generated go code in subprojectA, right?

If this is the case, currently you have to do this manually, like:

task copyGeneratedGoCodeToVendor(type: Copy) {
      dependsOn('vendor')
      // ... do the copy work here
}

rootProject.projectA.build.dependsOn(copyGeneratedGoCodeToVendor)

There's no equivalent of project() in gogradle plugin, since project() is a pure Java conception - when you declare a project('A') you are actually declaring some dependency on A.jar.

Please let me know if I didn't make myself clear.

blindpirate avatar Aug 29 '18 09:08 blindpirate