Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 54860fd5fc9f6148ce57fa51144349522b95dcc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*******************************************************************************
 * Copyright (c) 2008-2010 Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *      Sonatype, Inc. - initial API and implementation
 *******************************************************************************/

package org.eclipse.m2e.core.internal.project;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

import org.eclipse.core.resources.IFile;

import org.apache.maven.execution.MavenExecutionRequest;

import org.eclipse.m2e.core.project.MavenUpdateRequest;

/**
 * @author igor
 */
public class DependencyResolutionContext {

  /** Original update request */
  private final MavenUpdateRequest request;

  /** Set of all pom files to resolve */
  private final Set<IFile> pomFiles = new LinkedHashSet<IFile>();

  /** Set of pom files to resolve regardless of their isStale() state */
  private final Set<IFile> forcedPomFiles = new HashSet<IFile>();

  /** The template request for invocations of Maven */
  private MavenExecutionRequest executionRequest;

  public DependencyResolutionContext(MavenUpdateRequest request, MavenExecutionRequest executionRequest) {
    this.request = request;
    this.pomFiles.addAll(request.getPomFiles());
    this.executionRequest = executionRequest;
  }

  public synchronized boolean isEmpty() {
    return pomFiles.isEmpty();
  }

  public synchronized void forcePomFiles(Set<IFile> pomFiles) {
    this.pomFiles.addAll(pomFiles);
    this.forcedPomFiles.addAll(pomFiles);
  }

  public MavenUpdateRequest getRequest() {
    return request;
  }

  public MavenExecutionRequest getExecutionRequest() {
    return executionRequest;
  }

  public boolean isForce(IFile pom) {
    return request.isForce() || forcedPomFiles.contains(pom);
  }

  public synchronized IFile pop() {
    Iterator<IFile> i = pomFiles.iterator();
    IFile pom = i.next();
    i.remove();
    return pom;
  }
}

Back to the top