1 package org.apache.maven.plugins.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<>();
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<>();
57 }
58 final List<Dependency> dependencies = new ArrayList<>();
59 for ( Artifact a : getArtifacts() )
60 {
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 public List<String> getRuntimeClasspathElements()
75 {
76 List<String> artifacts = new ArrayList<>();
77
78 artifacts.add(
79 "src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar" );
80 artifacts.add(
81 "src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar" );
82
83 return artifacts;
84 }
85 }