Skip to content

:generateProto fails with directory not found when importing other proto definitions  #405

@anandwana001

Description

@anandwana001

Topic Proto file

syntax = "proto3";

package model;

import "src/main/proto/subtitled_html.proto";
import "src/main/proto/thumbnail.proto";
import "src/main/proto/translation.proto";
import "src/main/proto/voiceover.proto";

option java_package = "org.oppia.app.model";
option java_multiple_files = true;

Build Failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':model:generateProto'.
> protoc: stdout: . stderr: src/main/proto/subtitled_html.proto: File not found.
  src/main/proto/thumbnail.proto: File not found.
  src/main/proto/translation.proto: File not found.
  src/main/proto/voiceover.proto: File not found.
  topic.proto: Import "src/main/proto/subtitled_html.proto" was not found or had errors.
  topic.proto: Import "src/main/proto/thumbnail.proto" was not found or had errors.
  topic.proto: Import "src/main/proto/translation.proto" was not found or had errors.
  topic.proto: Import "src/main/proto/voiceover.proto" was not found or had errors.
  topic.proto:31:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto: "model.VoiceoverMapping" seems to be defined in "voiceover.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto: "model.TranslationMapping" seems to be defined in "translation.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:49:3: "model.SubtitledHtml" seems to be defined in "subtitled_html.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:52:12: "model.SubtitledHtml" seems to be defined in "subtitled_html.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:72:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:93:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:109:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:152:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:193:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:226:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:308:3: "model.LessonThumbnail" seems to be defined in "thumbnail.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto: "model.VoiceoverMapping" seems to be defined in "voiceover.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto: "model.TranslationMapping" seems to be defined in "translation.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.
  topic.proto:317:3: "model.SubtitledHtml" seems to be defined in "subtitled_html.proto", which is not imported by "topic.proto".  To use it here, please add the necessary import.

Now if I update this to

syntax = "proto3";

package model;

import "subtitled_html.proto";
import "thumbnail.proto";
import "translation.proto";
import "voiceover.proto";

option java_package = "org.oppia.app.model";
option java_multiple_files = true;

It will not fail, but check lint fails

command - protoc -I . --buf-check-lint_out=. $(find . -name '*.proto')

subtitled_html.proto: File not found.
thumbnail.proto: File not found.
translation.proto: File not found.
voiceover.proto: File not found.
model/build/resources/main/topic.proto:5:1: Import "subtitled_html.proto" was not found or had errors.
model/build/resources/main/topic.proto:6:1: Import "thumbnail.proto" was not found or had errors.
model/build/resources/main/topic.proto:7:1: Import "translation.proto" was not found or had errors.
model/build/resources/main/topic.proto:8:1: Import "voiceover.proto" was not found or had errors.
model/build/resources/main/topic.proto:31:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto: "VoiceoverMapping" is not defined.
model/build/resources/main/topic.proto: "TranslationMapping" is not defined.
model/build/resources/main/topic.proto:49:3: "SubtitledHtml" is not defined.
model/build/resources/main/topic.proto:52:12: "SubtitledHtml" is not defined.
model/build/resources/main/topic.proto:72:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto:93:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto:109:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto:152:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto:193:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto:226:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto:308:3: "LessonThumbnail" is not defined.
model/build/resources/main/topic.proto: "VoiceoverMapping" is not defined.
model/build/resources/main/topic.proto: "TranslationMapping" is not defined.
model/build/resources/main/topic.proto:317:3: "SubtitledHtml" is not defined.

Folders
Screenshot 2020-06-01 at 16 30 46

Gradle file

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

protobuf {
  protoc {
    artifact = 'com.google.protobuf:protoc:3.0.0'
  }
  plugins {
    javalite {
      artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
    }
  }
  generateProtoTasks {
    all().each { task ->
      task.builtins {
        remove java
      }
      task.plugins {
        javalite {}
      }
    }
  }
}

dependencies {
  compile 'com.google.protobuf:protobuf-lite:3.0.0'
}

sourceSets {
  main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/javalite"
  main.java.srcDirs += "$projectDir/src/main/proto"
}

If I try adding --proto_path so that It will know where to look for files:
command - protoc -I=model/src/main/proto -I=model/build/resources/main --buf-check-lint_out=. $(find . -name '*.proto')

Error
./model/build/resources/main/onboarding.proto: Input is shadowed in the --proto_path by "model/src/main/proto/onboarding.proto". Either use the latter file as your input or reorder the --proto_path so that the former file's location comes first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions