1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.plugin;
20
21 import javax.inject.Inject;
22
23 import java.io.IOException;
24
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.Parameter;
28 import org.apache.maven.scm.ScmException;
29 import org.apache.maven.scm.ScmFile;
30 import org.apache.maven.scm.command.list.ListScmResult;
31 import org.apache.maven.scm.manager.ScmManager;
32 import org.apache.maven.scm.repository.ScmRepository;
33 import org.apache.maven.settings.crypto.SettingsDecrypter;
34
35
36
37
38
39
40 @Mojo(name = "list", aggregator = true)
41 public class ListMojo extends AbstractScmMojo {
42
43
44
45 @Parameter(property = "scmVersionType")
46 private String scmVersionType;
47
48
49
50
51 @Parameter(property = "scmVersion")
52 private String scmVersion;
53
54
55
56
57 @Parameter(property = "recursive", defaultValue = "true")
58 private boolean recursive = true;
59
60 @Inject
61 public ListMojo(ScmManager manager, SettingsDecrypter settingsDecrypter) {
62 super(manager, settingsDecrypter);
63 }
64
65
66
67
68 public void execute() throws MojoExecutionException {
69 super.execute();
70
71 try {
72 ScmRepository repository = getScmRepository();
73 ListScmResult result = getScmManager()
74 .list(repository, getFileSet(), recursive, getScmVersion(scmVersionType, scmVersion));
75
76 checkResult(result);
77
78 if (result.getFiles() != null) {
79 for (ScmFile scmFile : result.getFiles()) {
80 getLog().info(scmFile.getPath());
81 }
82 }
83 } catch (ScmException | IOException e) {
84 throw new MojoExecutionException("Cannot run list command : ", e);
85 }
86 }
87 }