public static JpsRemoteProto.Message.Request createSetupRequest(
      final Map<String, String> pathVars, List<GlobalLibrary> sdkAndLibs) {
    final JpsRemoteProto.Message.Request.SetupCommand.Builder cmdBuilder =
        JpsRemoteProto.Message.Request.SetupCommand.newBuilder();

    if (!pathVars.isEmpty()) {
      for (Map.Entry<String, String> entry : pathVars.entrySet()) {
        final String var = entry.getKey();
        final String value = entry.getValue();
        if (var != null && value != null) {
          final JpsRemoteProto.Message.Request.SetupCommand.PathVariable.Builder pathVarBuilder =
              JpsRemoteProto.Message.Request.SetupCommand.PathVariable.newBuilder();
          cmdBuilder.addPathVariable(pathVarBuilder.setName(var).setValue(value).build());
        }
      }
    }

    if (!sdkAndLibs.isEmpty()) {
      for (GlobalLibrary lib : sdkAndLibs) {
        final JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary.Builder libBuilder =
            JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary.newBuilder();
        libBuilder.setName(lib.getName()).addAllPath(lib.getPaths());
        if (lib instanceof SdkLibrary) {
          libBuilder.setHomePath(((SdkLibrary) lib).getHomePath());
        }
        cmdBuilder.addGlobalLibrary(libBuilder.build());
      }
    }

    return JpsRemoteProto.Message.Request.newBuilder()
        .setRequestType(JpsRemoteProto.Message.Request.Type.SETUP_COMMAND)
        .setSetupCommand(cmdBuilder.build())
        .build();
  }
예제 #2
0
  public static JpsRemoteProto.Message.Request createSetupRequest(
      final Map<String, String> pathVars,
      List<GlobalLibrary> sdkAndLibs,
      @Nullable String globalEncoding,
      String ignoredFilesPatterns) {
    final JpsRemoteProto.Message.Request.SetupCommand.Builder cmdBuilder =
        JpsRemoteProto.Message.Request.SetupCommand.newBuilder();

    if (!pathVars.isEmpty()) {
      for (Map.Entry<String, String> entry : pathVars.entrySet()) {
        final String var = entry.getKey();
        final String value = entry.getValue();
        if (var != null && value != null) {
          cmdBuilder.addPathVariable(createPair(var, value));
        }
      }
    }

    if (!sdkAndLibs.isEmpty()) {
      for (GlobalLibrary lib : sdkAndLibs) {
        final JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary.Builder libBuilder =
            JpsRemoteProto.Message.Request.SetupCommand.GlobalLibrary.newBuilder();
        libBuilder.setName(lib.getName()).addAllPath(lib.getPaths());
        if (lib instanceof SdkLibrary) {
          final SdkLibrary sdk = (SdkLibrary) lib;
          libBuilder.setHomePath(sdk.getHomePath());
          libBuilder.setTypeName(sdk.getTypeName());
          final String additional = sdk.getAdditionalDataXml();
          if (additional != null) {
            libBuilder.setAdditionalDataXml(additional);
          }
        }
        cmdBuilder.addGlobalLibrary(libBuilder.build());
      }
    }

    cmdBuilder.setGlobalEncoding(globalEncoding);
    cmdBuilder.setIgnoredFilesPatterns(ignoredFilesPatterns);

    return JpsRemoteProto.Message.Request.newBuilder()
        .setRequestType(JpsRemoteProto.Message.Request.Type.SETUP_COMMAND)
        .setSetupCommand(cmdBuilder.build())
        .build();
  }