1 package org.apache.maven.scm.plugin;
2
3 import org.apache.maven.plugin.MojoExecutionException;
4 import org.apache.maven.scm.ScmException;
5 import org.apache.maven.scm.ScmFile;
6 import org.apache.maven.scm.ScmFileSet;
7 import org.apache.maven.scm.command.list.ListScmResult;
8 import org.apache.maven.scm.repository.ScmRepository;
9
10 import java.io.File;
11 import java.io.IOException;
12 import java.util.Iterator;
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class ListMojo
43 extends AbstractScmMojo
44 {
45
46
47
48
49
50 private String scmVersionType;
51
52
53
54
55
56
57 private String scmVersion;
58
59
60
61
62
63
64 private boolean recursive = true;
65
66 public void execute()
67 throws MojoExecutionException
68 {
69 super.execute();
70
71 try
72 {
73 ScmRepository repository = getScmRepository();
74 ListScmResult result = getScmManager().list( repository, getFileSet(), recursive,
75 getScmVersion( scmVersionType, scmVersion ) );
76
77 checkResult( result );
78
79 if ( result.getFiles() != null )
80 {
81 for ( Iterator i = result.getFiles().iterator(); i.hasNext(); )
82 {
83 ScmFile scmFile = (ScmFile) i.next();
84 getLog().info( scmFile.getPath() );
85 }
86 }
87 }
88 catch ( ScmException e )
89 {
90 throw new MojoExecutionException( "Cannot run list command : ", e );
91 }
92 catch ( IOException e )
93 {
94 throw new MojoExecutionException( "Cannot run list command : ", e );
95 }
96 }
97
98 public ScmFileSet getFileSet()
99 throws IOException
100 {
101 if ( getIncludes() != null || getExcludes() != null )
102 {
103 return new ScmFileSet( getWorkingDirectory(), getIncludes(), getExcludes() );
104 }
105 else
106 {
107 return new ScmFileSet( getWorkingDirectory(), new File( "." ) );
108 }
109 }
110
111 }
112