Coverage Report - org.apache.maven.plugins.patchtracker.UpdatePatchMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdatePatchMojo
0 %
0/20
0 %
0/2
4,5
 
 1  
 package org.apache.maven.plugins.patchtracker;
 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.commons.lang.StringUtils;
 23  
 import org.apache.maven.plugin.MojoExecutionException;
 24  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTracker;
 25  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerException;
 26  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerRequest;
 27  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerResult;
 28  
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 29  
 import org.codehaus.plexus.components.interactivity.PrompterException;
 30  
 
 31  
 /**
 32  
  * Goal which create a diff/patch file from the current project and create an issue in the project
 33  
  * with attaching the created patch file
 34  
  *
 35  
  * @goal update
 36  
  * @aggregator
 37  
  */
 38  0
 public class UpdatePatchMojo
 39  
     extends AbstractPatchMojo
 40  
 {
 41  
 
 42  
     /**
 43  
      * @parameter expression="${patch.patchId}" default-value=""
 44  
      */
 45  
     protected String patchId;
 46  
 
 47  
 
 48  
     public void execute()
 49  
         throws MojoExecutionException
 50  
     {
 51  
 
 52  
         try
 53  
         {
 54  
             // TODO do a status before and complains if some files in to be added status ?
 55  
 
 56  0
             String patchContent = getPatchContent();
 57  
 
 58  0
             PatchTrackerRequest patchTrackerRequest = buidPatchTrackerRequest( false );
 59  
 
 60  0
             patchTrackerRequest.setPatchId( getPatchId() ).setPatchContent( patchContent ).setDescription(
 61  
                 getPatchTrackerDescription() );
 62  
 
 63  0
             getLog().debug( patchTrackerRequest.toString() );
 64  0
             PatchTracker patchTracker = getPatchTracker();
 65  0
             PatchTrackerResult result = patchTracker.updatePatch( patchTrackerRequest, getLog() );
 66  0
             getLog().info( "issue updated with id:" + result.getPatchId() + ", url:" + result.getPatchUrl() );
 67  
         }
 68  0
         catch ( ComponentLookupException e )
 69  
         {
 70  0
             throw new MojoExecutionException( e.getMessage(), e );
 71  
         }
 72  0
         catch ( PatchTrackerException e )
 73  
         {
 74  0
             throw new MojoExecutionException( e.getMessage(), e );
 75  
         }
 76  0
         catch ( PrompterException e )
 77  
         {
 78  0
             throw new MojoExecutionException( e.getMessage(), e );
 79  0
         }
 80  
 
 81  
 
 82  0
     }
 83  
 
 84  
     protected String getPatchId()
 85  
         throws PrompterException, MojoExecutionException
 86  
     {
 87  0
         String value = null;
 88  
 
 89  
         // cli must win !
 90  0
         if ( StringUtils.isNotEmpty( patchId ) )
 91  
         {
 92  0
             value = patchId;
 93  
         }
 94  
 
 95  0
         return getValue( value, "patch id to update ?", null, true,
 96  
                          "you must configure a patch id when updating an issue or at least use interactive mode", value,
 97  
                          false );
 98  
     }
 99  
 
 100  
 
 101  
 }