Skip to content

Commit 5adf3d0

Browse files
committed
Support specific package name using command flag 'package-name'
Closes gh-957
1 parent 101a7a7 commit 5adf3d0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

grace-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
9494
public static final String FORCE_FLAG = 'force'
9595
public static final String GRACE_VERSION_FLAG = 'grace-version'
9696
public static final String BOOT_VERSION_FLAG = 'boot-version'
97+
public static final String PACKAGE_NAME_FLAG = 'package-name'
9798

9899
public static final String[] SUPPORT_GRACE_VERSIONS = ['2023', '2022', '6', '5', '4', '3']
99100
public static final String[] SUPPORT_SPRING_BOOT_VERSIONS = ['3.3', '3.4']
@@ -112,6 +113,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
112113
CreateAppCommand() {
113114
populateDescription()
114115
description.flag(name: INPLACE_FLAG, description: 'Used to create an application using the current directory')
116+
description.flag(name: PACKAGE_NAME_FLAG, description: 'The Package name', required: false)
115117
description.flag(name: PROFILE_FLAG, description: 'The profile to use', required: false)
116118
description.flag(name: FEATURES_FLAG, description: 'The features to use', required: false)
117119
description.flag(name: TEMPLATE_FLAG, description: 'The application template to use', required: false)
@@ -205,7 +207,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
205207
String profileName = commandLine.optionValue('profile')?.toString() ?: getDefaultProfile()
206208

207209
List<String> validFlags = [INPLACE_FLAG, PROFILE_FLAG, FEATURES_FLAG, TEMPLATE_FLAG,
208-
CSS_FLAG, JAVASCRIPT_FLAG, DATABASE_FLAG,
210+
CSS_FLAG, JAVASCRIPT_FLAG, DATABASE_FLAG, PACKAGE_NAME_FLAG,
209211
STACKTRACE_ARGUMENT, VERBOSE_ARGUMENT, QUIET_ARGUMENT,
210212
GRACE_VERSION_FLAG, BOOT_VERSION_FLAG, MINIMAL_FLAG, FORCE_FLAG]
211213
if (!commandLine.hasOption(ENABLE_PREVIEW_FLAG)) {
@@ -235,6 +237,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
235237

236238
CreateAppCommandObject cmd = new CreateAppCommandObject(
237239
appName: appName,
240+
packageName: commandLine.optionValue(PACKAGE_NAME_FLAG),
238241
baseDir: executionContext.baseDir,
239242
profileName: profileName,
240243
grailsVersion: specificGraceVersion ?: grailsVersion,
@@ -319,6 +322,8 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
319322
groupName = parts[0..-2].join('.')
320323
defaultPackageName = groupName
321324
}
325+
groupName = cmd.packageName ?: groupName
326+
defaultPackageName = cmd.packageName ?: defaultPackageName
322327
}
323328
catch (IllegalArgumentException e) {
324329
console.error(e.message)
@@ -1490,6 +1495,7 @@ group """
14901495
static class CreateAppCommandObject {
14911496

14921497
String appName
1498+
String packageName
14931499
File baseDir
14941500
String profileName
14951501
String grailsVersion

0 commit comments

Comments
 (0)