blob: cef502eb426d7020b2e85a503e775c78f48a3e5f (
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*******************************************************************************
* 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.project;
import java.util.LinkedHashSet;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.m2e.core.core.IMavenConstants;
/**
* Maven project update request
*
* @author Eugene Kuleshov
*/
public class MavenUpdateRequest {
/**
* Put Maven repository system in offline mode. Same effect as -o mvn command line parameter.
*/
private boolean offline = false;
/**
* Forces a check for updated releases and snapshots on remote repositories. Same effect as -U mvn command line
* parameter.
*/
private boolean forceDependencyUpdate = false;
/**
* Set of {@link IFile}
*/
private final Set<IFile> pomFiles = new LinkedHashSet<IFile>();
public MavenUpdateRequest(boolean offline, boolean forceDependencyUpdate) {
this.offline = offline;
this.forceDependencyUpdate = forceDependencyUpdate;
}
public MavenUpdateRequest(IProject project, boolean offline, boolean updateSnapshots) {
this(offline, updateSnapshots);
addPomFile(project);
}
public MavenUpdateRequest(IProject[] projects, boolean offline, boolean updateSnapshots) {
this(offline, updateSnapshots);
for(int i = 0; i < projects.length; i++ ) {
addPomFile(projects[i]);
}
}
public boolean isOffline() {
return this.offline;
}
public boolean isForceDependencyUpdate() {
return this.forceDependencyUpdate;
}
public void addPomFiles(Set<IFile> pomFiles) {
for(IFile pomFile : pomFiles) {
addPomFile(pomFile);
}
}
public void addPomFile(IFile pomFile) {
pomFiles.add(pomFile);
}
public void addPomFile(IProject project) {
pomFiles.add(project.getFile(IMavenConstants.POM_FILE_NAME));
}
public void removePomFile(IFile pomFile) {
pomFiles.remove(pomFile);
}
/**
* Returns Set of {@link IFile}
*/
public Set<IFile> getPomFiles() {
return this.pomFiles;
}
public boolean isEmpty() {
return this.pomFiles.isEmpty();
}
public String toString() {
StringBuilder sb = new StringBuilder("["); //$NON-NLS-1$
String sep = ""; //$NON-NLS-1$
for(IFile pomFile : pomFiles) {
sb.append(sep);
sb.append(pomFile.getFullPath());
sep = ", "; //$NON-NLS-1$
}
sb.append("]"); //$NON-NLS-1$
if(offline) {
sb.append(" offline"); //$NON-NLS-1$
}
if(forceDependencyUpdate) {
sb.append(" forceDependencyUpdate"); //$NON-NLS-1$
}
return sb.toString();
}
}
|