{"action":"closed","issue":{"url":"https://api.github.com/repos/google/protobuf-gradle-plugin/issues/47","labels_url":"https://api.github.com/repos/google/protobuf-gradle-plugin/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/google/protobuf-gradle-plugin/issues/47/comments","events_url":"https://api.github.com/repos/google/protobuf-gradle-plugin/issues/47/events","html_url":"https://github.com/google/protobuf-gradle-plugin/issues/47","id":112211788,"number":47,"title":"Compiler generates invalid Java code when processing packageless proto","user":{"login":"bmat-google","id":14658024,"avatar_url":"https://avatars.githubusercontent.com/u/14658024?v=3","gravatar_id":"","url":"https://api.github.com/users/bmat-google","html_url":"https://github.com/bmat-google","followers_url":"https://api.github.com/users/bmat-google/followers","following_url":"https://api.github.com/users/bmat-google/following{/other_user}","gists_url":"https://api.github.com/users/bmat-google/gists{/gist_id}","starred_url":"https://api.github.com/users/bmat-google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmat-google/subscriptions","organizations_url":"https://api.github.com/users/bmat-google/orgs","repos_url":"https://api.github.com/users/bmat-google/repos","events_url":"https://api.github.com/users/bmat-google/events{/privacy}","received_events_url":"https://api.github.com/users/bmat-google/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-19T19:10:29Z","updated_at":"2015-10-19T21:13:22Z","closed_at":"2015-10-19T21:13:22Z","body":"The following protobufs cause the plugin to generate invalid Java:\r\n\r\nall.proto\r\n```protobuf\r\nsyntax = \"proto3\";\r\n\r\n// This file is meant to be used for convenient importing of frequently used protobufs\r\n// Note that no package is defined\r\n\r\nimport public \"demo/one.proto\";\r\nimport public \"demo/two.proto\";\r\nimport public \"demo/three.proto\";\r\n```\r\n\r\ndemo/one.proto\r\n```protobuf\r\nsyntax = \"proto3\";\r\n\r\npackage demo;\r\n\r\nmessage One {\r\n\tstring one = 1;\r\n}\r\n```\r\n\r\ndemo/two.proto and demo/three.proto follow the same pattern.\r\n\r\ndemo.proto\r\n```protobuf\r\nsyntax = \"proto3\";\r\n\r\npackage demo;\r\n\r\nimport \"all.proto\";\r\n\r\nmessage Numbers {\r\n\tdemo.One one = 1;\r\n\tdemo.Two two = 2;\r\n\tdemo.Three three = 3;\r\n}\r\n```\r\n\r\nBelow is a snippet from the generated file ```Demo.java```:\r\n\r\n```java\r\n// Generated by the protocol buffer compiler.  DO NOT EDIT!\r\n// source: demo.proto\r\n\r\npackage demo;\r\n\r\npublic final class Demo {\r\n\r\n  /* omitted */\r\n\r\n  private static com.google.protobuf.Descriptors.FileDescriptor descriptor;\r\n\r\n  static {\r\n    java.lang.String[] descriptorData = { /* omitted */ };\r\n    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = /* omitted */;\r\n    com.google.protobuf.Descriptors.FileDescriptor\r\n      .internalBuildGeneratedFileFrom(descriptorData,\r\n        new com.google.protobuf.Descriptors.FileDescriptor[] {\r\n          .All.getDescriptor(), // <-- Note the leading dot, which prevents compilation\r\n        }, assigner);\r\n    /* omitted */\r\n  }\r\n\r\n  // @@protoc_insertion_point(outer_class_scope)\r\n}\r\n```\r\n\r\nThe plugin adds an extra dot before \"All\", resulting in invalid Java. The workaround is to specify a package in ```all.proto```."}}