Skip to content

Commit

Permalink
Stream java versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Nov 29, 2023
1 parent b621b1e commit 9fc7c32
Show file tree
Hide file tree
Showing 29 changed files with 252 additions and 118 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/acceptance-test.tests.actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
- name: Set up JDK 21
# Uses sha for added security since tags can be updated
uses: joschi/setup-jdk@e87a7cec853d2dd7066adf837fe12bf0f3d45e52
with:
java-version: openjdk17
java-version: openjdk21
- name: Cache Maven Repository
id: cache-maven
uses: actions/cache@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/api.tests.actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
- name: Set up JDK 21
# Uses sha for added security since tags can be updated
uses: joschi/setup-jdk@e87a7cec853d2dd7066adf837fe12bf0f3d45e52
with:
java-version: openjdk17
java-version: openjdk21
- name: Cache Maven Repository
id: cache-maven
uses: actions/cache@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quarkus-ecosystem.actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
ECOSYSTEM_CI_REPO: quarkusio/quarkus-ecosystem-ci
ECOSYSTEM_CI_REPO_FILE: context.yaml
JAVA_VERSION: 17
JAVA_VERSION: 21

#########################
# Repo specific setting #
Expand Down
5 changes: 5 additions & 0 deletions .quarkus/cli/plugins/quarkus-cli-catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version" : "v1",
"lastUpdate" : "21/11/2023 09:29:31",
"plugins" : { }
}
6 changes: 3 additions & 3 deletions acceptance-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<properties>
<compiler-plugin.version>3.10.0</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

Expand All @@ -18,7 +18,7 @@

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.version>3.5.1</quarkus.platform.version>
<quarkus.platform.version>3.6.0</quarkus.platform.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions acceptance-test/src/main/docker/Dockerfile.multistage
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Stage 1 : build with maven builder image
FROM registry.access.redhat.com/ubi8/openjdk-17:1.14 AS build
FROM registry.access.redhat.com/ubi8/openjdk-21:1.18 AS build
ARG MAVEN_BUILD_EXTRA_ARGS=
RUN echo "$MAVEN_BUILD_EXTRA_ARGS"
COPY pom.xml mvnw /usr/src/app/
Expand All @@ -14,7 +14,7 @@ RUN cd /usr/src/app/ && ./mvnw clean package -DskipTests $MAVEN_BUILD_EXTRA_ARGS
## Stage 2 : create the docker final image
FROM mcr.microsoft.com/playwright:v1.29.2-focal

ARG JAVA_PACKAGE=openjdk-17-jre-headless
ARG JAVA_PACKAGE=openjdk-21-jre-headless
ARG MAVEN_EXTRA_ARGS=
RUN echo "$MAVEN_EXTRA_ARGS"

Expand Down
10 changes: 5 additions & 5 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<properties>
<kotlin.compiler.jvmTarget>17</kotlin.compiler.jvmTarget>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<rest-assured.version>4.3.2</rest-assured.version>
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>

Expand All @@ -27,11 +27,11 @@
<!-- Quarkus platform used for the code.quarkus app-->
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.version>3.5.1</quarkus.platform.version>
<quarkus.platform.version>3.6.0</quarkus.platform.version>

<!-- Quarkus devtools version -->
<quarkus.devtools.version>3.5.1</quarkus.devtools.version>
<quarkus.base-codestarts.version>3.5.1</quarkus.base-codestarts.version>
<quarkus.devtools.version>3.6.0</quarkus.devtools.version>
<quarkus.base-codestarts.version>3.6.0</quarkus.base-codestarts.version>

<!-- Quarkiverse versions -->
<quarkus.jgit.version>2.3.1</quarkus.jgit.version>
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/docker/Dockerfile.multistage
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Stage 1 : build with maven builder image
FROM registry.access.redhat.com/ubi8/openjdk-17:1.17 AS build
FROM registry.access.redhat.com/ubi8/openjdk-21:1.18 AS build
ARG MAVEN_BUILD_EXTRA_ARGS=
RUN echo "$MAVEN_BUILD_EXTRA_ARGS"
COPY mvnw pom.xml maven-settings.xml* /usr/src/app/
Expand All @@ -12,7 +12,7 @@ USER 185
RUN cd /usr/src/app/ && ./mvnw clean package $MAVEN_BUILD_EXTRA_ARGS

## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/openjdk-17:1.17
FROM registry.access.redhat.com/ubi8/openjdk-21:1.18

