Search code examples
javapackagethrift

Thrift include two files with same name?


I have this structure: (namespace is java)

package/common.thrift
common.thrift
fileA.thrift

I want fileA.thrift to include both common.thrift

include ".../package/common.thrift"
include "common.thrift"

struct A {
   1: common.Something something #From first file (no error)
   2: common.SomethingElse else  #This throws error.
}

Thrift only reads content from the file specified first in order. Is there a way for this : common.thrift as common So that i can differentiate them. Or the only solution is to have different file names


Solution

  • Thrift only reads content from the file specified first in order

    Not quite. But Thrift needs a prefix to access things that are included. Because the prefix is the file name, you cannot have two "common" files included without producing ambiguities.

    Consequently, the answer to the question is no, you can't.