Skip to content

Commit 7cb0a22

Browse files
committed
Merge branch 'master' of https://github.com/sivasankariit/idea-plugin-protobuf into sivasankariit-master
# Conflicts: # src/protobuf/compiler/PbCompiler.java
2 parents 52af39b + d4fa489 commit 7cb0a22

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/protobuf/compiler/PbCompiler.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class PbCompiler implements SourceGeneratingCompiler {
5858
private static final String PROTOC_LINUX = "protoc";
5959
private static final String PROTOC_MAC = "protoc";
6060

61+
private static final String DEFAULT_PROTO_SOURCE_ROOT = "src/main/proto";
6162

6263
private static final Matcher ERROR_IN_LINE_MATCHER = Pattern.compile("[^:]*:[0-9]*:[0-9]*:.*").matcher("");
6364
private static final Matcher ERROR_IN_FILE_MATCHER = Pattern.compile("[^:]*:[^:]*").matcher("");
@@ -150,13 +151,22 @@ public void run(final Result<PsiDirectory> result) {
150151
for (String addtionalProtoPath : getModuleAdditionalProtoPaths(item)) {
151152
compilerCommand.append(" --proto_path=").append(addtionalProtoPath);
152153
}
154+
// Add the default proto source root for the module if the directory exists.
155+
VirtualFile moduleFile = item.getModule().getModuleFile();
156+
if (moduleFile != null) {
157+
VirtualFile protoSourceRoot = moduleFile.getParent().findFileByRelativePath(DEFAULT_PROTO_SOURCE_ROOT);
158+
if ((protoSourceRoot != null) && protoSourceRoot.isDirectory()) {
159+
compilerCommand.append(" --proto_path=").append(protoSourceRoot.getPath());
160+
}
161+
}
162+
153163
if (item.getFacet().getConfiguration().isGenerateNanoProto()) {
154164
compilerCommand.append(" --javanano_out=");
155165
} else {
156166
compilerCommand.append(" --java_out=");
157167
}
158168
compilerCommand.append(outputPath);
159-
compilerCommand.append(" ").append(item.getPath());
169+
compilerCommand.append(" ").append(item.getPath());
160170
LOG.info("Invoking protoc: " + compilerCommand.toString());
161171
proc = Runtime.getRuntime().exec(compilerCommand.toString());
162172
processStreams(compileContext, proc.getInputStream(), proc.getErrorStream(), item);

src/protobuf/settings/facet/ProtobufFacetEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private String toSystemIndependentPaths(String paths) {
8383
for (int i = 0; i < splitPaths.length; i++) {
8484
splitPaths[i] = FileUtil.toSystemIndependentName(splitPaths[i]);
8585
}
86-
return StringUtil.join(splitPaths);
86+
return StringUtil.join(splitPaths, ";");
8787
}
8888

8989
@Override

0 commit comments

Comments
 (0)