private static void doSetResolvedAttributes(State state,
                                              MavenModel model,
                                              Set<MavenId> unresolvedArtifactIds,
                                              boolean keepPreviousArtifacts,
                                              boolean keepPreviousPlugins) {
    Set<MavenId> newUnresolvedArtifacts = new HashSet<>();
    LinkedHashSet<MavenRemoteRepository> newRepositories = new LinkedHashSet<>();
    LinkedHashSet<MavenArtifact> newDependencies = new LinkedHashSet<>();
    LinkedHashSet<MavenArtifactNode> newDependencyTree = new LinkedHashSet<>();
    LinkedHashSet<MavenPlugin> newPlugins = new LinkedHashSet<>();
    LinkedHashSet<MavenArtifact> newExtensions = new LinkedHashSet<>();
    LinkedHashSet<MavenArtifact> newAnnotationProcessors = new LinkedHashSet<>();

    if (keepPreviousArtifacts) {
      if (state.myUnresolvedArtifactIds != null) newUnresolvedArtifacts.addAll(state.myUnresolvedArtifactIds);
      if (state.myRemoteRepositories != null) newRepositories.addAll(state.myRemoteRepositories);
      if (state.myDependencies != null) newDependencies.addAll(state.myDependencies);
      if (state.myDependencyTree != null) newDependencyTree.addAll(state.myDependencyTree);
      if (state.myExtensions != null) newExtensions.addAll(state.myExtensions);
      if (state.myAnnotationProcessors != null) newAnnotationProcessors.addAll(state.myAnnotationProcessors);
    }

    if (keepPreviousPlugins) {
      if (state.myPlugins != null) newPlugins.addAll(state.myPlugins);
    }

    newUnresolvedArtifacts.addAll(unresolvedArtifactIds);
    newRepositories.addAll(model.getRemoteRepositories());
    newDependencyTree.addAll(model.getDependencyTree());
    newDependencies.addAll(model.getDependencies());
    newPlugins.addAll(model.getPlugins());
    newExtensions.addAll(model.getExtensions());

    state.myUnresolvedArtifactIds = newUnresolvedArtifacts;
    state.myRemoteRepositories = new ArrayList<>(newRepositories);
    state.myDependencies = new ArrayList<>(newDependencies);
    state.myDependencyTree = new ArrayList<>(newDependencyTree);
    state.myPlugins = new ArrayList<>(newPlugins);
    state.myExtensions = new ArrayList<>(newExtensions);
    state.myAnnotationProcessors = new ArrayList<>(newAnnotationProcessors);
  }
private static void doSetResolvedAttributes(State state,
                                              MavenModel model,
                                              Set<MavenId> unresolvedArtifactIds,
                                              boolean keepPreviousArtifacts,
                                              boolean keepPreviousPlugins)