Coverage Report - org.apache.maven.plugins.patchtracker.PatchToIssueMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
PatchToIssueMojo
0 %
0/21
N/A
7
 
 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.http.impl.client.DefaultHttpClient;
 23  
 import org.apache.maven.plugin.MojoExecutionException;
 24  
 import org.apache.maven.plugin.MojoFailureException;
 25  
 import org.apache.maven.plugins.patchtracker.patching.PatchRepository;
 26  
 import org.apache.maven.plugins.patchtracker.patching.PatchRepositoryException;
 27  
 import org.apache.maven.plugins.patchtracker.patching.PatchRepositoryRequest;
 28  
 import org.apache.maven.plugins.patchtracker.patching.PatchRepositoryResult;
 29  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTracker;
 30  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerException;
 31  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerRequest;
 32  
 import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerResult;
 33  
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 34  
 
 35  
 
 36  
 /**
 37  
  * @author Olivier Lamy
 38  
  * @goal to-issue
 39  
  * @aggregator
 40  
  */
 41  0
 public class PatchToIssueMojo
 42  
     extends AbstractPatchMojo
 43  
 {
 44  
 
 45  
     /**
 46  
      * for github user/organization  : github.com/apache use apache
 47  
      *
 48  
      * @parameter expression="${patch.request.organisation}" default-value=""
 49  
      */
 50  
     protected String organisation;
 51  
 
 52  
     /**
 53  
      * github repo  : github.com/apache/maven-3 use maven-3
 54  
      *
 55  
      * @parameter expression="${patch.request.repository}" default-value=""
 56  
      */
 57  
     protected String repository;
 58  
 
 59  
     /**
 60  
      * for github: pull request id
 61  
      *
 62  
      * @parameter expression="${patch.request.id}" default-value=""
 63  
      */
 64  
     protected String id;
 65  
 
 66  
 
 67  
     /**
 68  
      * for github api url https://api.github.com
 69  
      *
 70  
      * @parameter expression="${patch.patchSystem.url}" default-value="${project.patchManagement.url}"
 71  
      */
 72  
     protected String patchSystemUrl;
 73  
 
 74  
 
 75  0
     DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
 76  
 
 77  
     public void execute()
 78  
         throws MojoExecutionException, MojoFailureException
 79  
     {
 80  
 
 81  
         try
 82  
         {
 83  0
             PatchRepositoryRequest patchRepositoryRequest =
 84  
                 new PatchRepositoryRequest().setUrl( patchSystemUrl ).setRepository( repository ).setId(
 85  
                     id ).setOrganization( organisation );
 86  
 
 87  0
             PatchRepository patchRepository = getPatchRepository();
 88  
 
 89  0
             PatchRepositoryResult result = patchRepository.getPatch( patchRepositoryRequest, getLog() );
 90  
 
 91  0
             PatchTrackerRequest patchTrackerRequest = buidPatchTrackerRequest( false );
 92  
 
 93  0
             patchTrackerRequest.setSummary( result.getTitle() );
 94  
 
 95  0
             patchTrackerRequest.setDescription( result.getDescription() + ". url: " + result.getPatchUrl() );
 96  
 
 97  0
             patchTrackerRequest.setPatchContent( result.getPatchContent() );
 98  
 
 99  0
             getLog().debug( "patchTrackerRequest:" + patchTrackerRequest.toString() );
 100  
 
 101  0
             PatchTracker patchTracker = getPatchTracker();
 102  
 
 103  0
             PatchTrackerResult patchTrackerResult = patchTracker.createPatch( patchTrackerRequest, getLog() );
 104  0
             getLog().info( "issue created with id:" + patchTrackerResult.getPatchId() + ", url:"
 105  
                                + patchTrackerResult.getPatchUrl() );
 106  
 
 107  
         }
 108  0
         catch ( ComponentLookupException e )
 109  
         {
 110  0
             throw new MojoExecutionException( e.getMessage(), e );
 111  
         }
 112  0
         catch ( PatchRepositoryException e )
 113  
         {
 114  0
             throw new MojoExecutionException( e.getMessage(), e );
 115  
         }
 116  0
         catch ( PatchTrackerException e )
 117  
         {
 118  0
             throw new MojoExecutionException( e.getMessage(), e );
 119  0
         }
 120  0
     }
 121  
 
 122  
 }