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