ARG MAVEN_EXTRA_ARGS=
RUN echo "$MAVEN_EXTRA_ARGS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class ProjectDefinition(val streamKey: String? = null,
val className: String? = null,
val path: String? = null,
val buildTool: String = DEFAULT_BUILDTOOL,
val javaVersion: String = DEFAULT_JAVA_VERSION,
val javaVersion: Int? = null,
val noCode: Boolean = DEFAULT_NO_CODE,
val noExamples: Boolean = DEFAULT_NO_CODE,
val extensions: Set<String> = setOf()) {
Expand All @@ -27,9 +27,7 @@ data class ProjectDefinition(val streamKey: String? = null,
const val DEFAULT_VERSION = "1.0.0-SNAPSHOT"
const val DEFAULT_BUILDTOOL = "MAVEN"
const val DEFAULT_NO_CODE = false
const val DEFAULT_JAVA_VERSION = "17"

const val JAVA_VERSION_PATTERN = "^(?:1\\.)?(\\d+)(?:\\..*)?\$";
const val GROUPID_PATTERN = "^([a-zA-Z_\$][a-zA-Z\\d_\$]*\\.)*[a-zA-Z_\$][a-zA-Z\\d_\$]*\$"
const val ARTIFACTID_PATTERN = "^[a-z][a-z0-9-._]*\$"
const val CLASSNAME_PATTERN = GROUPID_PATTERN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import io.quarkus.code.model.ProjectDefinition.Companion.CLASSNAME_PATTERN
import io.quarkus.code.model.ProjectDefinition.Companion.DEFAULT_ARTIFACTID
import io.quarkus.code.model.ProjectDefinition.Companion.DEFAULT_BUILDTOOL
import io.quarkus.code.model.ProjectDefinition.Companion.DEFAULT_GROUPID
import io.quarkus.code.model.ProjectDefinition.Companion.DEFAULT_JAVA_VERSION
import io.quarkus.code.model.ProjectDefinition.Companion.DEFAULT_NO_CODE
import io.quarkus.code.model.ProjectDefinition.Companion.DEFAULT_VERSION
import io.quarkus.code.model.ProjectDefinition.Companion.GROUPID_PATTERN
import io.quarkus.code.model.ProjectDefinition.Companion.JAVA_VERSION_PATTERN
import io.quarkus.code.model.ProjectDefinition.Companion.PATH_PATTERN
import org.eclipse.microprofile.openapi.annotations.media.Schema
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter
Expand Down Expand Up @@ -94,12 +92,9 @@ class ProjectDefinitionQuery {
private set

@QueryParam("j")
@NotEmpty
@DefaultValue(DEFAULT_JAVA_VERSION)
@Pattern(regexp = JAVA_VERSION_PATTERN)
@Parameter(name = "j", description = "The Java version for the generation application", required = false)
@Schema(description = "The Java version for the generation application", required = false, pattern = JAVA_VERSION_PATTERN)
var javaVersion: String = DEFAULT_JAVA_VERSION
@Schema(description = "The Java version for the generation application", required = false)
var javaVersion: Int? = null
private set


Expand Down
10 changes: 8 additions & 2 deletions api/src/main/kotlin/io/quarkus/code/model/Stream.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package io.quarkus.code.model

import java.util.SortedSet

data class Stream(
val key: String,
val quarkusCoreVersion: String,
val javaCompatibility: JavaCompatibility,
val platformVersion: String,
val recommended: Boolean,
val status: String
)
val status: String,
val lts: Boolean
) {
data class JavaCompatibility(val versions: SortedSet<Int>, val recommended: Int)
}
15 changes: 8 additions & 7 deletions api/src/main/kotlin/io/quarkus/code/rest/AnalyticsFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,36 +127,37 @@ class AnalyticsFilter : ContainerRequestFilter {
val extensions: Set<String>
val buildTool: String
val streamKey: String?
val javaVersion: String
val javaVersion: Int?
val noCode: Boolean
val recommendedPlatformInfo = platformService.get().recommendedPlatformInfo
if (context.method == "POST") {
val text = context.entityStream.bufferedReader().use(BufferedReader::readText)
context.entityStream = text.byteInputStream()
if (text.isNotBlank()) {
val json = JsonObject(text)
val rawExtensions = json.getJsonArray("extensions", JsonArray()).stream().map { it.toString() }
.collect(Collectors.toSet())
extensions = platformService.get().recommendedPlatformInfo.checkAndMergeExtensions(rawExtensions)
extensions = recommendedPlatformInfo.checkAndMergeExtensions(rawExtensions)
buildTool = json.getString("buildTool", ProjectDefinition.DEFAULT_BUILDTOOL)
javaVersion = json.getString("javaVersion", ProjectDefinition.DEFAULT_JAVA_VERSION)
javaVersion = json.getInteger("javaVersion")
streamKey = json.getString("streamKey")
noCode = json.getBoolean("noCode", ProjectDefinition.DEFAULT_NO_CODE)
} else {
extensions = emptySet()
buildTool = ProjectDefinition.DEFAULT_BUILDTOOL
streamKey = null
javaVersion = ProjectDefinition.DEFAULT_JAVA_VERSION
javaVersion = null
noCode = ProjectDefinition.DEFAULT_NO_CODE
}
} else {
extensions =
platformService.get().recommendedPlatformInfo.checkAndMergeExtensions(queryParams["e"]?.toSet())
recommendedPlatformInfo.checkAndMergeExtensions(queryParams["e"]?.toSet())
buildTool = queryParams.getFirst("b") ?: ProjectDefinition.DEFAULT_BUILDTOOL
streamKey = queryParams.getFirst("S")
javaVersion = queryParams.getFirst("j") ?: ProjectDefinition.DEFAULT_JAVA_VERSION
javaVersion = queryParams.getFirst("j")?.toInt()
noCode = queryParams.getFirst("nc")?.toBoolean() ?: ProjectDefinition.DEFAULT_NO_CODE
}
val resolvedStreamKey = platformService.get().getPlatformInfo(streamKey).streamKey
val resolvedStreamKey = platformService.get().getPlatformInfo(streamKey).stream.key
return mapOf(
"buildTool" to buildTool,
"extensions" to extensions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ class CodeQuarkusResource @Inject constructor(
if (projectDefinition.buildTool != ProjectDefinition.DEFAULT_BUILDTOOL) {
params.add(BasicNameValuePair("b", projectDefinition.buildTool))
}
if (projectDefinition.javaVersion != ProjectDefinition.DEFAULT_JAVA_VERSION) {
params.add(BasicNameValuePair("j", projectDefinition.javaVersion))
if (projectDefinition.javaVersion != null) {
params.add(BasicNameValuePair("j", projectDefinition.javaVersion.toString()))
}
if (projectDefinition.noCode != ProjectDefinition.DEFAULT_NO_CODE || projectDefinition.noExamples != ProjectDefinition.DEFAULT_NO_CODE) {
params.add(BasicNameValuePair("nc", (!ProjectDefinition.DEFAULT_NO_CODE).toString()))
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/kotlin/io/quarkus/code/service/PlatformInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package io.quarkus.code.service
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import io.quarkus.code.misc.QuarkusExtensionUtils
import io.quarkus.code.model.CodeQuarkusExtension
import io.quarkus.code.model.Stream
import io.quarkus.registry.catalog.ExtensionCatalog
import java.util.logging.Logger
import java.util.stream.Collectors

@JsonIgnoreProperties(ignoreUnknown = true)
class PlatformInfo(
val platformKey: String,
val streamKey: String,
val stream: Stream,
val quarkusCoreVersion: String,
val platformVersion: String,
val recommended: Boolean,
Expand Down
45 changes: 32 additions & 13 deletions api/src/main/kotlin/io/quarkus/code/service/PlatformService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import io.quarkus.devtools.project.QuarkusProjectHelper
import io.quarkus.code.model.CodeQuarkusExtension
import io.quarkus.code.model.ProjectDefinition
import io.quarkus.code.model.Stream
import io.quarkus.devtools.project.JavaVersion
import io.quarkus.devtools.project.JavaVersion.getCompatibleLTSVersions
import io.quarkus.platform.catalog.processor.CatalogProcessor
import io.quarkus.platform.catalog.processor.CatalogProcessor.getMinimumJavaVersion
import io.quarkus.platform.catalog.processor.CatalogProcessor.getRecommendedJavaVersion
import io.quarkus.registry.Constants
import java.util.HashMap
import io.quarkus.registry.catalog.PlatformCatalog
Expand Down Expand Up @@ -130,22 +135,36 @@ class PlatformService {
val platformKey = platform.platformKey
val streamId = stream.id
val streamKey = createStreamKey(platformKey, streamId)
val lts = stream.metadata["lts"] as Boolean
val minimumJavaVersion = getMinimumJavaVersion(extensionCatalog)

val compatibleJavaLTSVersions = getCompatibleLTSVersions(JavaVersion(minimumJavaVersion))
if (platformKey.equals("com.redhat.quarkus.platform")) {
// Hack to remove 21 support from code.quarkus.redhat.com
compatibleJavaLTSVersions.remove(21)
}
val recommendedJavaVersion = getRecommendedJavaVersion(extensionCatalog)?.toInt() ?: compatibleJavaLTSVersions.first()
val quarkusCoreVersion = stream.recommendedRelease.quarkusCoreVersion
val recommended = stream.id == platform.recommendedStream.id
val streamInfo = Stream(
key = streamKey,
quarkusCoreVersion = quarkusCoreVersion,
platformVersion = stream.recommendedRelease.version.toString(),
recommended = recommended,
status = getStreamStatus(quarkusCoreVersion),
lts = lts,
javaCompatibility = Stream.JavaCompatibility(compatibleJavaLTSVersions, recommendedJavaVersion)
)
val platformInfo = PlatformInfo(
platformKey = platformKey,
streamKey = streamKey,
quarkusCoreVersion = stream.recommendedRelease.quarkusCoreVersion,
quarkusCoreVersion = quarkusCoreVersion,
platformVersion = stream.recommendedRelease.version.toString(),
recommended = (stream.id == platform.recommendedStream.id),
recommended = recommended,
codeQuarkusExtensions = codeQuarkusExtensions,
extensionCatalog = extensionCatalog
extensionCatalog = extensionCatalog,
stream = streamInfo
)
streams.add(Stream(
key = streamKey,
quarkusCoreVersion = platformInfo.quarkusCoreVersion,
platformVersion = stream.recommendedRelease.version.toString(),
recommended = platformInfo.recommended,
status = getStreamStatus(platformInfo)
))
streams.add(streamInfo)
updatedStreamCatalogMap[streamKey] = platformInfo
}
}
Expand Down Expand Up @@ -218,8 +237,8 @@ class PlatformService {

}

private fun getStreamStatus(platformInfo: PlatformInfo): String {
val qualifier = DefaultArtifactVersion(platformInfo.quarkusCoreVersion).qualifier?.uppercase()
private fun getStreamStatus(quarkusCoreVersion: String): String {
val qualifier = DefaultArtifactVersion(quarkusCoreVersion).qualifier?.uppercase()
return if (qualifier.isNullOrBlank()) "FINAL" else qualifier
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package io.quarkus.code.service
import io.quarkus.code.model.ProjectDefinition
import io.quarkus.devtools.codestarts.CodestartException
import io.quarkus.devtools.commands.CreateProject
import io.quarkus.devtools.commands.data.QuarkusCommandException
import io.quarkus.devtools.messagewriter.MessageWriter
import io.quarkus.devtools.project.BuildTool
import io.quarkus.devtools.project.JavaVersion
import io.quarkus.devtools.project.QuarkusProjectHelper
import io.quarkus.devtools.project.SourceType
import io.quarkus.devtools.project.compress.QuarkusProjectCompress
import jakarta.inject.Singleton
import java.io.IOException
import java.io.OutputStream
import java.io.PrintStream
import java.nio.file.Files
import java.nio.file.Path
import java.util.logging.Logger
import jakarta.inject.Singleton

@Singleton
open class QuarkusProjectService {
Expand Down Expand Up @@ -50,9 +50,19 @@ open class QuarkusProjectService {
platformInfo.checkAndMergeExtensions(projectDefinition.extensions)
val buildTool = BuildTool.valueOf(projectDefinition.buildTool)
val codestarts = HashSet<String>()
/**if (gitHub) {
codestarts.add("github-action")
}**/
val javaVersionString = (projectDefinition.javaVersion ?: platformInfo.stream.javaCompatibility.recommended).toString()
if (gitHub) {
codestarts.add("tooling-github-action")
}
val javaVersion = JavaVersion(javaVersionString)
if (javaVersion.isPresent && !platformInfo.stream.javaCompatibility.versions.contains(javaVersion.asInt)) {
throw IllegalArgumentException("This Java version is not compatible with this stream (${platformInfo.stream.javaCompatibility.versions}): $javaVersionString");
}
val isJava = extensions.stream()
.noneMatch{ it.startsWith("io.quarkus:quarkus-kotlin") || it.startsWith("io.quarkus:quarkus-scala") }
if (javaVersion.isPresent && !isJava && javaVersion.asInt > JavaVersion.MAX_LTS_SUPPORTED_BY_KOTLIN) {
throw IllegalArgumentException("This Java version is not yet compatible with Kotlin and Scala using Quarkus (max:${JavaVersion.MAX_LTS_SUPPORTED_BY_KOTLIN}): $javaVersionString");
}
val messageWriter =
if (silent) MessageWriter.info(PrintStream(OutputStream.nullOutputStream())) else MessageWriter.info()
try {
Expand All @@ -61,7 +71,7 @@ open class QuarkusProjectService {
projectFolderPath,
platformInfo.extensionCatalog,
buildTool,
JavaVersion(projectDefinition.javaVersion),
javaVersion,
messageWriter
)
val projectDefinition = CreateProject(project)
Expand All @@ -70,7 +80,7 @@ open class QuarkusProjectService {
.version(projectDefinition.version)
.resourcePath(projectDefinition.path)
.extraCodestarts(codestarts)
.javaVersion(projectDefinition.javaVersion)
.javaVersion(javaVersion.version)
.resourceClassName(projectDefinition.className)
.extensions(extensions)
.noCode(projectDefinition.noCode || projectDefinition.noExamples)
Expand Down
Loading

0 comments on commit 9fc7c32

Please sign in to comment.