Skip to content

Commit

Permalink
Fixs code review
Browse files Browse the repository at this point in the history
  • Loading branch information
netodevel committed Nov 24, 2021
1 parent 86030b3 commit 345b2a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ version = "{project.version}"

{#insert java}
java {
{#if java.version == "11"}
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
{#else if java.version == "17"}
{#if java.version == "17"}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
{#else}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
{/if}
}
{/}
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ version '{project.version}'

{#insert java}
java {
{#if java.version == "11"}
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
{#else if java.version == "17"}
{#if java.version == "17"}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
{#else}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
{/if}
}
{/}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.nio.file.Path;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -20,7 +19,7 @@

public class CreateProjectHelper {

private static final List<String> JAVA_VERSIONS_LTS = List.of("11", "17");
private static final Set<String> JAVA_VERSIONS_LTS = Set.of("11", "17");
private static final String DEFAULT_JAVA_VERSION = "11";
private static final Pattern JAVA_VERSION_PATTERN = Pattern.compile("(?:1\\.)?(\\d+)(?:\\..*)?");

Expand Down Expand Up @@ -85,9 +84,7 @@ public static void setJavaVersion(Map<String, Object> values, String javaTarget)

if (matcher.matches()) {
String versionExtracted = matcher.group(1);
String version = JAVA_VERSIONS_LTS.stream()
.filter(e -> e.equals(versionExtracted))
.findFirst().orElse(DEFAULT_JAVA_VERSION);
String version = JAVA_VERSIONS_LTS.contains(versionExtracted) ? versionExtracted : DEFAULT_JAVA_VERSION;
values.put(ProjectGenerator.JAVA_TARGET, version);
} else {
values.put(ProjectGenerator.JAVA_TARGET, DEFAULT_JAVA_VERSION);
Expand Down

0 comments on commit 345b2a5

Please sign in to comment.