Skip to content

Commit 82e4859

Browse files
authored
[MRESOLVER-561] Refresh codebase, drop unused classes (#40)
Also use latest parent POM 42. --- https://issues.apache.org/jira/browse/MRESOLVER-560 https://issues.apache.org/jira/browse/MRESOLVER-561
1 parent 6bda044 commit 82e4859

22 files changed

+73
-80
lines changed

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>org.apache.maven</groupId>
2525
<artifactId>maven-parent</artifactId>
26-
<version>41</version>
26+
<version>42</version>
2727
</parent>
2828

2929
<groupId>org.apache.maven.resolver</groupId>
@@ -181,7 +181,6 @@
181181
<dependency>
182182
<groupId>org.eclipse.sisu</groupId>
183183
<artifactId>org.eclipse.sisu.plexus</artifactId>
184-
<version>0.9.0.M2</version>
185184
<exclusions>
186185
<exclusion>
187186
<groupId>com.google.guava</groupId>

src/main/java/org/apache/maven/resolver/internal/ant/AntRepositoryListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
class AntRepositoryListener extends AbstractRepositoryListener {
3333

34-
private Task task;
34+
private final Task task;
3535

3636
AntRepositoryListener(final Task task) {
3737
this.task = task;

src/main/java/org/apache/maven/resolver/internal/ant/AntServiceLocatorErrorHandler.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/main/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReader.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class ProjectWorkspaceReader implements WorkspaceReader {
4545

4646
private static final Object LOCK = new Object();
4747

48-
private Map<String, Artifact> artifacts = new ConcurrentHashMap<>();
48+
private final Map<String, Artifact> artifacts = new ConcurrentHashMap<>();
4949

5050
public void addPom(Pom pom) {
5151
if (pom.getFile() != null) {
@@ -89,15 +89,18 @@ private String coords(Artifact artifact) {
8989
return ArtifactIdUtils.toId(artifact);
9090
}
9191

92+
@Override
9293
public WorkspaceRepository getRepository() {
9394
return new WorkspaceRepository("ant");
9495
}
9596

97+
@Override
9698
public File findArtifact(Artifact artifact) {
9799
artifact = artifacts.get(coords(artifact));
98100
return (artifact != null) ? artifact.getFile() : null;
99101
}
100102

103+
@Override
101104
public List<String> findVersions(Artifact artifact) {
102105
List<String> versions = new ArrayList<>();
103106
for (Artifact art : artifacts.values()) {

src/main/java/org/apache/maven/resolver/internal/ant/tasks/DependencyGraphLogger.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030
*/
3131
class DependencyGraphLogger implements DependencyVisitor {
3232

33-
private Task task;
33+
private final Task task;
3434

3535
private String indent = "";
3636

3737
DependencyGraphLogger(Task task) {
3838
this.task = task;
3939
}
4040

41+
@Override
4142
public boolean visitEnter(DependencyNode node) {
4243
StringBuilder buffer = new StringBuilder(128);
4344
buffer.append(indent);
@@ -68,6 +69,7 @@ public boolean visitEnter(DependencyNode node) {
6869
return true;
6970
}
7071

72+
@Override
7173
public boolean visitLeave(DependencyNode node) {
7274
indent = indent.substring(0, indent.length() - 3);
7375
return true;

src/main/java/org/apache/maven/resolver/internal/ant/tasks/Layout.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Layout {
4848

4949
public static final String CLS = "{classifier}";
5050

51-
private String[] tokens;
51+
private final String[] tokens;
5252

5353
Layout(String layout) throws BuildException {
5454
Collection<String> valid = new HashSet<>(Arrays.asList(GID, GID_DIRS, AID, VER, BVER, EXT, CLS));
@@ -61,7 +61,7 @@ class Layout {
6161
}
6262
tokens.add(m.group());
6363
}
64-
this.tokens = tokens.toArray(new String[tokens.size()]);
64+
this.tokens = tokens.toArray(new String[0]);
6565
}
6666

6767
public String getPath(Artifact artifact) {
@@ -83,7 +83,7 @@ public String getPath(Artifact artifact) {
8383
if (artifact.getClassifier().length() <= 0) {
8484
if (i > 0) {
8585
String lt = tokens[i - 1];
86-
if (lt.length() > 0 && "-_".indexOf(lt.charAt(lt.length() - 1)) >= 0) {
86+
if (!lt.isEmpty() && "-_".indexOf(lt.charAt(lt.length() - 1)) >= 0) {
8787
buffer.setLength(buffer.length() - 1);
8888
}
8989
}

src/main/java/org/apache/maven/resolver/internal/ant/tasks/RefTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected Object getCheckedRef(final Class<?> requiredClass, final String dataTy
7373
Object o = ref.getReferencedObject(project);
7474
if (!(requiredClass.isAssignableFrom(o.getClass()))) {
7575
log("Class " + o.getClass() + " is not a subclass of " + requiredClass, Project.MSG_VERBOSE);
76-
String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName;
76+
String msg = ref.getRefId() + " doesn't denote a " + dataTypeName;
7777
throw new BuildException(msg);
7878
}
7979
return o;

src/main/java/org/apache/maven/resolver/internal/ant/tasks/Resolve.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
*/
5757
public class Resolve extends AbstractResolvingTask {
5858

59-
private List<ArtifactConsumer> consumers = new ArrayList<>();
59+
private final List<ArtifactConsumer> consumers = new ArrayList<>();
6060

6161
private boolean failOnMissingAttachments;
6262

@@ -191,7 +191,7 @@ public void setScopes(String scopes) {
191191
} else {
192192
dst = included;
193193
}
194-
if (scope.length() > 0) {
194+
if (!scope.isEmpty()) {
195195
dst.add(scope);
196196
}
197197
}
@@ -215,7 +215,7 @@ public void setClasspath(String classpath) {
215215

216216
/**
217217
*/
218-
public class Path extends ArtifactConsumer {
218+
public static class Path extends ArtifactConsumer {
219219

220220
private String refid;
221221

@@ -225,12 +225,14 @@ public void setRefId(String refId) {
225225
this.refid = refId;
226226
}
227227

228+
@Override
228229
public void validate() {
229230
if (refid == null) {
230231
throw new BuildException("You must specify the 'refid' for the path");
231232
}
232233
}
233234

235+
@Override
234236
public void process(Artifact artifact, RepositorySystemSession session) {
235237
if (path == null) {
236238
path = new org.apache.tools.ant.types.Path(getProject());
@@ -264,6 +266,7 @@ public void setRefId(String refId) {
264266
this.refid = refId;
265267
}
266268

269+
@Override
267270
public String getClassifier() {
268271
return classifier;
269272
}
@@ -290,6 +293,7 @@ public void setLayout(String layout) {
290293
this.layout = new Layout(layout);
291294
}
292295

296+
@Override
293297
public void validate() {
294298
if (refid == null && dir == null) {
295299
throw new BuildException("You must either specify the 'refid' for the resource collection"
@@ -300,6 +304,7 @@ public void validate() {
300304
}
301305
}
302306

307+
@Override
303308
public void process(Artifact artifact, RepositorySystemSession session) {
304309
if (dir != null) {
305310
if (refid != null && fileset == null) {
@@ -346,7 +351,7 @@ public void process(Artifact artifact, RepositorySystemSession session) {
346351

347352
/**
348353
*/
349-
public class Props extends ArtifactConsumer {
354+
public static class Props extends ArtifactConsumer {
350355

351356
private String prefix;
352357

@@ -356,6 +361,7 @@ public void setPrefix(String prefix) {
356361
this.prefix = prefix;
357362
}
358363

364+
@Override
359365
public String getClassifier() {
360366
return classifier;
361367
}
@@ -371,9 +377,10 @@ public void setAttachments(String attachments) {
371377
}
372378
}
373379

380+
@Override
374381
public void process(Artifact artifact, RepositorySystemSession session) {
375382
StringBuilder buffer = new StringBuilder(256);
376-
if (prefix != null && prefix.length() > 0) {
383+
if (prefix != null && !prefix.isEmpty()) {
377384
buffer.append(prefix);
378385
if (!prefix.endsWith(".")) {
379386
buffer.append('.');
@@ -384,7 +391,7 @@ public void process(Artifact artifact, RepositorySystemSession session) {
384391
buffer.append(artifact.getArtifactId());
385392
buffer.append(':');
386393
buffer.append(artifact.getExtension());
387-
if (artifact.getClassifier().length() > 0) {
394+
if (!artifact.getClassifier().isEmpty()) {
388395
buffer.append(':');
389396
buffer.append(artifact.getClassifier());
390397
}
@@ -397,11 +404,11 @@ public void process(Artifact artifact, RepositorySystemSession session) {
397404

398405
private static class Group {
399406

400-
private String classifier;
407+
private final String classifier;
401408

402-
private List<ArtifactConsumer> consumers = new ArrayList<>();
409+
private final List<ArtifactConsumer> consumers = new ArrayList<>();
403410

404-
private List<ArtifactRequest> requests = new ArrayList<>();
411+
private final List<ArtifactRequest> requests = new ArrayList<>();
405412

406413
Group(String classifier) {
407414
this.classifier = classifier;

src/main/java/org/apache/maven/resolver/internal/ant/types/Artifact.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected Artifact getRef() {
4444
return (Artifact) getCheckedRef();
4545
}
4646

47+
@Override
4748
public void validate(final Task task) {
4849
if (isReference()) {
4950
getRef().validate(task);
@@ -59,6 +60,7 @@ public void validate(final Task task) {
5960
}
6061
}
6162

63+
@Override
6264
public void setRefid(final Reference ref) {
6365
if (file != null || type != null || classifier != null) {
6466
throw tooManyAttributes();
@@ -130,6 +132,7 @@ public Pom getPom() {
130132
return pom;
131133
}
132134

135+
@Override
133136
public List<Artifact> getArtifacts() {
134137
return Collections.singletonList(this);
135138
}
@@ -139,6 +142,7 @@ public void execute() throws BuildException {
139142
ProjectWorkspaceReader.getInstance().addArtifact(this);
140143
}
141144

145+
@Override
142146
public String toString() {
143147
final String pomRepr = getPom() != null ? "(" + getPom().toString() + ":)" : "";
144148
return String.format(pomRepr + "%s:%s", getType(), getClassifier());

src/main/java/org/apache/maven/resolver/internal/ant/types/Artifacts.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@
2929
*/
3030
public class Artifacts extends DataType implements ArtifactContainer {
3131

32-
private List<ArtifactContainer> containers = new ArrayList<>();
32+
private final List<ArtifactContainer> containers = new ArrayList<>();
3333

3434
protected Artifacts getRef() {
35-
return (Artifacts) getCheckedRef();
35+
return getCheckedRef(Artifacts.class);
3636
}
3737

38+
@Override
3839
public void validate(Task task) {
3940
if (isReference()) {
4041
getRef().validate(task);
@@ -45,6 +46,7 @@ public void validate(Task task) {
4546
}
4647
}
4748

49+
@Override
4850
public void setRefid(Reference ref) {
4951
if (!containers.isEmpty()) {
5052
throw noChildrenAllowed();
@@ -65,6 +67,7 @@ public void addArtifacts(Artifacts artifacts) {
6567
containers.add(artifacts);
6668
}
6769

70+
@Override
6871
public List<Artifact> getArtifacts() {
6972
if (isReference()) {
7073
return getRef().getArtifacts();

0 commit comments

Comments
 (0)