Add package-name option for spring init
For some reason, we forgot to add an attribute to customize the package name when using spring init. This is now the case. Closes gh-3716
This commit is contained in:
@@ -89,10 +89,12 @@ public class InitCommand extends OptionParsingCommand {
|
||||
|
||||
private OptionSpec<String> description;
|
||||
|
||||
private OptionSpec<String> packaging;
|
||||
private OptionSpec<String> packageName;
|
||||
|
||||
private OptionSpec<String> type;
|
||||
|
||||
private OptionSpec<String> packaging;
|
||||
|
||||
private OptionSpec<String> build;
|
||||
|
||||
private OptionSpec<String> format;
|
||||
@@ -140,13 +142,14 @@ public class InitCommand extends OptionParsingCommand {
|
||||
"Project name; infer application name").withRequiredArg();
|
||||
this.description = option("description", "Project description")
|
||||
.withRequiredArg();
|
||||
this.packaging = option(Arrays.asList("packaging", "p"),
|
||||
"Project packaging (for example 'jar')").withRequiredArg();
|
||||
this.packageName = option("package-name", "Package name").withRequiredArg();
|
||||
this.type = option(
|
||||
Arrays.asList("type", "t"),
|
||||
"Project type. Not normally needed if you use --build "
|
||||
+ "and/or --format. Check the capabilities of the service "
|
||||
+ "(--list) for more details").withRequiredArg();
|
||||
this.packaging = option(Arrays.asList("packaging", "p"),
|
||||
"Project packaging (for example 'jar')").withRequiredArg();
|
||||
this.build = option("build",
|
||||
"Build system to use (for example 'maven' or 'gradle')")
|
||||
.withRequiredArg().defaultsTo("maven");
|
||||
@@ -226,8 +229,8 @@ public class InitCommand extends OptionParsingCommand {
|
||||
if (options.has(this.javaVersion)) {
|
||||
request.setJavaVersion(options.valueOf(this.javaVersion));
|
||||
}
|
||||
if (options.has(this.packaging)) {
|
||||
request.setPackaging(options.valueOf(this.packaging));
|
||||
if (options.has(this.packageName)) {
|
||||
request.setPackageName(options.valueOf(this.packageName));
|
||||
}
|
||||
request.setBuild(options.valueOf(this.build));
|
||||
request.setFormat(options.valueOf(this.format));
|
||||
@@ -235,6 +238,9 @@ public class InitCommand extends OptionParsingCommand {
|
||||
if (options.has(this.type)) {
|
||||
request.setType(options.valueOf(this.type));
|
||||
}
|
||||
if (options.has(this.packaging)) {
|
||||
request.setPackaging(options.valueOf(this.packaging));
|
||||
}
|
||||
if (options.has(this.language)) {
|
||||
request.setLanguage(options.valueOf(this.language));
|
||||
}
|
||||
|
||||
@@ -54,10 +54,12 @@ class ProjectGenerationRequest {
|
||||
|
||||
private String description;
|
||||
|
||||
private String packaging;
|
||||
private String packageName;
|
||||
|
||||
private String type;
|
||||
|
||||
private String packaging;
|
||||
|
||||
private String build;
|
||||
|
||||
private String format;
|
||||
@@ -178,15 +180,15 @@ class ProjectGenerationRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* The packaging type or {@code null} if it should not be customized.
|
||||
* @return the packaging type or {@code null}
|
||||
* Return the package name or {@code null} if it should not be customized.
|
||||
* @return the package name or {@code null}
|
||||
*/
|
||||
public String getPackaging() {
|
||||
return this.packaging;
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackaging(String packaging) {
|
||||
this.packaging = packaging;
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,6 +204,18 @@ class ProjectGenerationRequest {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The packaging type or {@code null} if it should not be customized.
|
||||
* @return the packaging type or {@code null}
|
||||
*/
|
||||
public String getPackaging() {
|
||||
return this.packaging;
|
||||
}
|
||||
|
||||
public void setPackaging(String packaging) {
|
||||
this.packaging = packaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* The build type to use. Ignored if a type is set. Can be used alongside the
|
||||
* {@link #getFormat() format} to identify the type to use.
|
||||
@@ -322,12 +336,15 @@ class ProjectGenerationRequest {
|
||||
if (this.description != null) {
|
||||
builder.setParameter("description", this.description);
|
||||
}
|
||||
if (this.packaging != null) {
|
||||
builder.setParameter("packaging", this.packaging);
|
||||
if (this.packageName != null) {
|
||||
builder.setParameter("packageName", this.packageName);
|
||||
}
|
||||
if (this.type != null) {
|
||||
builder.setParameter("type", projectType.getId());
|
||||
}
|
||||
if (this.packaging != null) {
|
||||
builder.setParameter("packaging", this.packaging);
|
||||
}
|
||||
if (this.javaVersion != null) {
|
||||
builder.setParameter("javaVersion", this.javaVersion);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user