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