Coverage Report - org.apache.maven.shared.release.phase.RunGoalsPhase
 
Classes in this File Line Coverage Branch Coverage Complexity
RunGoalsPhase
100% 
100% 
2
 
 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.settings.Settings;
 23  
 import org.apache.maven.shared.release.ReleaseExecutionException;
 24  
 import org.apache.maven.shared.release.ReleaseResult;
 25  
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 26  
 import org.apache.maven.shared.release.exec.MavenExecutor;
 27  
 import org.apache.maven.shared.release.exec.MavenExecutorException;
 28  
 import org.codehaus.plexus.util.StringUtils;
 29  
 
 30  
 import java.io.File;
 31  
 import java.util.List;
 32  
 
 33  
 /**
 34  
  * Run the integration tests for the project to verify that it builds before committing.
 35  
  *
 36  
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
 37  
  */
 38  62
 public class RunGoalsPhase
 39  
     extends AbstractReleasePhase
 40  
 {
 41  
     /**
 42  
      * Component to assist in executing Maven.
 43  
      */
 44  
     private MavenExecutor mavenExecutor;
 45  
 
 46  
     public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, Settings settings, List reactorProjects )
 47  
         throws ReleaseExecutionException
 48  
     {
 49  10
         ReleaseResult result = new ReleaseResult();
 50  
 
 51  
         try
 52  
         {
 53  10
             String goals = releaseDescriptor.getPreparationGoals();
 54  10
             if ( !StringUtils.isEmpty( goals ) )
 55  
             {
 56  8
                 logInfo( result, "Executing preparation goals '" + goals + "'..." );
 57  
 
 58  8
                 mavenExecutor.executeGoals( new File( releaseDescriptor.getWorkingDirectory() ), goals,
 59  
                                             releaseDescriptor.isInteractive(),
 60  
                                             releaseDescriptor.getAdditionalArguments(), result );
 61  
             }
 62  
         }
 63  4
         catch ( MavenExecutorException e )
 64  
         {
 65  4
             throw new ReleaseExecutionException( e.getMessage(), e );
 66  6
         }
 67  
 
 68  6
         result.setResultCode( ReleaseResult.SUCCESS );
 69  
 
 70  6
         return result;
 71  
     }
 72  
 
 73  
     public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, Settings settings, List reactorProjects )
 74  
         throws ReleaseExecutionException
 75  
     {
 76  4
         ReleaseResult result = new ReleaseResult();
 77  
 
 78  4
         logInfo( result, "Executing preparation goals - since this is simulation mode it is running against the " +
 79  
             "original project, not the rewritten ones" );
 80  
 
 81  4
         execute( releaseDescriptor, settings, reactorProjects );
 82  
 
 83  2
         return result;
 84  
     }
 85  
 
 86  
     public void setMavenExecutor( MavenExecutor mavenExecutor )
 87  
     {
 88  10
         this.mavenExecutor = mavenExecutor;
 89  10
     }
 90  
 }