mirror of
https://gitee.com/dcren/initializr.git
synced 2025-04-05 17:38:06 +08:00
Polish
See gh-1370
This commit is contained in:
parent
10d22bc534
commit
71cdc06911
@ -18,6 +18,8 @@ package io.spring.initializr.actuate.stat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.spring.initializr.actuate.stat.ProjectRequestDocument.ClientInformation;
|
||||
@ -38,9 +40,12 @@ import org.springframework.util.StringUtils;
|
||||
* Create {@link ProjectRequestDocument} instances.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class ProjectRequestDocumentFactory {
|
||||
|
||||
private static final Pattern PROJECT_TYPE_PATTERN = Pattern.compile("([a-z]*)-[a-z-]*");
|
||||
|
||||
public ProjectRequestDocument createDocument(ProjectRequestEvent event) {
|
||||
InitializrMetadata metadata = event.getMetadata();
|
||||
ProjectRequest request = event.getProjectRequest();
|
||||
@ -97,9 +102,11 @@ public class ProjectRequestDocumentFactory {
|
||||
}
|
||||
|
||||
private String determineBuildSystem(ProjectRequest request) {
|
||||
String type = request.getType();
|
||||
String[] elements = type.split("-");
|
||||
return (elements.length >= 2) ? elements[0] : null;
|
||||
Matcher typeMatcher = PROJECT_TYPE_PATTERN.matcher(request.getType());
|
||||
if (typeMatcher.matches()) {
|
||||
return typeMatcher.group(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private VersionInformation determineVersionInformation(ProjectRequest request) {
|
||||
|
@ -185,7 +185,7 @@ class ProjectGenerationStatPublisherTests {
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.setGroupId("com.example.acme");
|
||||
request.setArtifactId("test");
|
||||
request.setType("not-a-type");
|
||||
request.setType("not_a_type");
|
||||
request.setBootVersion("2.1.0.RELEASE");
|
||||
request.setDependencies(Arrays.asList("web", "data-jpa"));
|
||||
request.setLanguage("java");
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"generationTimestamp": 0,
|
||||
"type": "not-a-type",
|
||||
"type": "not_a_type",
|
||||
"groupId": "com.example.acme",
|
||||
"artifactId": "test",
|
||||
"javaVersion": "1.8",
|
||||
|
Loading…
Reference in New Issue
Block a user