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