Coverage Report - org.apache.maven.shared.release.phase.CheckCompletedPreparePhasesPhase
 
Classes in this File Line Coverage Branch Coverage Complexity
CheckCompletedPreparePhasesPhase
100%
15/15
100%
6/6
3,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 java.util.List;
 23  
 
 24  
 import org.apache.maven.project.MavenProject;
 25  
 import org.apache.maven.shared.release.ReleaseExecutionException;
 26  
 import org.apache.maven.shared.release.ReleaseFailureException;
 27  
 import org.apache.maven.shared.release.ReleaseResult;
 28  
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 29  
 import org.apache.maven.shared.release.env.ReleaseEnvironment;
 30  
 
 31  
 /**
 32  
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
 33  
  * @version $Id: CheckCompletedPreparePhasesPhase.java 1066014 2011-02-01 11:55:50Z olamy $
 34  
  * @plexus.component role="org.apache.maven.shared.release.phase.ReleasePhase" role-hint="verify-completed-prepare-phases"
 35  
  */
 36  58
 public class CheckCompletedPreparePhasesPhase
 37  
     extends AbstractReleasePhase
 38  
 {
 39  
     public ReleaseResult execute( ReleaseDescriptor releaseDescriptor,
 40  
                                   ReleaseEnvironment releaseEnvironment,
 41  
                                   List<MavenProject> reactorProjects )
 42  
         throws ReleaseExecutionException, ReleaseFailureException
 43  
     {
 44  26
         ReleaseResult result = new ReleaseResult();
 45  
 
 46  
         // if we stopped mid-way through preparation - don't perform
 47  26
         if ( releaseDescriptor.getCompletedPhase() != null
 48  
              && !"end-release".equals( releaseDescriptor.getCompletedPhase() ) )
 49  
         {
 50  2
             String message = "Cannot perform release - the preparation step was stopped mid-way. Please re-run "
 51  
                              + "release:prepare to continue, or perform the release from an SCM tag.";
 52  
 
 53  2
             result.setResultCode( ReleaseResult.ERROR );
 54  
 
 55  2
             logError( result, message );
 56  
 
 57  2
             throw new ReleaseFailureException( message );
 58  
         }
 59  
 
 60  24
         if ( releaseDescriptor.getScmSourceUrl() == null )
 61  
         {
 62  2
             String message = "No SCM URL was provided to perform the release from";
 63  
 
 64  2
             result.setResultCode( ReleaseResult.ERROR );
 65  
 
 66  2
             logError( result, message );
 67  
 
 68  2
             throw new ReleaseFailureException( message );
 69  
         }
 70  
 
 71  22
         result.setResultCode( ReleaseResult.SUCCESS );
 72  
 
 73  22
         return result;
 74  
     }
 75  
 
 76  
     public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor,
 77  
                                    ReleaseEnvironment releaseEnvironment,
 78  
                                    List<MavenProject> reactorProjects )
 79  
         throws ReleaseExecutionException, ReleaseFailureException
 80  
     {
 81  2
         return execute( releaseDescriptor, releaseEnvironment, reactorProjects );
 82  
     }
 83  
 }