diff --git a/archetype/src/main/resources/META-INF/archetype-post-generate.groovy b/archetype/src/main/resources/META-INF/archetype-post-generate.groovy index eeaaf6b9..0843a9bd 100644 --- a/archetype/src/main/resources/META-INF/archetype-post-generate.groovy +++ b/archetype/src/main/resources/META-INF/archetype-post-generate.groovy @@ -26,19 +26,17 @@ private validateInput(jakartaVersion, profile, javaVersion, runtime, docker, Fil throw new RuntimeException("Failed, valid Jakarta EE versions are 8, 9, 9.1, and 10") } - if (!profile.equalsIgnoreCase("core") && !profile.equalsIgnoreCase("web") && !profile.equalsIgnoreCase("full")) { + if (!["core", "web", "full"].contains(profile.toLowerCase())) { FileUtils.forceDelete(outputDirectory) throw new RuntimeException("Failed, valid Jakarta EE profiles are core, web, and full") } - if ((javaVersion != '8') && (javaVersion != '11') && (javaVersion != '17')) { + if (!['8', '11', '17', '21'].contains(javaVersion)) { FileUtils.forceDelete(outputDirectory) throw new RuntimeException("Failed, valid Java SE versions are 8, 11, and 17") } - if (!runtime.equalsIgnoreCase("none") && !runtime.equalsIgnoreCase("glassfish") - && !runtime.equalsIgnoreCase("open-liberty") && !runtime.equalsIgnoreCase("payara") - && !runtime.equalsIgnoreCase("tomee") && !runtime.equalsIgnoreCase("wildfly")) { + if (!["none", "glassfish", "open-liberty", "payara", "tomee", "wildfly", "helidon"].contains(runtime.toLowerCase())) { FileUtils.forceDelete(outputDirectory) throw new RuntimeException("Failed, valid runtime values are none, glassfish, open-liberty, payara, tomee, and wildfly") } @@ -103,6 +101,13 @@ private validateInput(jakartaVersion, profile, javaVersion, runtime, docker, Fil throw new RuntimeException("Failed, WildFly does not offer a release for Jakarta EE 9 or Jakarta EE 9.1") } } + + if (runtime.equalsIgnoreCase("helidon")) { + if (jakartaVersion != '10' && javaVersion != '21' && profile != 'core') { + FileUtils.forceDelete(outputDirectory) + throw new RuntimeException("Failed, Helidon offer a release for Jakarta EE 10 Core profile only") + } + } } private generateRuntime(runtime, jakartaVersion, docker, File outputDirectory) { @@ -127,6 +132,17 @@ private generateRuntime(runtime, jakartaVersion, docker, File outputDirectory) { case "open-liberty": println "Generating code for Open Liberty" break + case "helidon": println "Generating code for Helidon" + var helidonDir = new File(outputDirectory, "src/main/helidon") + var resourcesDir = new File(outputDirectory, "src/main/resources") + var webappDir = new File(outputDirectory,"src/main/webapp"); + FileUtils.forceDelete(new File(webappDir, "/WEB-INF")) + FileUtils.copyDirectory(new File(helidonDir, "resources"), resourcesDir) + FileUtils.copyDirectory(webappDir, new File(resourcesDir, "/WEB")) + FileUtils.forceDelete(webappDir) + FileUtils.forceDelete(helidonDir) + break + default: println "No runtime will be included in the sample" } @@ -134,6 +150,11 @@ private generateRuntime(runtime, jakartaVersion, docker, File outputDirectory) { // We do not need the liberty configuration directory, let's delete it. FileUtils.forceDelete(new File(outputDirectory, "src/main/liberty")) } + + if (!runtime.equalsIgnoreCase("helidon")) { + // We do not need the helidon configuration directory, let's delete it. + FileUtils.forceDelete(new File(outputDirectory, "src/main/helidon")) + } } static void bindEEPackage(String jakartaVersion, File outputDirectory) throws IOException { diff --git a/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 54592e60..e3ae5b6c 100644 --- a/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -59,6 +59,9 @@ images/jakartaee_logo.jpg + + src/main/helidon + diff --git a/archetype/src/main/resources/archetype-resources/Dockerfile b/archetype/src/main/resources/archetype-resources/Dockerfile index f30159ae..945ec4fc 100644 --- a/archetype/src/main/resources/archetype-resources/Dockerfile +++ b/archetype/src/main/resources/archetype-resources/Dockerfile @@ -81,11 +81,20 @@ #end #set ($deployDirectory = "/config/apps/") #end +#if (${runtime} == 'helidon') +#set ($baseImage = "container-registry.oracle.com/java/jdk-no-fee-term:21") +#end FROM $baseImage #if (${runtime} == 'open-liberty') COPY src/main/liberty/config/server.xml /config/server.xml #end +#if (${runtime} == 'helidon') +COPY target/libs ./libs +COPY target/${artifactId}.jar ./ +CMD ["java", "-jar", "${artifactId}.jar"] +#else COPY target/${artifactId}.war $deployDirectory +#end #if ((${runtime} == 'wildfly') && (${profile} == 'full')) CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0", "-c","standalone-full.xml"] #end \ No newline at end of file diff --git a/archetype/src/main/resources/archetype-resources/README.md b/archetype/src/main/resources/archetype-resources/README.md index c87fc77d..d950680d 100644 --- a/archetype/src/main/resources/archetype-resources/README.md +++ b/archetype/src/main/resources/archetype-resources/README.md @@ -16,6 +16,8 @@ You can run the application by executing the following command from the director ./mvnw clean package wildfly:dev #elseif (${runtime} == 'open-liberty') ./mvnw liberty:dev +#elseif (${runtime} == 'helidon') +./mvnw clean package && java -jar ./target/${artifactId}.jar #end ``` @@ -23,6 +25,8 @@ You can run the application by executing the following command from the director Once the runtime starts, you can access the project at [http://localhost:8080](http://localhost:8080). #elseif (${runtime} == 'open-liberty') Once the runtime starts, you can access the project at [http://localhost:9080](http://localhost:9080). +#elseif (${runtime} == 'helidon') +Once the runtime starts, you can access the project at [http://localhost:8080/](http://localhost:8080/). #else Once the runtime starts, you can access the project at [http://localhost:8080/${artifactId}](http://localhost:8080/${artifactId}). #end @@ -45,10 +49,12 @@ docker run -it --rm -p 9080:9080 ${artifactId}:v1 #end ``` -#if (${runtime} != 'open-liberty') -Once the runtime starts, you can access the project at [http://localhost:8080/${artifactId}](http://localhost:8080/${artifactId}). -#else +#if (${runtime} == 'open-liberty') Once the runtime starts, you can access the project at [http://localhost:9080/](http://localhost:9080/). +#elseif (${runtime} == 'helidon') +Once the runtime starts, you can access the project at [http://localhost:8080/](http://localhost:8080/). +#else +Once the runtime starts, you can access the project at [http://localhost:8080/${artifactId}](http://localhost:8080/${artifactId}). #end #end #else diff --git a/archetype/src/main/resources/archetype-resources/pom.xml b/archetype/src/main/resources/archetype-resources/pom.xml index 48dd1f15..eefe7a4f 100644 --- a/archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetype/src/main/resources/archetype-resources/pom.xml @@ -9,6 +9,7 @@ #set ($wildflyConfiguration = "standalone-full") #end #if (${jakartaVersion} == '10') +#set ($helidonVersion = "4.1.2") #set ($eeApiVersion = "10.0.0") #elseif (${jakartaVersion} == '9.1') #set ($eeApiVersion = "9.1.0") @@ -45,10 +46,22 @@ 4.0.0 +#if (${runtime} == 'helidon') + + io.helidon.applications + helidon-mp + ${helidonVersion} + + +#end ${groupId} ${artifactId} ${version} +#if (${runtime} == 'helidon') + jar +#else war +#end ${artifactId} @@ -75,7 +88,9 @@ ${wildflyVersion} #end 3.13.0 +#if (${runtime} != 'helidon') 3.4.0 +#end #if ((${runtime} == 'glassfish') || ((${runtime} == 'payara') && (${profile} == 'full'))) 1.10.15 #end @@ -108,6 +123,31 @@ ${payara.version} provided +#end +#if (${runtime} == 'helidon') + + io.helidon.microprofile.bundles + helidon-microprofile-core + + + jakarta.json.bind + jakarta.json.bind-api + + + org.glassfish.jersey.media + jersey-media-json-binding + runtime + + + io.helidon.logging + helidon-logging-jul + runtime + + + io.smallrye + jandex + runtime + #end @@ -119,6 +159,7 @@ maven-compiler-plugin ${compiler-plugin.version} +#if (${runtime} != 'helidon') maven-war-plugin ${war-plugin.version} @@ -126,7 +167,7 @@ false - +#end #if (${runtime} == 'glassfish') @@ -214,6 +255,25 @@ liberty-maven-plugin ${liberty-plugin.version} +#elseif (${runtime} == 'helidon') + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-libs + + + + + io.smallrye + jandex-maven-plugin + + + make-index + + + #end diff --git a/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/META-INF/beans.xml b/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/META-INF/beans.xml new file mode 100644 index 00000000..54a38d04 --- /dev/null +++ b/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/META-INF/beans.xml @@ -0,0 +1,8 @@ + + + diff --git a/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/META-INF/microprofile-config.properties b/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/META-INF/microprofile-config.properties new file mode 100644 index 00000000..64bab704 --- /dev/null +++ b/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/META-INF/microprofile-config.properties @@ -0,0 +1,4 @@ +server.port=8080 +server.host=0.0.0.0 +server.static.classpath.location=/WEB/ +server.static.classpath.welcome=index.html \ No newline at end of file diff --git a/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/logging.properties b/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/logging.properties new file mode 100644 index 00000000..09b37076 --- /dev/null +++ b/archetype/src/main/resources/archetype-resources/src/main/helidon/resources/logging.properties @@ -0,0 +1,17 @@ +# Example Logging Configuration File +# For more information see $JAVA_HOME/jre/lib/logging.properties + +# Send messages to the console +handlers=io.helidon.logging.jul.HelidonConsoleHandler + +# HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread +java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n + +# Global logging level. Can be overridden by specific loggers +.level=INFO + +# Component specific log levels +#io.helidon.webserver.level=INFO +#io.helidon.config.level=INFO +#io.helidon.security.level=INFO +#io.helidon.common.level=INFO diff --git a/ui/src/main/java/org/eclipse/starter/ui/Project.java b/ui/src/main/java/org/eclipse/starter/ui/Project.java index 1fb5d005..bdc185c6 100644 --- a/ui/src/main/java/org/eclipse/starter/ui/Project.java +++ b/ui/src/main/java/org/eclipse/starter/ui/Project.java @@ -33,7 +33,7 @@ public class Project implements Serializable { private static final Logger LOGGER = Logger.getLogger(MethodHandles.lookup().lookupClass().getName()); private static final Map RUNTIMES = Map.ofEntries(entry("glassfish", "GlassFish"), entry("open-liberty", "Open Liberty"), entry("payara", "Payara"), entry("tomee", "TomEE"), - entry("wildfly", "WildFly")); + entry("wildfly", "WildFly"), entry("helidon", "Helidon")); private static final String DEFAULT_GROUPID = "org.eclipse"; private static final String DEFAULT_ARTIFACTID = "jakartaee-hello-world"; @@ -73,6 +73,7 @@ public Project() { profiles.put("web", new SelectItem("web", "Web Profile")); profiles.put("core", new SelectItem("core", "Core Profile")); + javaVersions.put("21", new SelectItem("21", "Java SE 21")); javaVersions.put("17", new SelectItem("17", "Java SE 17")); javaVersions.put("11", new SelectItem("11", "Java SE 11")); javaVersions.put("8", new SelectItem("8", "Java SE 8", "Java SE 8", true)); @@ -191,6 +192,7 @@ public void onJakartaVersionChange() { runtimes.get("payara").setDisabled(true); runtimes.get("glassfish").setDisabled(true); } + runtimes.get("helidon").setDisabled(true); } else { javaVersions.get("8").setDisabled(true); @@ -199,6 +201,7 @@ public void onJakartaVersionChange() { } runtimes.get("wildfly").setDisabled(false); + runtimes.get("helidon").setDisabled(false); } } @@ -243,8 +246,12 @@ public void onProfileChange() { runtimes.get("glassfish").setDisabled(true); runtimes.get("tomee").setDisabled(true); + runtimes.get("helidon").setDisabled(false); } else if (profile.equals("full")) { runtimes.get("tomee").setDisabled(true); + runtimes.get("helidon").setDisabled(true); + } else { + runtimes.get("helidon").setDisabled(true); } } @@ -312,6 +319,10 @@ public void onRuntimeChange() { LOGGER.log(Level.INFO, "Validating form for Jakarta EE version: {0}, Jakarta EE profile: {1}, Java SE version: {2}, Docker: {3}, runtime: {4}", new Object[] { jakartaVersion, profile, javaVersion, docker, runtime }); + javaVersions.forEach((s, i) -> i.setDisabled(false)); + jakartaVersions.forEach((s, i) -> i.setDisabled(false)); + jakartaVersions.forEach((s, i) -> i.setDisabled(false)); + if (!profile.equals("core")) { jakartaVersions.get("9").setDisabled(false); jakartaVersions.get("9.1").setDisabled(false); @@ -361,7 +372,21 @@ public void onRuntimeChange() { if (jakartaVersion != 8) { javaVersions.get("8").setDisabled(true); - } + } + } else if (runtime.equals("helidon")) { + jakartaVersions.get("9").setDisabled(true); + profiles.get("web").setDisabled(true); + profiles.get("full").setDisabled(true); + javaVersions.get("8").setDisabled(true); + javaVersions.get("11").setDisabled(true); + javaVersions.get("17").setDisabled(true); + jakartaVersions.get("8").setDisabled(true); + jakartaVersions.get("9").setDisabled(true); + jakartaVersions.get("9.1").setDisabled(true); + // these are the only choices so far + jakartaVersion = 10; + javaVersion = 21; + profile = "core"; } }