22
22
import java .net .MalformedURLException ;
23
23
import java .net .URL ;
24
24
import java .util .ArrayList ;
25
- import java .util .HashMap ;
25
+ import java .util .Collection ;
26
26
import java .util .List ;
27
- import java .util .Map ;
28
27
29
28
import org .apache .maven .plugin .logging .Log ;
30
29
import org .apache .maven .plugins .issues .Issue ;
35
34
import org .apache .maven .settings .crypto .DefaultSettingsDecryptionRequest ;
36
35
import org .apache .maven .settings .crypto .SettingsDecrypter ;
37
36
import org .apache .maven .settings .crypto .SettingsDecryptionResult ;
38
- import org .eclipse .egit .github .core .Label ;
39
- import org .eclipse .egit .github .core .client .GitHubClient ;
40
- import org .eclipse .egit .github .core .service .IssueService ;
37
+ import org .kohsuke .github .GHIssue ;
38
+ import org .kohsuke .github .GHIssueState ;
39
+ import org .kohsuke .github .GHLabel ;
40
+ import org .kohsuke .github .GitHubBuilder ;
41
41
42
42
/**
43
43
* @since 2.8
@@ -47,7 +47,7 @@ public class GitHubDownloader {
47
47
/**
48
48
* The github client.
49
49
*/
50
- private GitHubClient client ;
50
+ private GitHubBuilder client ;
51
51
52
52
/**
53
53
* A boolean to indicate if we should include open issues as well
@@ -80,7 +80,7 @@ public GitHubDownloader(
80
80
int githubPort ,
81
81
boolean includeOpenIssues ,
82
82
boolean onlyMilestoneIssues )
83
- throws MalformedURLException {
83
+ throws IOException {
84
84
this .includeOpenIssues = includeOpenIssues ;
85
85
this .onlyMilestoneIssues = onlyMilestoneIssues ;
86
86
@@ -89,9 +89,9 @@ public GitHubDownloader(
89
89
// The githubclient prefers to connect to 'github.com' using the api domain, unlike github enterprise
90
90
// which can connect fine using its domain, so for github.com use empty constructor
91
91
if (githubURL .getHost ().equalsIgnoreCase ("github.com" )) {
92
- this .client = new GitHubClient ();
92
+ this .client = new GitHubBuilder ();
93
93
} else {
94
- this .client = new GitHubClient ( githubURL .getHost (), githubPort , githubScheme );
94
+ this .client = new GitHubBuilder (). withEndpoint ( githubScheme + githubURL .getHost () + githubPort );
95
95
}
96
96
97
97
this .githubIssueURL = project .getIssueManagement ().getUrl ();
@@ -119,7 +119,7 @@ public GitHubDownloader(
119
119
this .githubRepo = urlPathParts [1 ];
120
120
}
121
121
122
- protected Issue createIssue (org . eclipse . egit . github . core . Issue githubIssue ) {
122
+ protected Issue createIssue (GHIssue githubIssue ) throws IOException {
123
123
Issue issue = new Issue ();
124
124
125
125
issue .setKey (String .valueOf (githubIssue .getNumber ()));
@@ -155,9 +155,9 @@ protected Issue createIssue(org.eclipse.egit.github.core.Issue githubIssue) {
155
155
issue .setStatus ("open" );
156
156
}
157
157
158
- List < Label > labels = githubIssue .getLabels ();
158
+ final Collection < GHLabel > labels = githubIssue .getLabels ();
159
159
if (labels != null && !labels .isEmpty ()) {
160
- issue .setType (labels .get (0 ).getName ());
160
+ issue .setType (labels .stream (). findAny (). get ().getName ());
161
161
}
162
162
163
163
return issue ;
@@ -166,24 +166,20 @@ protected Issue createIssue(org.eclipse.egit.github.core.Issue githubIssue) {
166
166
public List <Issue > getIssueList () throws IOException {
167
167
List <Issue > issueList = new ArrayList <>();
168
168
169
- IssueService service = new IssueService (client );
170
- Map <String , String > issueFilter = new HashMap <>();
171
-
172
169
if (includeOpenIssues ) {
173
- // Adding open issues
174
-
175
- for (org . eclipse . egit . github . core . Issue issue : service . getIssues ( githubOwner , githubRepo , issueFilter ) ) {
170
+ final List < GHIssue > openIssues =
171
+ client . build (). getRepository ( githubOwner + "/" + githubRepo ). getIssues ( GHIssueState . OPEN );
172
+ for (final GHIssue issue : openIssues ) {
176
173
if (!onlyMilestoneIssues || issue .getMilestone () != null ) {
177
174
issueList .add (createIssue (issue ));
178
175
}
179
176
}
180
177
}
181
178
182
- // Adding closed issues
183
-
184
- issueFilter .put ("state" , "closed" );
179
+ final List <GHIssue > closedIssues =
180
+ client .build ().getRepository (githubOwner + "/" + githubRepo ).getIssues (GHIssueState .CLOSED );
185
181
186
- for (org . eclipse . egit . github . core . Issue issue : service . getIssues ( githubOwner , githubRepo , issueFilter ) ) {
182
+ for (final GHIssue issue : closedIssues ) {
187
183
if (!onlyMilestoneIssues || issue .getMilestone () != null ) {
188
184
issueList .add (createIssue (issue ));
189
185
}
@@ -207,7 +203,7 @@ public void configureAuthentication(
207
203
server = result .getServer ();
208
204
String user = server .getUsername ();
209
205
String password = server .getPassword ();
210
- this .client .setCredentials (user , password );
206
+ this .client .withPassword (user , password );
211
207
212
208
configured = true ;
213
209
break ;
0 commit comments