@@ -49,10 +49,9 @@ public abstract class ContributionTask extends DefaultTask {
49
49
@ Inject
50
50
protected abstract FileSystemOperations getFileSystemOperations ();
51
51
52
- private Path gradlew ;
53
-
54
52
private final ObjectMapper objectMapper = new ObjectMapper ().enable (SerializationFeature .INDENT_OUTPUT ).setSerializationInclusion (JsonInclude .Include .NON_NULL );
55
53
54
+ private Path gradlew ;
56
55
private Path testsDirectory ;
57
56
private Path metadataDirectory ;
58
57
@@ -166,7 +165,7 @@ private void checkPackages(Path testsPath) throws ContributingException {
166
165
try {
167
166
FilesUtils .findJavaFiles (testsPath , javaFiles );
168
167
} catch (IOException e ) {
169
- throw new ContributingException ("Cannot find java files. Reason: " + e );
168
+ throw new ContributingException ("Cannot find Java files. Reason: " + e );
170
169
}
171
170
172
171
for (Path file : javaFiles ) {
@@ -211,71 +210,29 @@ private Path getResourcesLocation(){
211
210
212
211
private List <String > getDockerImages () {
213
212
ContributingQuestion question = questions .get ("docker" );
214
-
215
- List <String > images = new ArrayList <>();
216
- while (true ) {
217
- String nextImage = InteractiveTaskUtils .askQuestion (question .question (), question .help (), answer -> {
218
- if (!answer .equalsIgnoreCase ("-" ) && answer .split (":" ).length != 2 ) {
219
- throw new ContributingException ("Docker image name not provided in the correct format. Type help for explanation." );
220
- }
221
-
222
- return answer ;
223
- });
224
-
225
- if (nextImage .trim ().equalsIgnoreCase ("-" )) {
226
- break ;
213
+ return InteractiveTaskUtils .askRecurringQuestions (question .question (), question .help (), 0 , answer -> {
214
+ if (answer .split (":" ).length != 2 ) {
215
+ throw new ContributingException ("Docker image name not provided in the correct format. Type help for explanation." );
227
216
}
228
217
229
- images .add (nextImage );
230
- }
231
-
232
- return images ;
218
+ return answer ;
219
+ });
233
220
}
234
221
235
222
private List <String > getAllowedPackages () {
236
223
ContributingQuestion question = questions .get ("allowedPackages" );
237
- List <String > packages = new ArrayList <>();
238
- while (true ) {
239
- String nextPackage = InteractiveTaskUtils .askQuestion (question .question (), question .help (), answer -> answer );
240
- if (nextPackage .trim ().equalsIgnoreCase ("-" )) {
241
- if (packages .isEmpty ()) {
242
- InteractiveTaskUtils .printErrorMessage ("At least one package must be provided. Type help for explanation." );
243
- continue ;
244
- }
245
-
246
- break ;
247
- }
248
-
249
- packages .add (nextPackage );
250
- }
251
-
252
- return packages ;
224
+ return InteractiveTaskUtils .askRecurringQuestions (question .question (), question .help (), 1 , answer -> answer );
253
225
}
254
226
255
227
private List <Coordinates > getAdditionalDependencies () {
256
228
ContributingQuestion question = questions .get ("additionalDependencies" );
257
- List <Coordinates > dependencies = new ArrayList <>();
258
- while (true ) {
259
- Coordinates dependency = InteractiveTaskUtils .askQuestion (question .question (), question .help (), answer -> {
260
- if (answer .equalsIgnoreCase ("-" )) {
261
- return null ;
262
- }
263
-
264
- try {
265
- return CoordinateUtils .fromString (answer );
266
- } catch (IllegalArgumentException ex ) {
267
- throw new ContributingException (ex .getMessage ());
268
- }
269
- });
270
-
271
- if (dependency == null ) {
272
- break ;
229
+ return InteractiveTaskUtils .askRecurringQuestions (question .question (), question .help (), 0 , answer -> {
230
+ try {
231
+ return CoordinateUtils .fromString (answer );
232
+ } catch (IllegalArgumentException ex ) {
233
+ throw new ContributingException (ex .getMessage ());
273
234
}
274
-
275
- dependencies .add (dependency );
276
- }
277
-
278
- return dependencies ;
235
+ });
279
236
}
280
237
281
238
private void createStubs (boolean shouldUpdate ){
0 commit comments