public static void runBuild(@NotNull JpsModelLoader loader, @NotNull File dataStorageRoot, boolean forceBuild,
                              @NotNull Set<String> modulesSet, boolean allModules, 
                              @NotNull List<String> artifactsList, boolean allArtifacts, 
                              boolean includeTests, @NotNull MessageHandler messageHandler) throws Exception {
    List<TargetTypeBuildScope> scopes = new ArrayList<>();
    for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
      if (includeTests || !type.isTests()) {
        TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(type.getTypeId()).setForceBuild(forceBuild);
        if (allModules) {
          scopes.add(builder.setAllTargets(true).build());
        }
        else if (!modulesSet.isEmpty()) {
          scopes.add(builder.addAllTargetId(modulesSet).build());
        }
      }
    }

    TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder()
      .setTypeId(ArtifactBuildTargetType.INSTANCE.getTypeId())
      .setForceBuild(forceBuild);

    if (allArtifacts) {
      scopes.add(builder.setAllTargets(true).build());
    }
    else if (!artifactsList.isEmpty()) {
      scopes.add(builder.addAllTargetId(artifactsList).build());
    }

    runBuild(loader, dataStorageRoot, messageHandler, scopes, true);
  }
public static void runBuild(@NotNull JpsModelLoader loader, @NotNull File dataStorageRoot, boolean forceBuild,
                              @NotNull Set<String> modulesSet, boolean allModules, 
                              @NotNull List<String> artifactsList, boolean allArtifacts, 
                              boolean includeTests, @NotNull MessageHandler messageHandler)