List of usage examples for org.springframework.boot.cli.command.init InitializrServiceMetadata getProjectTypes
Map<String, ProjectType> getProjectTypes()
From source file:org.springframework.boot.cli.command.init.ServiceCapabilitiesReportGenerator.java
private void reportAvilableProjectTypes(InitializrServiceMetadata metadata, StringBuilder report) { report.append("Available project types:" + NEW_LINE); report.append("------------------------" + NEW_LINE); List<String> typeIds = new ArrayList<String>(metadata.getProjectTypes().keySet()); Collections.sort(typeIds);// w w w . ja v a 2s . co m for (String typeId : typeIds) { ProjectType type = metadata.getProjectTypes().get(typeId); report.append(typeId + " - " + type.getName()); if (!type.getTags().isEmpty()) { reportTags(report, type); } if (type.isDefaultType()) { report.append(" (default)"); } report.append(NEW_LINE); } }
From source file:org.springframework.boot.cli.command.init.ProjectGenerationRequest.java
protected ProjectType determineProjectType(InitializrServiceMetadata metadata) { if (this.type != null) { ProjectType result = metadata.getProjectTypes().get(this.type); if (result == null) { throw new ReportableException( ("No project type with id '" + this.type + "' - check the service capabilities (--list)")); }// ww w. j av a2 s.com return result; } else if (isDetectType()) { Map<String, ProjectType> types = new HashMap<>(metadata.getProjectTypes()); if (this.build != null) { filter(types, "build", this.build); } if (this.format != null) { filter(types, "format", this.format); } if (types.size() == 1) { return types.values().iterator().next(); } else if (types.isEmpty()) { throw new ReportableException("No type found with build '" + this.build + "' and format '" + this.format + "' check the service capabilities (--list)"); } else { throw new ReportableException("Multiple types found with build '" + this.build + "' and format '" + this.format + "' use --type with a more specific value " + types.keySet()); } } else { ProjectType defaultType = metadata.getDefaultType(); if (defaultType == null) { throw new ReportableException(("No project type is set and no default is defined. " + "Check the service capabilities (--list)")); } return defaultType; } }