1 package org.apache.maven.plugins.patchtracker;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
33
34
35
36
37
38 public class UpdatePatchMojo
39 extends AbstractPatchMojo
40 {
41
42
43
44
45 protected String patchId;
46
47
48 public void execute()
49 throws MojoExecutionException
50 {
51
52 try
53 {
54
55
56 String patchContent = getPatchContent();
57
58 PatchTrackerRequest patchTrackerRequest = buidPatchTrackerRequest( false );
59
60 patchTrackerRequest.setPatchId( getPatchId() ).setPatchContent( patchContent ).setDescription(
61 getPatchTrackerDescription() );
62
63 getLog().debug( patchTrackerRequest.toString() );
64 PatchTracker patchTracker = getPatchTracker();
65 PatchTrackerResult result = patchTracker.updatePatch( patchTrackerRequest, getLog() );
66 getLog().info( "issue updated with id:" + result.getPatchId() + ", url:" + result.getPatchUrl() );
67 }
68 catch ( ComponentLookupException e )
69 {
70 throw new MojoExecutionException( e.getMessage(), e );
71 }
72 catch ( PatchTrackerException e )
73 {
74 throw new MojoExecutionException( e.getMessage(), e );
75 }
76 catch ( PrompterException e )
77 {
78 throw new MojoExecutionException( e.getMessage(), e );
79 }
80
81
82 }
83
84 protected String getPatchId()
85 throws PrompterException, MojoExecutionException
86 {
87 String value = null;
88
89
90 if ( StringUtils.isNotEmpty( patchId ) )
91 {
92 value = patchId;
93 }
94
95 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 }