Skip to content

Commit

Permalink
3.x: Archetype - Backport several issues from 4.x to 3.x (#8564)
Browse files Browse the repository at this point in the history
* Fix Json code duplication

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* Fix archetypes module

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* Add opens WEB to module info for multipart

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* Kubernetes uses ClusterIP instead of NodePort

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* fix sql script for oracle database

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* Archetype generates .gitignore

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* update index.html to match backend endpoint

Signed-off-by: tvallin <thibault.vallin@oracle.com>

---------

Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin authored Mar 26, 2024
1 parent f661067 commit 5d887ff
Show file tree
Hide file tree
Showing 22 changed files with 204 additions and 71 deletions.
1 change: 1 addition & 0 deletions archetypes/helidon/src/main/archetype/common/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<includes>
<include>.helidon.mustache</include>
<include>README.md.mustache</include>
<include>.gitignore.mustache</include>
</includes>
</templates>
<model>
Expand Down
6 changes: 3 additions & 3 deletions archetypes/helidon/src/main/archetype/common/extra.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</includes>
</templates>
<model>
<list key="modules">
<list key="module-requires">
<value>io.helidon.webclient</value>
</list>
</model>
Expand Down Expand Up @@ -67,7 +67,7 @@
<value key="artifactId">helidon-webclient</value>
</map>
</list>
<list key="modules">
<list key="module-requires">
<value if="${flavor} == 'mp'">io.helidon.microprofile.faulttolerance</value>
<value if="${flavor} == 'mp'">io.helidon.common.reactive</value>
<value if="${flavor} == 'se'">io.helidon.faulttolerance</value>
Expand Down Expand Up @@ -154,7 +154,7 @@
.addCrossOrigin(CrossOriginConfig.create())
.build();]]></value>
</list>
<list key="modules">
<list key="module-requires">
<value if="${flavor} == 'mp'">io.helidon.microprofile.cors</value>
<value if="${flavor} == 'se'">io.helidon.webserver.cors</value>
</list>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Compiled class file
*.class

# Maven
target/
.m2/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# IntelliJ Idea
.idea/
*.iws
*.ipr
*.iml
*.releaseBackup
atlassian-ide-plugin.xml

# Netbeans
nbactions.xml
nb-configuration.xml

# Eclipse
.settings
.settings/
.project
.classpath
.factorypath

