1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.api.plugin.testing.stubs;
20
21 import java.io.File;
22 import java.nio.file.Path;
23 import java.util.Collections;
24 import java.util.List;
25 import java.util.Optional;
26
27 import org.apache.maven.api.Artifact;
28 import org.apache.maven.api.DependencyCoordinate;
29 import org.apache.maven.api.Project;
30 import org.apache.maven.api.RemoteRepository;
31 import org.apache.maven.api.annotations.Nonnull;
32 import org.apache.maven.api.model.Model;
33
34
35
36
37
38
39 public class ProjectStub implements Project {
40
41 private Model model = Model.newInstance();
42 private Path basedir;
43 private File pomPath;
44 private boolean executionRoot;
45 private Artifact artifact;
46
47 public void setModel(Model model) {
48 this.model = model;
49 }
50
51 @Nonnull
52 @Override
53 public String getGroupId() {
54 return model.getGroupId();
55 }
56
57 @Nonnull
58 @Override
59 public String getArtifactId() {
60 return model.getArtifactId();
61 }
62
63 @Nonnull
64 @Override
65 public String getVersion() {
66 return model.getVersion();
67 }
68
69 public String getName() {
70 return model.getName();
71 }
72
73 @Nonnull
74 @Override
75 public String getPackaging() {
76 return model.getPackaging();
77 }
78
79 @Nonnull
80 @Override
81 public Artifact getArtifact() {
82 return artifact;
83 }
84
85 @Nonnull
86 @Override
87 public Model getModel() {
88 return model;
89 }
90
91 @Nonnull
92 @Override
93 public Optional<Path> getPomPath() {
94 return Optional.ofNullable(pomPath).map(File::toPath);
95 }
96
97 @Nonnull
98 @Override
99 public List<DependencyCoordinate> getDependencies() {
100 return null;
101 }
102
103 @Nonnull
104 @Override
105 public List<DependencyCoordinate> getManagedDependencies() {
106 return null;
107 }
108
109 @Override
110 public Optional<Path> getBasedir() {
111 return Optional.ofNullable(basedir);
112 }
113
114 public void setBasedir(Path basedir) {
115 this.basedir = basedir;
116 }
117
118 @Override
119 public boolean isExecutionRoot() {
120 return executionRoot;
121 }
122
123 @Override
124 public Optional<Project> getParent() {
125 return Optional.empty();
126 }
127
128 @Override
129 public List<RemoteRepository> getRemoteProjectRepositories() {
130 return Collections.emptyList();
131 }
132
133 @Override
134 public List<RemoteRepository> getRemotePluginRepositories() {
135 return Collections.emptyList();
136 }
137
138 public void setGroupId(String groupId) {
139 model = model.withGroupId(groupId);
140 }
141
142 public void setArtifactId(String artifactId) {
143 model = model.withArtifactId(artifactId);
144 }
145
146 public void setVersion(String version) {
147 model = model.withVersion(version);
148 }
149
150 public void setName(String name) {
151 model = model.withName(name);
152 }
153
154 public void setPackaging(String packaging) {
155 model = model.withPackaging(packaging);
156 }
157
158 public void setArtifact(Artifact artifact) {
159 this.artifact = artifact;
160 }
161
162 public void setPomPath(File pomPath) {
163 this.pomPath = pomPath;
164 }
165
166 public void setExecutionRoot(boolean executionRoot) {
167 this.executionRoot = executionRoot;
168 }
169
170 public void setMavenModel(org.apache.maven.model.Model model) {
171 this.model = model.getDelegate();
172 }
173 }