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 | 0 | 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 | 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 | |
|
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 | |
} |