Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ListMojo |
|
| 5.5;5.5 |
1 | package org.apache.maven.scm.plugin; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
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 | * Get the list of project files. | |
34 | * | |
35 | * @author <a href="evenisse@apache.org">Emmanuel Venisse</a> | |
36 | * @version $Id: ListMojo.java 1055646 2011-01-05 21:22:58Z olamy $ | |
37 | * @goal list | |
38 | * @aggregator | |
39 | */ | |
40 | 0 | public class ListMojo |
41 | extends AbstractScmMojo | |
42 | { | |
43 | /** | |
44 | * The version type (branch/tag/revision) of scmVersion. | |
45 | * | |
46 | * @parameter expression="${scmVersionType}" | |
47 | */ | |
48 | private String scmVersionType; | |
49 | ||
50 | /** | |
51 | * The version (revision number/branch name/tag name). | |
52 | * | |
53 | * @parameter expression="${scmVersion}" | |
54 | */ | |
55 | private String scmVersion; | |
56 | ||
57 | /** | |
58 | * Use recursive mode. | |
59 | * | |
60 | * @parameter expression="${recursive}" default-value="true" | |
61 | */ | |
62 | 0 | private boolean recursive = true; |
63 | ||
64 | /** {@inheritDoc} */ | |
65 | public void execute() | |
66 | throws MojoExecutionException | |
67 | { | |
68 | 0 | super.execute(); |
69 | ||
70 | try | |
71 | { | |
72 | 0 | ScmRepository repository = getScmRepository(); |
73 | 0 | ListScmResult result = getScmManager().list( repository, getFileSet(), recursive, |
74 | getScmVersion( scmVersionType, scmVersion ) ); | |
75 | ||
76 | 0 | checkResult( result ); |
77 | ||
78 | 0 | if ( result.getFiles() != null ) |
79 | { | |
80 | 0 | for ( ScmFile scmFile : result.getFiles() ) |
81 | { | |
82 | 0 | getLog().info( scmFile.getPath() ); |
83 | } | |
84 | } | |
85 | } | |
86 | 0 | catch ( ScmException e ) |
87 | { | |
88 | 0 | throw new MojoExecutionException( "Cannot run list command : ", e ); |
89 | } | |
90 | 0 | catch ( IOException e ) |
91 | { | |
92 | 0 | throw new MojoExecutionException( "Cannot run list command : ", e ); |
93 | 0 | } |
94 | 0 | } |
95 | ||
96 | public ScmFileSet getFileSet() | |
97 | throws IOException | |
98 | { | |
99 | 0 | if ( getIncludes() != null || getExcludes() != null ) |
100 | { | |
101 | 0 | return new ScmFileSet( getWorkingDirectory(), getIncludes(), getExcludes() ); |
102 | } | |
103 | else | |
104 | { | |
105 | 0 | return new ScmFileSet( getWorkingDirectory(), new File( "." ) ); |
106 | } | |
107 | } | |
108 | ||
109 | } | |
110 |