{{#gitignore}}
{{.}}
{{/gitignore}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ metadata:
labels:
app: {{artifactId}}
spec:
type: NodePort
type: ClusterIP
selector:
app: {{artifactId}}
ports:
- port: 8080
targetPort: 8080
name: http
- name: tcp
port: 8080
protocol: TCP
targetPort: 8080
---
kind: Deployment
apiVersion: apps/v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@

module {{package}} {
{{#modules}}
{{#module-requires}}
requires {{.}};
{{/modules}}
{{/module-requires}}

exports {{package}};

{{#module-opens}}
opens {{.}};
{{/module-opens}}
{{#module-opens-package}}
opens {{package}};
{{/module-opens-package}}
}
44 changes: 25 additions & 19 deletions archetypes/helidon/src/main/archetype/common/media.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022, 2023 Oracle and/or its affiliates.
Copyright (c) 2022, 2024 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,12 +34,6 @@
<option value="jsonp" name="JSON-P" description="Jakarta JSON Processing" if="${flavor} == 'se'">
<output>
<model>
<list key="dependencies">
<map order="500">
<value key="groupId">io.helidon.media</value>
<value key="artifactId">helidon-media-jsonp</value>
</map>
</list>
<list key="Main-helidon-imports">
<value>io.helidon.media.jsonp.JsonpSupport</value>
</list>
Expand All @@ -58,8 +52,7 @@
<list key="WebClient-builder">
<value><![CDATA[ .addMediaSupport(JsonpSupport.create())]]></value>
</list>
<list key="modules">
<value>jakarta.json</value>
<list key="module-requires">
<value>io.helidon.media.jsonp</value>
</list>
</model>
Expand Down Expand Up @@ -101,7 +94,7 @@
<list key="WebClient-builder" if="${flavor} == 'se'">
<value><![CDATA[ .addMediaSupport(JacksonSupport.create())]]></value>
</list>
<list key="modules">
<list key="module-requires">
<value>com.fasterxml.jackson.annotation</value>
<value if="${flavor} == 'se'">io.helidon.media.jackson</value>
</list>
Expand Down Expand Up @@ -144,8 +137,7 @@
<list key="WebClient-builder" if="${flavor} == 'se'">
<value><![CDATA[ .addMediaSupport(JsonbSupport.create())]]></value>
</list>
<list key="modules">
<value>jakarta.json</value>
<list key="module-requires">
<value if="${flavor} == 'se'">io.helidon.media.jsonb</value>
</list>
</model>
Expand All @@ -167,24 +159,23 @@
<value key="artifactId">helidon-media-multipart</value>
</map>
<map order="500" if="${flavor} == 'se'">
<value key="groupId">io.helidon.media</value>
<value key="artifactId">helidon-media-jsonp</value>
<value key="groupId">io.helidon.webserver</value>
<value key="artifactId">helidon-webserver-static-content</value>
</map>
</list>
<list key="modules">
<value>jakarta.json</value>
<list key="module-requires">
<value if="${flavor} == 'se'">io.helidon.media.multipart</value>
<value if="${flavor} == 'se'">io.helidon.media.jsonp</value>
<value if="${flavor} == 'se'">io.helidon.webserver.staticcontent</value>
<value if="${flavor} == 'mp'">jersey.media.multipart</value>
</list>
<list key="MainTest-helidon-imports" if="${flavor} == 'se'">
<value>io.helidon.media.jsonp.JsonpSupport</value>
</list>
<list key="Main-helidon-imports" if="${flavor} == 'se'">
<value>io.helidon.media.jsonp.JsonpSupport</value>
</list>
<list key="Main-helidon-imports" if="${flavor} == 'se'">
<value>io.helidon.media.multipart.MultiPartSupport</value>
<value>io.helidon.webserver.staticcontent.StaticContentSupport</value>
</list>
<list key="Main-serverBuilder" if="${flavor} == 'se'">
<value><![CDATA[ .addMediaSupport(JsonpSupport.create())]]></value>
Expand All @@ -196,7 +187,13 @@
<value><![CDATA[ .addMediaSupport(MultiPartSupport.create())]]></value>
</list>
<list key="Main-routingBuilder" if="${flavor} == 'se'">
<value><![CDATA[ .register("/multipart", new FileService())]]></value>
<value order="1"><![CDATA[ .register("/ui", StaticContentSupport.builder("WEB")
.welcomeFileName("index.html")
.build())
.register("/multipart", new FileService())]]></value>
</list>
<list key="module-opens" if="${flavor} == 'se'">
<value>WEB</value>
</list>
</model>
</output>
Expand All @@ -215,6 +212,15 @@
<value key="media-json-jackson" if="!(${media} contains 'json' &amp;&amp; ${media.json-lib} == 'jackson')">false</value>
<value key="json-lib" if="${media} contains 'json'">${media.json-lib}</value>
<value key="multipart" if="${media} contains 'multipart'">true</value>
<list key="dependencies" if="${media} contains 'multipart' || ${media.json-lib} == 'jsonp'">
<map order="500" if="${flavor} == 'se'">
<value key="groupId">io.helidon.media</value>
<value key="artifactId">helidon-media-jsonp</value>
</map>
</list>
<list key="module-requires" if="${media} contains 'multipart' || ['jsonp', 'jsonb'] contains ${media.json-lib}">
<value>jakarta.json</value>
</list>
</model>
</output>
</step>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
@Inject
private MetricRegistry registry;]]></value>
</list>
<list key="modules">
<list key="module-requires">
<value>io.helidon.microprofile.metrics</value>
</list>
</model>
Expand Down Expand Up @@ -211,7 +211,7 @@ curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
<list key="MainTest-static-imports">
<value>static org.junit.jupiter.api.Assertions.assertEquals</value>
</list>
<list key="modules">
<list key="module-requires">
<value>io.helidon.integrations.micrometer</value>
</list>
<list key="readme-sections">
Expand Down Expand Up @@ -278,7 +278,7 @@ allRequests_total 0.0
assertThat(response.status().code(), is(200));
}]]></value>
</list>
<list key="modules" if="${flavor} == 'se'">
<list key="module-requires" if="${flavor} == 'se'">
<value>io.helidon.metrics</value>
</list>
<list key="readme-sections" if="${flavor} == 'se'">
Expand Down Expand Up @@ -345,7 +345,7 @@ curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
<value key="artifactId">helidon-health-checks</value>
</map>
</list>
<list key="modules">
<list key="module-requires">
<value>io.helidon.health</value>
<value if="${flavor} == 'se'">io.helidon.health.checks</value>
</list>
Expand Down
25 changes: 12 additions & 13 deletions archetypes/helidon/src/main/archetype/common/packaging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
</includes>
</templates>
<model>
<list key="readme-sections">
<value order="50" template="mustache">
<![CDATA[
<list key="readme-sections">
<value order="50" template="mustache"><![CDATA[
## Run the application in Kubernetes
If you don’t have access to a Kubernetes cluster, you can [install one](https://helidon.io/docs/latest/#/about/kubernetes) on your desktop.
Expand All @@ -60,22 +59,22 @@ kubectl get pods # Verify connectivity to cluster
### Deploy the application to Kubernetes
```
kubectl create -f app.yaml # Deploy application
kubectl get pods # Wait for quickstart pod to be RUNNING
kubectl get service {{artifactId}} # Get service info
kubectl create -f app.yaml # Deploy application
kubectl get pods # Wait for quickstart pod to be RUNNING
kubectl get service {{artifactId}} # Get service info
kubectl port-forward service/{{artifactId}} 8081:8080 # Forward service port to 8081
```
Note the PORTs. You can now exercise the application as you did before but use the second
port number (the NodePort) instead of 8080.
You can now exercise the application as you did before but use the port number 8081.
After you’re done, cleanup.
```
kubectl delete -f app.yaml
```
]]>
</value>
</list>
]]>
</value>
</list>
</model>
</output>
</boolean>
Expand Down Expand Up @@ -115,7 +114,7 @@ kubectl delete -f app.yaml
* Note that this class is required when using modules as the module main class must be in a package that is either exported
* or opened by the module, see {@link java.lang.module.ModuleDescriptor#read(java.io.InputStream, java.util.function.Supplier)}.
* <p>
* This class provides a proper module main class and calls the {@link io.helidon.Main#main(String[]) built-in main class}.
* This class provides a proper module main class and calls the {@link io.helidon.microprofile.cdi.Main#main(String[]) built-in main class}.
*/]]>
</value>
<value key="Main-method-javadoc"><![CDATA[
Expand All @@ -138,7 +137,7 @@ kubectl delete -f app.yaml
<list key="Main-method-content">
<value><![CDATA[io.helidon.microprofile.cdi.Main.main(args);]]></value>
</list>
<list key="modules">
<list key="module-requires">
<value>io.helidon.microprofile.cdi</value>
</list>
</model>
Expand Down
4 changes: 2 additions & 2 deletions archetypes/helidon/src/main/archetype/common/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<value key="artifactId">helidon-microprofile-oidc</value>
</map>
</list>
<list key="modules" if="${flavor} == 'se'">
<list key="module-requires" if="${flavor} == 'se'">
<value>io.helidon.security.providers.oidc</value>
</list>
<list key="Main-helidon-imports" if="${flavor} == 'se'">
Expand Down Expand Up @@ -191,7 +191,7 @@
<value key="artifactId">helidon-security-integration-webserver</value>
</map>
</list>
<list key="modules">
<list key="module-requires">
<value if="${flavor} == 'se'">io.helidon.security</value>
<value if="${flavor} == 'se'">io.helidon.security.integration.webserver</value>
</list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@
<value key="artifactId">helidon-microprofile-core</value>
</map>
</list>
<list key="modules">
<list key="module-requires">
<value>jakarta.cdi</value>
<value>jakarta.inject</value>
<value>jakarta.ws.rs</value>
<value>io.helidon.microprofile.config</value>
</list>
<value key="module-opens-package">true</value>
</model>
</output>
</archetype-script>
Loading

0 comments on commit 5d887ff

Please sign in to comment.