Search in sources :

Example 6 with ProtoFile

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());
    }
}
Also used : ProtoFile(com.google.startupos.tools.build_file_generator.Protos.ProtoFile)

Aggregations

ProtoFile (com.google.startupos.tools.build_file_generator.Protos.ProtoFile)6 BuildFile (com.google.startupos.tools.build_file_generator.Protos.BuildFile)3 HttpArchiveDepsList (com.google.startupos.tools.build_file_generator.Protos.HttpArchiveDepsList)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ImmutableList (com.google.common.collect.ImmutableList)1 GitRepo (com.google.startupos.common.repo.GitRepo)1 JavaBinary (com.google.startupos.tools.build_file_generator.Protos.BuildFile.JavaBinary)1 JavaLibrary (com.google.startupos.tools.build_file_generator.Protos.BuildFile.JavaLibrary)1 JavaProtoLibrary (com.google.startupos.tools.build_file_generator.Protos.BuildFile.JavaProtoLibrary)1 JavaTest (com.google.startupos.tools.build_file_generator.Protos.BuildFile.JavaTest)1 LoadExtensionStatement (com.google.startupos.tools.build_file_generator.Protos.BuildFile.LoadExtensionStatement)1 ProtoLibrary (com.google.startupos.tools.build_file_generator.Protos.BuildFile.ProtoLibrary)1 HttpArchiveDeps (com.google.startupos.tools.build_file_generator.Protos.HttpArchiveDeps)1 JavaClass (com.google.startupos.tools.build_file_generator.Protos.JavaClass)1 ThirdPartyDep (com.google.startupos.tools.build_file_generator.Protos.ThirdPartyDep)1 WorkspaceFile (com.google.startupos.tools.build_file_generator.Protos.WorkspaceFile)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.junit.Test)1