Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add Helidon runtime #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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) {
Expand All @@ -127,13 +132,29 @@ 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"
}

if (!runtime.equalsIgnoreCase("open-liberty")) {
// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<include>images/jakartaee_logo.jpg</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/helidon</directory>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory></directory>
<includes>
Expand Down
9 changes: 9 additions & 0 deletions archetype/src/main/resources/archetype-resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 9 additions & 3 deletions archetype/src/main/resources/archetype-resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ 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
```

#if ((${runtime} == 'payara') && (${profile} != 'full'))
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
Expand All @@ -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
Expand Down
62 changes: 61 additions & 1 deletion archetype/src/main/resources/archetype-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -45,10 +46,22 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

#if (${runtime} == 'helidon')
<parent>
<groupId>io.helidon.applications</groupId>
<artifactId>helidon-mp</artifactId>
<version>${helidonVersion}</version>
<relativePath/>
</parent>
#end
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
#if (${runtime} == 'helidon')
<packaging>jar</packaging>
#else
<packaging>war</packaging>
#end

<name>${artifactId}</name>
<description>
Expand All @@ -75,7 +88,9 @@
<wildfly.version>${wildflyVersion}</wildfly.version>
#end
<compiler-plugin.version>3.13.0</compiler-plugin.version>
#if (${runtime} != 'helidon')
<war-plugin.version>3.4.0</war-plugin.version>
#end
#if ((${runtime} == 'glassfish') || ((${runtime} == 'payara') && (${profile} == 'full')))
<cargo.version>1.10.15</cargo.version>
#end
Expand Down Expand Up @@ -108,6 +123,31 @@
<version>${payara.version}</version>
<scope>provided</scope>
</dependency>
#end
#if (${runtime} == 'helidon')
<dependency>
<groupId>io.helidon.microprofile.bundles</groupId>
<artifactId>helidon-microprofile-core</artifactId>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.helidon.logging</groupId>
<artifactId>helidon-logging-jul</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>jandex</artifactId>
<scope>runtime</scope>
</dependency>
#end
</dependencies>

Expand All @@ -119,14 +159,15 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
#if (${runtime} != 'helidon')
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

#end
#if (${runtime} == 'glassfish')
<!-- Execute 'mvn clean package cargo:run' to run the application. -->
<plugin>
Expand Down Expand Up @@ -214,6 +255,25 @@
<artifactId>liberty-maven-plugin</artifactId>
<version>${liberty-plugin.version}</version>
</plugin>
#elseif (${runtime} == 'helidon')
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libs</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.smallrye</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<executions>
<execution>
<id>make-index</id>
</execution>
</executions>
</plugin>
#end
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
version="4.0"
bean-discovery-mode="all">
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server.port=8080
server.host=0.0.0.0
server.static.classpath.location=/WEB/
server.static.classpath.welcome=index.html
Original file line number Diff line number Diff line change
@@ -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
29 changes: 27 additions & 2 deletions ui/src/main/java/org/eclipse/starter/ui/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Project implements Serializable {
private static final Logger LOGGER = Logger.getLogger(MethodHandles.lookup().lookupClass().getName());
private static final Map<String, String> 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";

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);

Expand All @@ -199,6 +201,7 @@ public void onJakartaVersionChange() {
}

runtimes.get("wildfly").setDisabled(false);
runtimes.get("helidon").setDisabled(false);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
}
}

Expand Down