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.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 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class PatchToIssueMojo |
42 | |
extends AbstractPatchMojo |
43 | |
{ |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
protected String organisation; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
protected String repository; |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
protected String id; |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
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 | |
} |