1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.war.stub;
20
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.Set;
24 import java.util.TreeSet;
25
26 import org.apache.maven.artifact.Artifact;
27 import org.apache.maven.model.Dependency;
28 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
29
30 public class MavenProjectArtifactsStub extends MavenProjectBasicStub {
31 TreeSet<Artifact> artifacts;
32
33 public MavenProjectArtifactsStub() throws Exception {
34 artifacts = new TreeSet<>();
35 }
36
37 public void addArtifact(ArtifactStub stub) {
38 artifacts.add(stub);
39 }
40
41 public Set<Artifact> getArtifacts() {
42 return artifacts;
43 }
44
45 public List<Dependency> getDependencies() {
46 if (getArtifacts() == null) {
47 return new ArrayList<>();
48 }
49 final List<Dependency> dependencies = new ArrayList<>();
50 for (Artifact a : getArtifacts()) {
51 Dependency dependency = new Dependency();
52 dependency.setArtifactId(a.getArtifactId());
53 dependency.setGroupId(a.getGroupId());
54 dependency.setVersion(a.getVersion());
55 dependency.setScope(a.getScope());
56 dependency.setType(a.getType());
57 dependency.setClassifier(a.getClassifier());
58 dependencies.add(dependency);
59 }
60 return dependencies;
61 }
62
63 public List<String> getRuntimeClasspathElements() {
64 List<String> artifacts = new ArrayList<>();
65
66 artifacts.add(
67 "src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar");
68 artifacts.add(
69 "src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar");
70
71 return artifacts;
72 }
73 }