From 8bd3058b5a8bc4ea84a98d61e8356cc90a34631c Mon Sep 17 00:00:00 2001 From: "Ricardo M." Date: Wed, 2 Oct 2024 15:29:24 +0200 Subject: [PATCH] chore(catalog-generator): Lower the required Java version to 17 Currently, the `catalog-generator` requires Java 21. While that enable modern syntax, not all users have it installed in their machines, so in order to lower the contribution requirements, we're lowering the required version to be Java 17. By default, in RHEL 9.0, Java 17 is preinstalled. Here is an extract of the available Java version per RHEL version | RHEL Version | Java version | Release date | | --- | --- | --- | | RHEL 7 | Java 8 | June 10, 2014 | | RHEL 8 | Java 11 | May 7, 2019 | | RHEL 9 | Java 17 | May 17, 2022 | fix: https://github.com/KaotoIO/kaoto/issues/1476 --- README.md | 2 +- packages/catalog-generator/pom.xml | 28 +++++++++++++--- .../generator/CamelCatalogProcessor.java | 32 ++++++++++++++----- .../commands/GenerateCommandTest.java | 6 ++-- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1c99bfe6b..93325328e 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Have a quick look at our online demo instance: ## Requirements - NodeJS (v18.x or higher) [+info](https://nodejs.org/en) - Yarn (v3.x or higher) [+info](https://yarnpkg.com/getting-started/install) -- OpenJDK (v21 or higher) [+info](https://developers.redhat.com/products/openjdk/download) +- OpenJDK (v17 or higher) [+info](https://developers.redhat.com/products/openjdk/download) _For more information on Vite, check [Vite's documentation](https://vitejs.dev/config/)._ diff --git a/packages/catalog-generator/pom.xml b/packages/catalog-generator/pom.xml index 12cb85ca8..eea4cac5a 100644 --- a/packages/catalog-generator/pom.xml +++ b/packages/catalog-generator/pom.xml @@ -11,10 +11,9 @@ A Camel Catalog generator for Kaoto. https://kaoto.io - 3.13.0 - 21 - 21 - 21 + 17 + 17 + 17 UTF-8 UTF-8 4.8.0 @@ -23,6 +22,7 @@ 2.17.2 5.11.0 6.13.3 + 3.5.0 3.13.0 3.5.0 @@ -160,6 +160,26 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + ${version.maven-enforcer-plugin} + + + enforce-java-version + + enforce + + + + + [17,) + + + + + + maven-compiler-plugin ${version.maven-compiler-plugin} diff --git a/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java b/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java index 0d537da8f..fa95c3be1 100644 --- a/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java +++ b/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java @@ -399,15 +399,31 @@ public String getEntityCatalog() throws Exception { var entityName = entry.getKey(); var entitySchema = entry.getValue(); var entityCatalog = catalogMap.get(entityName); + switch (entityName) { - case "beans" -> processBeansParameters(entitySchema, entityCatalog); - case "from" -> processFromParameters(entitySchema, entityCatalog); - case "route" -> processRouteParameters(entitySchema, entityCatalog); - case "routeTemplate" -> processRouteTemplateParameters(entitySchema, entityCatalog); - case "templatedRoute" -> processTemplatedRouteParameters(entitySchema, entityCatalog); - case "restConfiguration" -> processRestConfigurationParameters(entitySchema, entityCatalog); - case "rest" -> processRestParameters(entitySchema, entityCatalog); - case null, default -> processEntityParameters(entityName, entitySchema, entityCatalog); + case "beans": + processBeansParameters(entitySchema, entityCatalog); + break; + case "from": + processFromParameters(entitySchema, entityCatalog); + break; + case "route": + processRouteParameters(entitySchema, entityCatalog); + break; + case "routeTemplate": + processRouteTemplateParameters(entitySchema, entityCatalog); + break; + case "templatedRoute": + processTemplatedRouteParameters(entitySchema, entityCatalog); + break; + case "restConfiguration": + processRestConfigurationParameters(entitySchema, entityCatalog); + break; + case "rest": + processRestParameters(entitySchema, entityCatalog); + break; + default: + processEntityParameters(entityName, entitySchema, entityCatalog); } sortPropertiesAccordingToCamelCatalog(entitySchema, entityCatalog); diff --git a/packages/catalog-generator/src/test/java/io/kaoto/camelcatalog/commands/GenerateCommandTest.java b/packages/catalog-generator/src/test/java/io/kaoto/camelcatalog/commands/GenerateCommandTest.java index 76b2ecb17..3d5c01bdd 100644 --- a/packages/catalog-generator/src/test/java/io/kaoto/camelcatalog/commands/GenerateCommandTest.java +++ b/packages/catalog-generator/src/test/java/io/kaoto/camelcatalog/commands/GenerateCommandTest.java @@ -59,7 +59,7 @@ void testGeneratorCalledWithCorrectParameters() { })) { generateCommand.run(); - CatalogGeneratorBuilder builder = mockedBuilder.constructed().getFirst(); + CatalogGeneratorBuilder builder = mockedBuilder.constructed().get(0); verify(builder, times(1)).withRuntime(CatalogRuntime.Main); verify(builder, times(1)).withCamelCatalogVersion("4.8.0"); @@ -99,12 +99,12 @@ void testCatalogLibraryOutput() { ) { generateCommand.run(); - CatalogLibrary library = mockedLibrary.constructed().getFirst(); + CatalogLibrary library = mockedLibrary.constructed().get(0); assertEquals(library.getName(), "test-camel-catalog"); assertEquals(library.getDefinitions().size(), 1); - CatalogLibraryEntry catalogLibraryEntry = library.getDefinitions().getFirst(); + CatalogLibraryEntry catalogLibraryEntry = library.getDefinitions().get(0); assertEquals(catalogLibraryEntry.name(), "test-camel-catalog"); assertEquals(catalogLibraryEntry.version(), "4.8.0"); assertEquals(catalogLibraryEntry.runtime(), "Main");