Coverage Report - org.apache.maven.shared.release.phase.AbstractReleasePomsPhase
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractReleasePomsPhase
77%
7/9
N/A
5
 
 1  
 package org.apache.maven.shared.release.phase;
 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.scm.manager.NoSuchScmProviderException;
 23  
 import org.apache.maven.scm.provider.ScmProvider;
 24  
 import org.apache.maven.scm.repository.ScmRepository;
 25  
 import org.apache.maven.scm.repository.ScmRepositoryException;
 26  
 import org.apache.maven.shared.release.ReleaseExecutionException;
 27  
 import org.apache.maven.shared.release.ReleaseFailureException;
 28  
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 29  
 import org.apache.maven.shared.release.env.ReleaseEnvironment;
 30  
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 31  
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
 32  
 
 33  
 /**
 34  
  * Abstract release POM phase.
 35  
  *
 36  
  * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
 37  
  */
 38  196
 public abstract class AbstractReleasePomsPhase extends AbstractReleasePhase
 39  
 {
 40  
     /**
 41  
      * Tool that gets a configured SCM repository from release configuration.
 42  
      *
 43  
      * @plexus.requirement
 44  
      */
 45  
     private ScmRepositoryConfigurator scmRepositoryConfigurator;
 46  
 
 47  
     protected ScmRepository getScmRepository( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment )
 48  
         throws ReleaseFailureException, ReleaseExecutionException
 49  
     {
 50  
         try
 51  
         {
 52  94
             return scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, releaseEnvironment.getSettings() );
 53  
         }
 54  2
         catch ( ScmRepositoryException exception )
 55  
         {
 56  2
             throw new ReleaseScmRepositoryException( exception.getMessage(), exception.getValidationMessages() );
 57  
         }
 58  2
         catch ( NoSuchScmProviderException exception )
 59  
         {
 60  2
             throw new ReleaseExecutionException( "Unable to configure SCM repository: " + exception.getMessage(),
 61  
                                                  exception );
 62  
         }
 63  
     }
 64  
 
 65  
     protected ScmProvider getScmProvider( ScmRepository scmRepository )
 66  
         throws ReleaseExecutionException
 67  
     {
 68  
         try
 69  
         {
 70  56
             return scmRepositoryConfigurator.getRepositoryProvider( scmRepository );
 71  
         }
 72  0
         catch ( NoSuchScmProviderException exception )
 73  
         {
 74  0
             throw new ReleaseExecutionException( "Unable to configure SCM repository: " + exception.getMessage(),
 75  
                                                  exception );
 76  
         }
 77  
     }
 78  
 }