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.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.ScmFileSet;
31 import org.apache.maven.scm.command.list.ListScmResult;
32 import org.apache.maven.scm.repository.ScmRepository;
33
34
35
36
37
38
39 @Mojo( name = "list", aggregator = true )
40 public class ListMojo
41 extends AbstractScmMojo
42 {
43
44
45
46 @Parameter( property = "scmVersionType" )
47 private String scmVersionType;
48
49
50
51
52 @Parameter( property = "scmVersion" )
53 private String scmVersion;
54
55
56
57
58 @Parameter( property = "recursive", defaultValue = "true" )
59 private boolean recursive = true;
60
61
62 public void execute()
63 throws MojoExecutionException
64 {
65 super.execute();
66
67 try
68 {
69 ScmRepository repository = getScmRepository();
70 ListScmResult result = getScmManager().list( repository, getFileSet(), recursive,
71 getScmVersion( scmVersionType, scmVersion ) );
72
73 checkResult( result );
74
75 if ( result.getFiles() != null )
76 {
77 for ( ScmFile scmFile : result.getFiles() )
78 {
79 getLog().info( scmFile.getPath() );
80 }
81 }
82 }
83 catch ( ScmException e )
84 {
85 throw new MojoExecutionException( "Cannot run list command : ", e );
86 }
87 catch ( IOException e )
88 {
89 throw new MojoExecutionException( "Cannot run list command : ", e );
90 }
91 }
92
93 public ScmFileSet getFileSet()
94 throws IOException
95 {
96 if ( getIncludes() != null || getExcludes() != null )
97 {
98 return new ScmFileSet( getWorkingDirectory(), getIncludes(), getExcludes() );
99 }
100 else
101 {
102 return new ScmFileSet( getWorkingDirectory(), new File( "." ) );
103 }
104 }
105
106 }
107