@@ -276,10 +276,10 @@ public void execute() throws MojoExecutionException {
276
276
}
277
277
278
278
askTheUserForMissingValues ();
279
- if (projectArtifactId != DEFAULT_ARTIFACT_ID && !OK_ID .matcher (projectArtifactId ).matches ()) {
279
+ if (! DEFAULT_ARTIFACT_ID . equals ( projectArtifactId ) && !OK_ID .matcher (projectArtifactId ).matches ()) {
280
280
throw new MojoExecutionException (String .format (BAD_IDENTIFIER , "artifactId" , projectArtifactId ));
281
281
}
282
- if (projectGroupId != DEFAULT_GROUP_ID && !OK_ID .matcher (projectGroupId ).matches ()) {
282
+ if (! DEFAULT_GROUP_ID . equals ( projectGroupId ) && !OK_ID .matcher (projectGroupId ).matches ()) {
283
283
throw new MojoExecutionException (String .format (BAD_IDENTIFIER , "groupId" , projectGroupId ));
284
284
}
285
285
@@ -389,16 +389,7 @@ private void askTheUserForMissingValues() throws MojoExecutionException {
389
389
// If the user has disabled the interactive mode or if the user has specified the artifactId, disable the
390
390
// user interactions.
391
391
if (!session .getRequest ().isInteractiveMode () || shouldUseDefaults ()) {
392
- if (isBlank (projectArtifactId )) {
393
- // we need to set it for the project directory
394
- projectArtifactId = DEFAULT_ARTIFACT_ID ;
395
- }
396
- if (isBlank (projectGroupId )) {
397
- projectGroupId = DEFAULT_GROUP_ID ;
398
- }
399
- if (isBlank (projectVersion )) {
400
- projectVersion = DEFAULT_VERSION ;
401
- }
392
+ setProperDefaults ();
402
393
return ;
403
394
}
404
395
@@ -427,12 +418,27 @@ private void askTheUserForMissingValues() throws MojoExecutionException {
427
418
input -> noCode = input .startsWith ("n" ));
428
419
429
420
prompter .collectInput ();
421
+ } else {
422
+ setProperDefaults ();
430
423
}
431
424
} catch (IOException e ) {
432
425
throw new MojoExecutionException ("Unable to get user input" , e );
433
426
}
434
427
}
435
428
429
+ private void setProperDefaults () {
430
+ if (isBlank (projectArtifactId )) {
431
+ // we need to set it for the project directory
432
+ projectArtifactId = DEFAULT_ARTIFACT_ID ;
433
+ }
434
+ if (isBlank (projectGroupId )) {
435
+ projectGroupId = DEFAULT_GROUP_ID ;
436
+ }
437
+ if (isBlank (projectVersion )) {
438
+ projectVersion = DEFAULT_VERSION ;
439
+ }
440
+ }
441
+
436
442
private boolean shouldUseDefaults () {
437
443
// Must be called before user input
438
444
return projectArtifactId != null ;
0 commit comments