use of com.google.startupos.tools.build_file_generator.Protos.ProtoFile in project startup-os by google.
the class BuildFileGenerator method getInternalProjectDep.
private String getInternalProjectDep(Import importProto, List<ProtoFile> protoFiles, String packageToCreateBuildFile) {
final String projectPackageSuffix = buildFileGeneratorUtils.getProjectPackageSuffix(projectName, importProto.getPackage());
String path = "//" + removeProjectPackageSuffix(importProto.getPackage(), projectPackageSuffix).replace(".", "/");
for (ProtoFile protoFile : protoFiles) {
for (String service : protoFile.getServicesList()) {
if ((service + "Grpc").equals(importProto.getRootClass())) {
String javaGrpcName = ":" + protoFile.getFileName() + "_java_grpc";
if (importProto.getPackage().equals(packageToCreateBuildFile)) {
return javaGrpcName;
} else {
return "//" + removeProjectPackageSuffix(protoFile.getPackage(), projectPackageSuffix).replace(".", "/") + javaGrpcName;
}
}
}
String javaProtoName = ":" + protoFile.getFileName() + "_java_proto";
if ((importProto.getPackage().equals(protoFile.getJavaPackage()) && importProto.getRootClass().equals(protoFile.getJavaOuterClassname()))) {
if (importProto.getPackage().equals(packageToCreateBuildFile)) {
return javaProtoName;
} else {
return "//" + removeProjectPackageSuffix(protoFile.getPackage(), projectPackageSuffix).replace(".", "/") + javaProtoName;
}
}
}
if (importProto.getRootClass().isEmpty()) {
return path + ":" + convertUpperCamelToLowerUnderscore(importProto.getClassName());
} else {
return path + ":" + convertUpperCamelToLowerUnderscore(importProto.getRootClass());
}
}
Aggregations