-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for java 17 in generated projects codestart
Adding support to java versions lts Updated template of builds for support java 17 Fixs imports Remove sysout Change codestart dockerfiles to use openjdk-xx-runtime Remove no longer needed RUN_JAVA_VERSION Fixs code formatting
- Loading branch information
Showing
8 changed files
with
57 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
...urces/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.jvm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
{#include Dockerfile-layout type='jvm'} | ||
{#quarkusbuild}{buildtool.cli} {buildtool.cmd.package}{/quarkusbuild} | ||
{#image}{dockerfile.jvm.from} {/image} | ||
{#args} | ||
ARG JAVA_PACKAGE={dockerfile.jvm.java-package} | ||
ARG RUN_JAVA_VERSION={dockerfile.jvm.run-java-version} | ||
{/args} | ||
{#copy} | ||
# We make four distinct layers so if there are application changes the library layers can be re-used | ||
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/lib/ /deployments/lib/ | ||
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/*.jar /deployments/ | ||
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/app/ /deployments/app/ | ||
COPY --chown=1001 {buildtool.build-dir}/quarkus-app/quarkus/ /deployments/quarkus/ | ||
COPY --chown=185 {buildtool.build-dir}/quarkus-app/lib/ /deployments/lib/ | ||
COPY --chown=185 {buildtool.build-dir}/quarkus-app/*.jar /deployments/ | ||
COPY --chown=185 {buildtool.build-dir}/quarkus-app/app/ /deployments/app/ | ||
COPY --chown=185 {buildtool.build-dir}/quarkus-app/quarkus/ /deployments/quarkus/ | ||
{/copy} | ||
{/include} | ||
|
7 changes: 1 addition & 6 deletions
7
...odestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.legacy-jar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
{#include Dockerfile-layout type='legacy-jar'} | ||
{#quarkusbuild}{buildtool.cli} {buildtool.cmd.package-legacy-jar}{/quarkusbuild} | ||
{#image}{dockerfile.legacy-jar.from} {/image} | ||
{#args} | ||
ARG JAVA_PACKAGE={dockerfile.legacy-jar.java-package} | ||
ARG RUN_JAVA_VERSION={dockerfile.legacy-jar.run-java-version} | ||
{/args} | ||
{#copy} | ||
COPY {buildtool.build-dir}/lib/* /deployments/lib/ | ||
COPY {buildtool.build-dir}/*-runner.jar /deployments/app.jar | ||
COPY {buildtool.build-dir}/*-runner.jar /deployments/quarkus-run.jar | ||
{/copy} | ||
{/include} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
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; | ||
|
@@ -18,6 +19,9 @@ | |
import javax.lang.model.SourceVersion; | ||
|
||
public class CreateProjectHelper { | ||
|
||
private static final List<Integer> JAVA_VERSIONS_LTS = List.of(8, 11, 17); | ||
This comment has been minimized.
Sorry, something went wrong.
maxandersen
Member
|
||
private static final int DEFAULT_JAVA_VERSION = 11; | ||
private static final Pattern JAVA_VERSION_PATTERN = Pattern.compile("(?:1\\.)?(\\d+)(?:\\..*)?"); | ||
|
||
public static final String DEFAULT_GROUP_ID = "org.acme"; | ||
|
@@ -78,10 +82,16 @@ public static void setJavaVersion(Map<String, Object> values, String javaTarget) | |
|
||
Matcher matcher = JAVA_VERSION_PATTERN | ||
.matcher(javaTarget != null ? javaTarget : System.getProperty("java.version", "")); | ||
if (matcher.matches() && Integer.parseInt(matcher.group(1)) < 11) { | ||
values.put(ProjectGenerator.JAVA_TARGET, "8"); | ||
|
||
if (matcher.matches()) { | ||
int versionExtracted = Integer.parseInt(matcher.group(1)); | ||
int version = JAVA_VERSIONS_LTS.stream() | ||
.filter(e -> e.equals(versionExtracted)) | ||
.findFirst().orElse(DEFAULT_JAVA_VERSION); | ||
|
||
values.put(ProjectGenerator.JAVA_TARGET, String.valueOf(version)); | ||
} else { | ||
values.put(ProjectGenerator.JAVA_TARGET, "11"); | ||
values.put(ProjectGenerator.JAVA_TARGET, String.valueOf(DEFAULT_JAVA_VERSION)); | ||
} | ||
} | ||
|
||
|
28 changes: 28 additions & 0 deletions
28
...ols-common/src/test/java/io/quarkus/devtools/project/codegen/CreateProjectHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkus.devtools.project.codegen; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class CreateProjectHelperTest { | ||
|
||
@Test | ||
public void givenJavaVersion17ShouldReturn17() { | ||
Map<String, Object> values = new HashMap<>(); | ||
values.put("nonull", "nonull"); | ||
|
||
CreateProjectHelper.setJavaVersion(values, "17"); | ||
assertEquals("17", values.get("java_target")); | ||
} | ||
|
||
@Test | ||
public void givenJavaVersion16ShouldReturn11() { | ||
Map<String, Object> values = new HashMap<>(); | ||
values.put("nonull", "nonull"); | ||
|
||
CreateProjectHelper.setJavaVersion(values, "16.0.1"); | ||
assertEquals("11", values.get("java_target")); | ||
} | ||
} |
should this not continue to be image so it continue to function with older clis?