google / google/protobuf-gradle-plugin

Java classes are not generated

Open
#782 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
Groovy
Stars
1.8k
Forks
288
PR merge metrics
No merged PRs in 30d

Description

I have `.proto` files inside `proto/` directory of Android project. The proto files are from a git sub module and the sub module under `src/main/proto`. There are some other dirs inside the sub module and imports are used in proto files.
Example of an import from a proto file is like: `import "code/device/protofiles/v1/status.proto";`

I've set the proto srcDirs path to custom path in gradle. and it look like:
`main {
proto {
srcDirs = ['src/main/proto/device/proto']
}
}`

upon setting custom srcDir path it resolves the imports in proto files but Java classes are not getting generated inside `build/generated/source` dir.
When I remove the custom `srcDirs` from gradle and change all imports to
`import "device/proto/code/device/protofiles/v1/status.proto";` instead of `import "code/device/protofiles/v1/status.proto";`
the java classes gets generated.
But I want not to change the imports as these protofiles are inside a submodule and is used in othe projects as well.

Issue: Java classes are not generating from protofiles upon custom srcDirs path for protofiles

Contributor guide

Open the contributing guide

Research direction

Start with the custom Gradle proto.srcDirs configuration and the proto/ layout described in the issue, including the submodule and imported status.proto path. Reproduce generation with the original imports, then inspect the plugin's handling of custom source roots; done means Java classes appear under build/generated/source without changing those imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, groovy
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.