mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-25 21:22:58 +08:00
Set "gradle" buildSystem for "gradle-project-kotlin" types
Prior to this commit, projects with type "gradle-project-kotlin" would not get the expected "gradle" buildSystem property, unlike the Groovy flavor with "gradle-project". This value would be set as empty. This commit ensures that the detection algorithm supports project types with multiple "-" within their values. Fixes gh-1370
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -99,7 +99,7 @@ public class ProjectRequestDocumentFactory {
|
|||||||
private String determineBuildSystem(ProjectRequest request) {
|
private String determineBuildSystem(ProjectRequest request) {
|
||||||
String type = request.getType();
|
String type = request.getType();
|
||||||
String[] elements = type.split("-");
|
String[] elements = type.split("-");
|
||||||
return (elements.length == 2) ? elements[0] : null;
|
return (elements.length >= 2) ? elements[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VersionInformation determineVersionInformation(ProjectRequest request) {
|
private VersionInformation determineVersionInformation(ProjectRequest request) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -217,6 +217,16 @@ class ProjectRequestDocumentFactoryTests {
|
|||||||
assertThat(document.getErrorState().getDependencies()).isNull();
|
assertThat(document.getErrorState().getDependencies()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void createDocumentExtendedType() {
|
||||||
|
ProjectRequest request = createProjectRequest();
|
||||||
|
request.setType("gradle-project-kotlin");
|
||||||
|
ProjectGeneratedEvent event = createProjectGeneratedEvent(request);
|
||||||
|
ProjectRequestDocument document = this.factory.createDocument(event);
|
||||||
|
assertThat(document.getType()).isEqualTo("gradle-project-kotlin");
|
||||||
|
assertThat(document.getBuildSystem()).isEqualTo("gradle");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createDocumentInvalidDependency() {
|
void createDocumentInvalidDependency() {
|
||||||
ProjectRequest request = createProjectRequest();
|
ProjectRequest request = createProjectRequest();
|
||||||
|
|||||||
Reference in New Issue
Block a user