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:
Brian Clozel 2023-01-30 19:49:12 +01:00
parent 7ea72e72d9
commit 10d22bc534
2 changed files with 13 additions and 3 deletions

View File

@ -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");
* you may not use this file except in compliance with the License.
@ -99,7 +99,7 @@ public class ProjectRequestDocumentFactory {
private String determineBuildSystem(ProjectRequest request) {
String type = request.getType();
String[] elements = type.split("-");
return (elements.length == 2) ? elements[0] : null;
return (elements.length >= 2) ? elements[0] : null;
}
private VersionInformation determineVersionInformation(ProjectRequest request) {

View File

@ -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");
* you may not use this file except in compliance with the License.
@ -217,6 +217,16 @@ class ProjectRequestDocumentFactoryTests {
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
void createDocumentInvalidDependency() {
ProjectRequest request = createProjectRequest();