Coverage Report - org.apache.maven.shared.release.exec.AbstractMavenExecutor
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMavenExecutor
100%
18/18
100%
4/4
1,25
 
 1  
 package org.apache.maven.shared.release.exec;
 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.shared.release.ReleaseResult;
 23  
 import org.apache.maven.shared.release.env.DefaultReleaseEnvironment;
 24  
 import org.apache.maven.shared.release.env.ReleaseEnvironment;
 25  
 import org.codehaus.plexus.logging.LogEnabled;
 26  
 import org.codehaus.plexus.logging.Logger;
 27  
 import org.codehaus.plexus.util.StringUtils;
 28  
 
 29  
 import java.io.File;
 30  
 import java.util.ArrayList;
 31  
 import java.util.List;
 32  
 
 33  
 public abstract class AbstractMavenExecutor
 34  
     implements MavenExecutor, LogEnabled
 35  
 {
 36  
 
 37  
     private Logger logger;
 38  
 
 39  
     protected AbstractMavenExecutor()
 40  176
     {
 41  176
     }
 42  
 
 43  
     /** {@inheritDoc} */
 44  
     public void executeGoals( File workingDirectory, String goals, boolean interactive, String additionalArguments,
 45  
                               String pomFileName, ReleaseResult result )
 46  
         throws MavenExecutorException
 47  
     {
 48  2
         executeGoals( workingDirectory, goals, new DefaultReleaseEnvironment(), interactive, additionalArguments, pomFileName, result );
 49  2
     }
 50  
 
 51  
     /** {@inheritDoc} */
 52  
     public void executeGoals( File workingDirectory, String goals, boolean interactive, String additionalArguments,
 53  
                               ReleaseResult result )
 54  
         throws MavenExecutorException
 55  
     {
 56  22
         executeGoals( workingDirectory, goals, new DefaultReleaseEnvironment(), interactive, additionalArguments, result );
 57  18
     }
 58  
 
 59  
     /** {@inheritDoc} */
 60  
     public void executeGoals( File workingDirectory, String goals, ReleaseEnvironment releaseEnvironment,
 61  
                               boolean interactive, String arguments, ReleaseResult result )
 62  
         throws MavenExecutorException
 63  
     {
 64  22
         executeGoals( workingDirectory, goals, releaseEnvironment, interactive, arguments, null, result );
 65  18
     }
 66  
 
 67  
     /** {@inheritDoc} */
 68  
     public void executeGoals( File workingDirectory, String goals, ReleaseEnvironment releaseEnvironment,
 69  
                               boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result )
 70  
         throws MavenExecutorException
 71  
     {
 72  24
         List<String> goalsList = new ArrayList<String>();
 73  24
         if ( goals != null )
 74  
         {
 75  
             // accept both space and comma, so the old way still work
 76  
             // also accept line separators, so that goal lists can be spread
 77  
             // across multiple lines in the POM.
 78  22
             String[] tokens = StringUtils.split( goals, ", \n\r\t" );
 79  
 
 80  66
             for ( int i = 0; i < tokens.length; ++i )
 81  
             {
 82  44
                 goalsList.add( tokens[i] );
 83  
             }
 84  
         }
 85  24
         executeGoals( workingDirectory, goalsList, releaseEnvironment, interactive, additionalArguments, pomFileName, result );
 86  20
     }
 87  
 
 88  
     protected abstract void executeGoals( File workingDirectory, List<String> goals, ReleaseEnvironment releaseEnvironment,
 89  
                               boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result )
 90  
         throws MavenExecutorException;
 91  
 
 92  
 
 93  
     protected final Logger getLogger()
 94  
     {
 95  10
         return logger;
 96  
     }
 97  
 
 98  
     /** {@inheritDoc} */
 99  
     public void enableLogging( Logger logger )
 100  
     {
 101  174
         this.logger = logger;
 102  174
     }
 103  
 }