Coverage Report - org.apache.maven.scm.plugin.BranchMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
BranchMojo
71%
10/14
N/A
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 org.apache.maven.plugin.MojoExecutionException;
 23  
 import org.apache.maven.scm.ScmException;
 24  
 import org.apache.maven.scm.command.branch.BranchScmResult;
 25  
 import org.apache.maven.scm.provider.ScmProvider;
 26  
 import org.apache.maven.scm.repository.ScmRepository;
 27  
 
 28  
 import java.io.IOException;
 29  
 
 30  
 /**
 31  
  * Branch the project.
 32  
  *
 33  
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
 34  
  * @version $Id: BranchMojo.java 538856 2007-05-17 09:58:55Z evenisse $
 35  
  * @goal branch
 36  
  * @description Branch the project
 37  
  * @aggregator
 38  
  */
 39  1
 public class BranchMojo
 40  
     extends AbstractScmMojo
 41  
 {
 42  
     /**
 43  
      * Tag name.
 44  
      *
 45  
      * @parameter expression="${branch}"
 46  
      */
 47  
     private String branch;
 48  
 
 49  
     /**
 50  
      * The message applied to the tag creation.
 51  
      *
 52  
      * @parameter expression="${message}"
 53  
      */
 54  
     private String message;
 55  
 
 56  
     public void execute()
 57  
         throws MojoExecutionException
 58  
     {
 59  1
         super.execute();
 60  
 
 61  
         try
 62  
         {
 63  1
             ScmRepository repository = getScmRepository();
 64  1
             ScmProvider provider = getScmManager().getProviderByRepository( repository );
 65  
 
 66  1
             String finalBranch = provider.sanitizeTagName( branch );
 67  1
             getLog().info( "Final Branch Name: '" + finalBranch + "'" );
 68  
 
 69  1
             BranchScmResult result = provider.branch( repository, getFileSet(), finalBranch, message );
 70  
 
 71  1
             checkResult( result );
 72  
         }
 73  0
         catch ( IOException e )
 74  
         {
 75  0
             throw new MojoExecutionException( "Cannot run branch command : ", e );
 76  
         }
 77  0
         catch ( ScmException e )
 78  
         {
 79  0
             throw new MojoExecutionException( "Cannot run branch command : ", e );
 80  1
         }
 81  1
     }
 82  
 }