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

[3.x] Archetype - Add jpms option with false as default #8310

Merged
merged 2 commits into from
Feb 1, 2024
Merged
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
3 changes: 1 addition & 2 deletions archetypes/helidon/src/main/archetype/common/common.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2021, 2022 Oracle and/or its affiliates.
Copyright (c) 2021, 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 @@ -42,7 +42,6 @@
<includes>
<include>.helidon.mustache</include>
<include>README.md.mustache</include>
<include>src/main/java/module-info.java.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
@@ -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 @@ -72,12 +72,12 @@
<value if="${flavor} == 'mp'">io.helidon.common.reactive</value>
<value if="${flavor} == 'se'">io.helidon.faulttolerance</value>
</list>
<list key="Main-helidon-imports">
<list key="Main-helidon-imports" if="${flavor} == 'se'">
<value>io.helidon.common.http.Http</value>
<value>io.helidon.faulttolerance.BulkheadException</value>
<value>io.helidon.faulttolerance.CircuitBreakerOpenException</value>
</list>
<list key="Main-other-imports">
<list key="Main-other-imports" if="${flavor} == 'se'">
<value>java.util.concurrent.TimeoutException</value>
</list>
<list key="Main-routingBuilder">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package {{package}};

{{#Main-java-imports}}
import {{.}};
{{/Main-java-imports}}

{{#Main-helidon-imports}}
import {{.}};
{{/Main-helidon-imports}}

{{#Main-other-imports}}
import {{.}};
{{/Main-other-imports}}

{{#Main-static-imports}}
import {{.}};
{{/Main-static-imports}}

{{Main-class-javadoc}}
public class Main {
{{#Main-class-fields}}
{{.}}
{{/Main-class-fields}}

{{Main-method-javadoc}}
public static void main(String[] args) {
{{#Main-method-content}}
{{.}}
{{/Main-method-content}}
}

{{#Main-class-content}}
{{.}}
{{/Main-class-content}}
}
10 changes: 2 additions & 8 deletions archetypes/helidon/src/main/archetype/common/observability.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 @@ -66,12 +66,6 @@ curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
<value key="artifactId">helidon-microprofile-metrics</value>
</map>
</list>
<list key="Main-helidon-imports">
<value>io.helidon.metrics.MetricsSupport</value>
</list>
<list key="Main-routingBuilder">
<value><![CDATA[ .register(MetricsSupport.create()) // Metrics at "/metrics"]]></value>
</list>
<list key="SimpleGreetService-imports">
<value>org.eclipse.microprofile.metrics.MetricUnits</value>
<value>org.eclipse.microprofile.metrics.annotation.Counted</value>
Expand Down Expand Up @@ -355,7 +349,7 @@ curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
<value>io.helidon.health</value>
<value if="${flavor} == 'se'">io.helidon.health.checks</value>
</list>
<list key="Main-helidon-imports">
<list key="Main-helidon-imports" if="${flavor} == 'se'">
<value>io.helidon.health.HealthSupport</value>
<value>io.helidon.health.checks.HealthChecks</value>
</list>
Expand Down
53 changes: 52 additions & 1 deletion archetypes/helidon/src/main/archetype/common/packaging.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 @@ -93,6 +93,57 @@ kubectl delete -f app.yaml
</templates>
</output>
</boolean>
<boolean id="jpms"
name="Module support (JPMS)"
description="Add a module-info to your project"
default="false"
optional="true">
<output>
<templates engine="mustache" transformations="mustache,packaged">
<directory>files</directory>
<includes>
<include>src/main/java/module-info.java.mustache</include>
<include if="${flavor} == 'mp'">src/**/Main.java.mustache</include>
</includes>
</templates>
<model if="${flavor} == 'mp'">
<value key="mainClass">${package}.Main</value>
<value key="Main-class-javadoc"><![CDATA[
/**
* Main entry point of the application.
* <p>
* 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}.
*/]]>
</value>
<value key="Main-method-javadoc"><![CDATA[
/**
* Main method. Starts CDI (and the application).
*
* @param args ignored
*/]]>
</value>
<list key="Main-class-fields">
<value><![CDATA[
/**
* Cannot be instantiated.
*/
private Main() {
}
]]>
</value>
</list>
<list key="Main-method-content">
<value><![CDATA[io.helidon.microprofile.cdi.Main.main(args);]]></value>
</list>
<list key="modules">
<value>io.helidon.microprofile.cdi</value>
</list>
</model>
</output>
</boolean>
</inputs>
</step>
</archetype-script>
3 changes: 2 additions & 1 deletion archetypes/helidon/src/main/archetype/common/presets.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 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 @@ -37,5 +37,6 @@
<boolean path="docker.jlink-image">true</boolean>
<boolean path="k8s">true</boolean>
<boolean path="v8o">false</boolean>
<boolean path="jpms">false</boolean>
</presets>
</archetype-script>
3 changes: 2 additions & 1 deletion archetypes/helidon/src/main/archetype/mp/oci/oci-mp.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 Oracle and/or its affiliates.
Copyright (c) 2023, 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 @@ -45,6 +45,7 @@ This will mount `~/.oci` as a volume in the running docker container.
<boolean path="docker.jlink-image">false</boolean>
<boolean path="k8s">true</boolean>
<boolean path="v8o">false</boolean>
<boolean path="jpms">false</boolean>
</presets>
<call method="pre-processed-models"/>
<exec src="/common/common.xml"/>
Expand Down
93 changes: 92 additions & 1 deletion archetypes/helidon/src/main/archetype/se/common/common-se.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021, 2022 Oracle and/or its affiliates.
Copyright (c) 2021, 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 All @@ -23,6 +23,12 @@
<exec src="/common/common.xml"/>
<source src="/common/sources.xml"/>
<output>
<templates engine="mustache" transformations="mustache,packaged">
<directory>/common/files</directory>
<includes>
<include>src/**/Main.java.mustache</include>
</includes>
</templates>
<model>
<value key="mainClass">${package}.Main</value>
<value key="parent-artifactId">helidon-se</value>
Expand Down Expand Up @@ -88,6 +94,91 @@
<value>io.helidon.common.http</value>
<value>io.helidon.config</value>
</list>
<value key="Main-class-javadoc"><![CDATA[
/**
* The application main class.
*/]]>
</value>
<value key="Main-method-javadoc"><![CDATA[/**
* Application main entry point.
* @param args command line arguments.
*/]]>
</value>
<list key="Main-class-fields">
<value order="0"><![CDATA[
/**
* Cannot be instantiated.
*/
private Main() {
}
]]>
</value>
</list>
<list key="Main-method-content">
<value><![CDATA[ startServer();]]>
</value>
</list>
<list key="Main-class-content">
<value template="mustache"><![CDATA[
/**
* Start the server.
* @return the created {@link WebServer} instance
*/
static Single<WebServer> startServer() {
// load logging configuration
LogConfig.configureRuntime();
// By default this will pick up application.yaml from the classpath
Config config = Config.create();
WebServer server = WebServer.builder(createRouting(config))
.config(config.get("server"))
{{#Main-serverBuilder}}
{{.}}
{{/Main-serverBuilder}}
.build();
Single<WebServer> webserver = server.start();
// Try to start the server. If successful, print some info and arrange to
// print a message at shutdown. If unsuccessful, print the exception.
webserver.forSingle(ws -> {
{{Main-readyMessage}}
ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
})
.exceptionallyAccept(t -> {
System.err.println("Startup failed: " + t.getMessage());
t.printStackTrace(System.err);
});
return webserver;
}
/**
* Creates new {@link Routing}.
*
* @return routing configured with JSON support, a health check, and a service
* @param config configuration of this server
*/
private static Routing createRouting(Config config) {
{{#Main-createRouting}}
{{.}}
{{/Main-createRouting}}
Routing.Builder builder = Routing.builder()
{{#Main-routingBuilder}}
{{.}}{{#last}}; {{/last}}
{{/Main-routingBuilder}}
{{#Main-security-routing-section}}
{{.}}
{{/Main-security-routing-section}}
return builder.build();
}]]>
</value>
</list>
</model>
</output>
</archetype-script>
Loading
Loading