diff --git a/archetypes/README.md b/archetypes/README.md index d15a418989f..aae83156393 100644 --- a/archetypes/README.md +++ b/archetypes/README.md @@ -1,7 +1,7 @@ # Archetypes Development Helidon provides a set of archetypes to bootstrap end user's application development journey. They are implemented here based on -[Archetype V2 engine] (https://github.com/helidon-io/helidon-build-tools/wiki/Archetype-Engine-V2) +[Archetype V2 engine](https://github.com/helidon-io/helidon-build-tools/wiki/Archetype-Engine-V2). ## Build @@ -32,3 +32,5 @@ cd `artifactId` ``` Now, just follow instructions in the generated README file. + +[//]: # (TODO - Add description of the new archetype rules) diff --git a/archetypes/archetypes/.live-plugins/plugin.groovy b/archetypes/archetypes/.live-plugins/plugin.groovy new file mode 100644 index 00000000000..5efa1e47fbf --- /dev/null +++ b/archetypes/archetypes/.live-plugins/plugin.groovy @@ -0,0 +1,111 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.intellij.openapi.extensions.* +import com.intellij.patterns.XmlPatterns +import com.intellij.psi.* +import com.intellij.psi.impl.source.resolve.reference.PsiReferenceContributorEP +import com.intellij.psi.util.PsiTreeUtil +import com.intellij.psi.xml.* +import com.intellij.util.ProcessingContext + +// depends-on-plugin org.jetbrains.kotlin + +/* + This script provides some IntelliJ support for the archetype scripts. + It supports navigation for the src attributes of and elements. + Setup: + - Install the plugin named "LivePlugin" from the IntelliJ marketplace. + - Then right click on this script and select "Run live plugin" + - Optionally, enable "Run Plugins on IDE start" on the Live Plugins panel + Development: + - Mark the parent directory as as source or resource root + - Enable "Add LivePlugin and IDE Jars to Project" on the Live Plugins panel + - Resolve imports > Add library to classpath > "LivePlugin and IDE jar" + See: + - https://github.com/dkandalov/live-plugin + - https://gist.github.com/dkandalov/49f17eb3f6a2e87fdb1f2dc3d1eba609 + */ + +class ArchetypeScriptReference extends PsiPolyVariantReferenceBase { + + static final String SOURCE_ROOT = "src/main/archetype" + + ArchetypeScriptReference(XmlAttributeValue element) { + super(element, true) + } + + def fileRef() { + def elementFile = element.containingFile.virtualFile + if (element.value.startsWith("/")) { + def index = elementFile.path.lastIndexOf(SOURCE_ROOT) + def path = elementFile.path.substring(0, index + SOURCE_ROOT.length()) + element.value + return elementFile.fileSystem.findFileByPath(path) + } else { + return elementFile.parent.findFileByRelativePath(element.value) + } + } + + @Override + ResolveResult[] multiResolve(boolean incomplete) { + def result = fileRef() + if (result != null) { + def psiManager = PsiManager.getInstance(element.project) + def file = psiManager.findFile(result) + if (file != null) { + return new ResolveResult[]{new PsiElementResolveResult(file)} + } + } + return ResolveResult.EMPTY_ARRAY + } + + @Override + boolean isReferenceTo(PsiElement element) { + return false + } +} + +class ArchetypeScriptContributor extends PsiReferenceContributor { + + @Override + void registerReferenceProviders(PsiReferenceRegistrar registrar) { + registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue(), new PsiReferenceProvider() { + @Override + PsiReference[] getReferencesByElement(PsiElement element, ProcessingContext context) { + // enable only for archetype-script documents and src attributes + def doc = PsiTreeUtil.getParentOfType(element, XmlDocument.class) + def attr = PsiTreeUtil.getParentOfType(element, XmlAttribute.class) + def tag = PsiTreeUtil.getParentOfType(element, XmlTag.class) + if (doc != null && doc.rootTag.name == "archetype-script" + && attr != null && attr.name == "src" + && tag != null && (tag.name == "exec" || tag.name == "source")) { + return new PsiReference[]{ + new ArchetypeScriptReference((XmlAttributeValue) element) + } + } + return PsiReference.EMPTY_ARRAY + } + }, PsiReferenceRegistrar.LOWER_PRIORITY) + } +} + +def extension = new PsiReferenceContributorEP().tap { + language = "XML" + implementationClass = ArchetypeScriptContributor.class.name + pluginDescriptor = new DefaultPluginDescriptor(PluginId.getId("LivePlugin"), + ArchetypeScriptContributor.class.classLoader) +} +PsiReferenceContributor.EP_NAME.point.registerExtension(extension, pluginDisposable) diff --git a/archetypes/archetypes/README.md b/archetypes/archetypes/README.md new file mode 100644 index 00000000000..60e7cb07762 --- /dev/null +++ b/archetypes/archetypes/README.md @@ -0,0 +1,22 @@ +# Archetype + +Document description + +## Conventions + +### Features + +- Must have an HTTP endpoint to exercise the feature (no generic path like 'api' or 'endpoint') +- Must have a unit test class +- Must have README.md documentation +- Must have javadoc following Helidon standard + +### Architecture + +- directories group (files/features/nodes) +- files names is flexible but has to self explainatory +- inputs and output must be splited +- archetype flow has to go through all inputs and then the output +- paths relative and absolute +- snippet should be placed at the same location then the template (in terms of path) +- files must start at line 1 and end with a new line diff --git a/archetypes/archetypes/filters.properties b/archetypes/archetypes/filters.properties index 70d78ff2c81..b85444ed661 100644 --- a/archetypes/archetypes/filters.properties +++ b/archetypes/archetypes/filters.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2025 Oracle and/or its affiliates. +# Copyright (c) 2022, 2023 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. @@ -31,16 +31,16 @@ observability=!(${metrics} || ${tracing} || ${health}) || \ (${metrics} && ${tracing} && ${health}) # force health.builtin=true -health=!${health} || (${health.builtin}) +health=!${health} || ${health.builtin} # force metrics.builtin=true -metrics=!${metrics} || (${metrics.builtin}) +metrics=!${metrics} || ${metrics.builtin} # group extra options extra=${extra} == [] || ${extra} == ['cors', 'fault-tolerance', 'coherence'] || \ (${flavor} == 'se' && ${extra} == ['webclient', 'cors', 'fault-tolerance', 'coherence']) -# group docker and k8s +# group docker, k8s and multi-module packaging=!(${docker} || ${k8s}) || (${docker} && ${k8s}) # force docker.native-image=true and docker.jlink-image=true when docker=true @@ -119,3 +119,17 @@ hikaricp-media=\ db-health=\ ${app-type} != 'database' || (${app-type} == 'database' && \ !${health}) + +multi-module=\ + ${multi-module} && \ + ${flavor} == 'se' && \ + ${media.json-lib} == 'jsonp' && \ + ${extra} == [] && \ + !${db} && \ + !${security} && \ + !${metrics} && \ + !${tracing} && \ + !${health} && \ + !${docker} && \ + !${k8s} && \ + !${jpms} diff --git a/archetypes/archetypes/pom.xml b/archetypes/archetypes/pom.xml index c0e7f49f3f3..5854cb83f4f 100644 --- a/archetypes/archetypes/pom.xml +++ b/archetypes/archetypes/pom.xml @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - files - - .helidon.mustache - README.md.mustache - .gitignore.mustache - src/main/java/**/Main.java.mustache - - - - 1.1.0 - - - io.helidon.logging - helidon-logging-jul - runtime - - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/customize-project.xml b/archetypes/archetypes/src/main/archetype/common/customize-project.xml deleted file mode 100644 index 6bc6844e955..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/customize-project.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - io.helidon.applications - ${helidon-version} - true - ${artifactId} - ${groupId} - ${version} - ${package} - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/docker.xml b/archetypes/archetypes/src/main/archetype/common/docker.xml deleted file mode 100644 index 2df7165a8c5..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/docker.xml +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - files - - src/*/resources/META-INF/**/*.mustache - - - - files - - src/**/native-image/**/resource-config.json - - - - - - - - - files - - .dockerignore - - - - files - - Dockerfile.mustache - Dockerfile.native.mustache - Dockerfile.jlink.mustache - - - - - ADD pom.xml . - - - ADD src src - - - - - - - - - - - - - - - - - -Declipselink.weave.skip - -DskipOpenApiGenerate - - - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/extra.xml b/archetypes/archetypes/src/main/archetype/common/extra.xml deleted file mode 100644 index f732ce42080..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/extra.xml +++ /dev/null @@ -1,374 +0,0 @@ - - - - - - - - - - - - - - - - true - true - true - true - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.jlink.mustache b/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.jlink.mustache deleted file mode 100644 index 4659123c983..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.jlink.mustache +++ /dev/null @@ -1,35 +0,0 @@ - -# 1st stage, build the app -FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build - -WORKDIR /usr/share - -# Install maven -RUN set -x && \ - curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ - tar -xvf apache-maven-*-bin.tar.gz && \ - rm apache-maven-*-bin.tar.gz && \ - mv apache-maven-* maven && \ - ln -s /usr/share/maven/bin/mvn /bin/ - -WORKDIR /helidon - -# Create a first layer to cache the "Maven World" in the local repository. -# Incremental docker builds will always resume after that, unless you update -# the pom -ADD pom.xml . -RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip - -# Do the Maven build to create the custom Java Runtime Image -# Incremental docker builds will resume here when you change sources -ADD src src -RUN mvn package -Pjlink-image -DskipTests -RUN echo "done!" - -# 2nd stage, build the final image with the JRI built in the 1st stage - -FROM debian:stretch-slim -WORKDIR /helidon -COPY --from=build /helidon/target/{{artifactId}}-jri ./ -ENTRYPOINT ["/bin/bash", "/helidon/bin/start"] -EXPOSE 8080 diff --git a/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.mustache b/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.mustache deleted file mode 100644 index 11f2945897c..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.mustache +++ /dev/null @@ -1,43 +0,0 @@ - -# 1st stage, build the app -FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build - -# Install maven -WORKDIR /usr/share -RUN set -x && \ - curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ - tar -xvf apache-maven-*-bin.tar.gz && \ - rm apache-maven-*-bin.tar.gz && \ - mv apache-maven-* maven && \ - ln -s /usr/share/maven/bin/mvn /bin/ - -WORKDIR /helidon - -# Create a first layer to cache the "Maven World" in the local repository. -# Incremental docker builds will always resume after that, unless you update -# the pom -{{#poms}} -{{.}} -{{/poms}} -RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip {{#docker-phase1-options}}{{.}}{{^last}} {{/last}}{{/docker-phase1-options}} - -# Do the Maven build! -# Incremental docker builds will resume here when you change sources -{{#src-dirs}} -{{.}} -{{/src-dirs}} -RUN mvn package -DskipTests - -RUN echo "done!" - -# 2nd stage, build the runtime image -FROM container-registry.oracle.com/java/jdk-no-fee-term:21 -WORKDIR /helidon - -# Copy the binary built in the 1st stage -COPY --from=build /helidon/{{#module-dir}}{{.}}/{{/module-dir}}target/{{artifactId}}.jar ./ -COPY --from=build /helidon/{{#module-dir}}{{.}}/{{/module-dir}}target/libs ./libs - -CMD ["java", "-jar", "{{artifactId}}.jar"] - -EXPOSE 8080 diff --git a/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.native.mustache b/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.native.mustache deleted file mode 100644 index 4ff85c6391e..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/files/Dockerfile.native.mustache +++ /dev/null @@ -1,39 +0,0 @@ - -# 1st stage, build the app -FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build - -WORKDIR /usr/share - -# Install maven -RUN set -x && \ - curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ - tar -xvf apache-maven-*-bin.tar.gz && \ - rm apache-maven-*-bin.tar.gz && \ - mv apache-maven-* maven && \ - ln -s /usr/share/maven/bin/mvn /bin/ - -WORKDIR /helidon - -# Create a first layer to cache the "Maven World" in the local repository. -# Incremental docker builds will always resume after that, unless you update -# the pom -ADD pom.xml . -RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip - -# Do the Maven build! -# Incremental docker builds will resume here when you change sources -ADD src src -RUN mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests - -RUN echo "done!" - -# 2nd stage, build the runtime image -FROM scratch -WORKDIR /helidon - -# Copy the binary built in the 1st stage -COPY --from=build /helidon/target/{{artifactId}} . - -ENTRYPOINT ["./{{artifactId}}"] - -EXPOSE 8080 diff --git a/archetypes/archetypes/src/main/archetype/common/files/src/main/java/__pkg__/Main.java.mustache b/archetypes/archetypes/src/main/archetype/common/files/src/main/java/__pkg__/Main.java.mustache deleted file mode 100644 index c0963bbfa8d..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/files/src/main/java/__pkg__/Main.java.mustache +++ /dev/null @@ -1,37 +0,0 @@ - -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}} -} \ No newline at end of file diff --git a/archetypes/archetypes/src/main/archetype/common/media-sources.xml b/archetypes/archetypes/src/main/archetype/common/media-sources.xml deleted file mode 100644 index 5f34067e8b7..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/media-sources.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - files - - src/*/java/**/SimpleGreetService.java.mustache - src/*/java/**/SimpleGreetResource.java.mustache - src/*/java/**/GreetService.java.mustache - - - - files - - src/*/java/**/*.java.jsonp.mustache - - - - files - - src/*/java/**/*.json.mustache - - - - files - - src/*/java/**/*.multipart.mustache - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/media.xml b/archetypes/archetypes/src/main/archetype/common/media.xml deleted file mode 100644 index 0d520a71db3..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/media.xml +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - jsonb - jsonp - - - - - - - - - - - - - - - true - false - true - false - ${media.json-lib} - true - - - - - - jakarta.json - jakarta.json-api - - - io.helidon.http.media - helidon-http-media-jsonp - - - - jakarta.json - - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/observability.xml b/archetypes/archetypes/src/main/archetype/common/observability.xml deleted file mode 100644 index 518af2aa3b6..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/observability.xml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - io.helidon.webserver.observe - helidon-webserver-observe-metrics - - - io.helidon.metrics - helidon-metrics-system-meters - runtime - - - - - - - io.helidon.webserver.observe.metrics - io.helidon.metrics.api - - - - - - - - - - - - - - - - - io.helidon.microprofile.health - helidon-microprofile-health - - - - - - - - - - - io.helidon.webserver.observe - helidon-webserver-observe-health - - - io.helidon.health - helidon-health-checks - - - - org.hamcrest.CoreMatchers.containsString - - - - - - - - - io.helidon.webserver.observe.health - io.helidon.health.checks - - - - - - - - - - - - - - - - - - - true - ${metrics.provider} - ${metrics.builtin} - true - ${health.builtin} - true - ${tracing.provider} - - - io.helidon.microprofile.metrics - helidon-microprofile-metrics - - - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/packaging.xml b/archetypes/archetypes/src/main/archetype/common/packaging.xml deleted file mode 100644 index 3b9471d0d96..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/packaging.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - files - - app.yaml.mustache - - - - - - - - - - - - - - files - - src/main/java/**/module-info.java.mustache - src/main/java/**/Main.java.mustache - - - - - - - diff --git a/archetypes/archetypes/src/main/archetype/common/security.xml b/archetypes/archetypes/src/main/archetype/common/security.xml deleted file mode 100644 index db0378cf9a8..00000000000 --- a/archetypes/archetypes/src/main/archetype/common/security.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - true - true - - - - - - - - - - true - - - diff --git a/archetypes/archetypes/src/main/archetype/defaults.xml b/archetypes/archetypes/src/main/archetype/defaults.xml new file mode 100644 index 00000000000..6e18d27d528 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/defaults.xml @@ -0,0 +1,88 @@ + + + + + + . + + false + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + diff --git a/archetypes/archetypes/src/main/archetype/features/customize-project/inputs.xml b/archetypes/archetypes/src/main/archetype/features/customize-project/inputs.xml new file mode 100644 index 00000000000..6dce4c373eb --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/customize-project/inputs.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/customize-project/output.xml b/archetypes/archetypes/src/main/archetype/features/customize-project/output.xml new file mode 100644 index 00000000000..59c63f52460 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/customize-project/output.xml @@ -0,0 +1,32 @@ + + + + + + + + ${artifactId} + ${groupId} + ${version} + ${package} + + + diff --git a/archetypes/archetypes/src/main/archetype/common/files/.dockerignore b/archetypes/archetypes/src/main/archetype/features/docker/files/.dockerignore similarity index 100% rename from archetypes/archetypes/src/main/archetype/common/files/.dockerignore rename to archetypes/archetypes/src/main/archetype/features/docker/files/.dockerignore diff --git a/archetypes/archetypes/src/main/archetype/features/docker/files/Dockerfile.hbs b/archetypes/archetypes/src/main/archetype/features/docker/files/Dockerfile.hbs new file mode 100644 index 00000000000..b1d54aa75ee --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/docker/files/Dockerfile.hbs @@ -0,0 +1,107 @@ +# 1st stage, build the app +FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build + +# Install maven +WORKDIR /usr/share +RUN set -x && \ + curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ + tar -xvf apache-maven-*-bin.tar.gz && \ + rm apache-maven-*-bin.tar.gz && \ + mv apache-maven-* maven && \ + ln -s /usr/share/maven/bin/mvn /bin/ + +WORKDIR /helidon + +# Create a first layer to cache the "Maven World" in the local repository. +# Incremental docker builds will always resume after that, unless you update +# the pom +ADD pom.xml . +{{#multi-module}} +{{#module-names}} +ADD {{.}}/pom.xml {{.}}/pom.xml +{{/module-names}} +{{/multi-module}} +RUN mvn package \ +{{#multi-module}} + -pl {{module-name}} -am \ +{{/multi-module}} +{{#native-image}} + -Pnative-image -Dnative.image.skip \ +{{/native-image}} +{{#jlink}} + -Pjlink-image -DskipJavaImage \ +{{/jlink}} +{{#eclipselink}} + -Declipselink.weave.skip \ +{{/eclipselink}} +{{#openapi-generator}} + -DskipOpenApiGenerate \ +{{/openapi-generator}} + -Dmaven.test.skip + +# Do the Maven build! +# Incremental docker builds will resume here when you change sources +{{#multi-module}} +{{#module-names}} +ADD {{.}}/src {{.}}/src +{{/module-names}} +RUN mvn package \ + -pl {{module-name}} -am \ +{{#native-image}} + -Pnative-image \ +{{/native-image}} +{{#jlink}} + -Pjlink-image \ +{{/jlink}} + -Dmaven.test.skip +{{/multi-module}} +{{^multi-module}} +ADD src src +RUN mvn package \ +{{#native-image}} + -Pnative-image \ +{{/native-image}} +{{#jlink}} + -Pjlink-image \ +{{/jlink}} + -Dmaven.test.skip +{{/multi-module}} + +RUN echo "done!" + +# 2nd stage, build the runtime image +{{#native-image}} +FROM scratch +WORKDIR /helidon + +# Copy the binary built in the 1st stage +COPY --from=build /helidon/target/{{artifactId}} . + +ENTRYPOINT ["./{{artifactId}}"] +{{/native-image}} +{{^native-image}} +{{#jlink}} +FROM debian:stretch-slim +WORKDIR /helidon +COPY --from=build /helidon/target/{{artifactId}}-jri ./ +ENTRYPOINT ["/bin/bash", "/helidon/bin/start"] +{{/jlink}} +{{^jlink}} +FROM container-registry.oracle.com/java/jdk-no-fee-term:21 +WORKDIR /helidon + +# Copy the binary built in the 1st stage +{{#multi-module}} +COPY --from=build /helidon/{{module-name}}/target/{{artifactId}}.jar ./ +COPY --from=build /helidon/{{module-name}}/target/libs ./libs +{{/multi-module}} +{{^multi-module}} +COPY --from=build /helidon/target/{{artifactId}}.jar ./ +COPY --from=build /helidon/target/libs ./libs +{{/multi-module}} + +CMD ["java", "-jar", "{{basedir}}/{{artifactId}}.jar"] +{{/jlink}} +{{/native-image}} + +EXPOSE 8080 diff --git a/archetypes/archetypes/src/main/archetype/features/docker/files/README.md.hbs b/archetypes/archetypes/src/main/archetype/features/docker/files/README.md.hbs new file mode 100644 index 00000000000..a411434e979 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/docker/files/README.md.hbs @@ -0,0 +1,19 @@ + +## Building the Docker Image + +```shell +docker build -t {{artifactId}} . +``` + +## Running the Docker Image + +{{#docker-run-readme-section}} +{{.}} +{{/docker-run-readme-section}} +{{^docker-run-readme-section}} +```shell +docker run --rm -p 8080:8080 {{artifactId}}:latest +``` +{{/docker-run-readme-section}} + +Exercise the application as described above. diff --git a/archetypes/archetypes/src/main/archetype/features/docker/inputs.xml b/archetypes/archetypes/src/main/archetype/features/docker/inputs.xml new file mode 100644 index 00000000000..e531b611bee --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/docker/inputs.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/docker/output.xml b/archetypes/archetypes/src/main/archetype/features/docker/output.xml new file mode 100644 index 00000000000..702ffc86689 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/docker/output.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + files + + Dockerfile.hbs + + + false + false + + + + files + + Dockerfile.hbs + + + true + false + + + + files + + Dockerfile.hbs + + + false + true + + + + + + + + + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/jlink/files/README.md.hbs b/archetypes/archetypes/src/main/archetype/features/jlink/files/README.md.hbs new file mode 100644 index 00000000000..2abffe74dd0 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/jlink/files/README.md.hbs @@ -0,0 +1,33 @@ +## Building a Custom Runtime Image + +Build the custom runtime image using the jlink image profile: + +```shell +mvn package -Pjlink-image +``` + +This uses the helidon-maven-plugin to perform the custom image generation. +After the build completes it will report some statistics about the build including the reduction in image size. + +The target/{{artifactId}}-jri directory is a self-contained custom image of your application. It contains your application, +its runtime dependencies and the JDK modules it depends on. You can start your application using the provide start script: + +```shell +./target/{{artifactId}}-jri/bin/start +``` + +Class Data Sharing (CDS) Archive +Also included in the custom image is a Class Data Sharing (CDS) archive that improves your application’s startup +performance and in-memory footprint. You can learn more about Class Data Sharing in the JDK documentation. + +The CDS archive increases your image size to get these performance optimizations. It can be of significant size (tens of MB). +The size of the CDS archive is reported at the end of the build output. + +If you’d rather have a smaller image size (with a slightly increased startup time) you can skip the creation of the CDS +archive by executing your build like this: + +```shell +mvn package -Pjlink-image -Djlink.image.addClassDataSharingArchive=false +``` + +For more information on available configuration options see the helidon-maven-plugin documentation. diff --git a/archetypes/archetypes/src/main/archetype/features/jlink/inputs.xml b/archetypes/archetypes/src/main/archetype/features/jlink/inputs.xml new file mode 100644 index 00000000000..a900cf459f8 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/jlink/inputs.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/se/custom/observability.xml b/archetypes/archetypes/src/main/archetype/features/jlink/output.xml similarity index 77% rename from archetypes/archetypes/src/main/archetype/se/custom/observability.xml rename to archetypes/archetypes/src/main/archetype/features/jlink/output.xml index db722caf323..a0fdfb8dfb8 100644 --- a/archetypes/archetypes/src/main/archetype/se/custom/observability.xml +++ b/archetypes/archetypes/src/main/archetype/features/jlink/output.xml @@ -1,7 +1,7 @@ + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/jpms/output.xml b/archetypes/archetypes/src/main/archetype/features/jpms/output.xml new file mode 100644 index 00000000000..7aa09f8244b --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/jpms/output.xml @@ -0,0 +1,93 @@ + + + + + + + files + + src/main/java/**/module-info.java.hbs + + + + + + java.logging + jakarta.annotation + jakarta.cdi + jakarta.inject + jakarta.json + jakarta.json.bind + jakarta.persistence + jakarta.ws.rs + jakarta.xml.bind + io.helidon + io.helidon.common.pki + io.helidon.config + io.helidon.cors + io.helidon.dbclient + io.helidon.dbclient.metrics + io.helidon.dbclient.tracing + io.helidon.faulttolerance + io.helidon.health.checks + io.helidon.http + io.helidon.http.media.multipart + io.helidon.logging.common + io.helidon.metrics.api + io.helidon.microprofile.cors + io.helidon.microprofile.faulttolerance + io.helidon.microprofile.jwt.auth + io.helidon.microprofile.metrics + io.helidon.microprofile.openapi + io.helidon.microprofile.telemetry + io.helidon.microprofile.config + io.helidon.security + io.helidon.security.annotations + io.helidon.security.integration.common + io.helidon.security.providers.common + io.helidon.security.providers.google.login + io.helidon.security.providers.httpauth + io.helidon.security.providers.httpsign + io.helidon.security.providers.jwt + io.helidon.security.providers.oidc + io.helidon.tracing + io.helidon.webclient.http1 + io.helidon.webclient.security + io.helidon.webserver + io.helidon.webserver.context + io.helidon.webserver.cors + io.helidon.webserver.http2 + io.helidon.webserver.observe + io.helidon.webserver.observe.health + io.helidon.webserver.observe.metrics + io.helidon.webserver.observe.tracing + io.helidon.webserver.security + io.helidon.webserver.staticcontent + jersey.media.multipart + org.jvnet.mimepull + com.fasterxml.jackson.annotation + com.fasterxml.jackson.core + com.oracle.coherence + com.oracle.coherence.cdi + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/kubernetes/files/README.md.hbs b/archetypes/archetypes/src/main/archetype/features/kubernetes/files/README.md.hbs new file mode 100644 index 00000000000..759a3f4fc7f --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/kubernetes/files/README.md.hbs @@ -0,0 +1,33 @@ +## 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. + +### Verify connectivity to cluster + +```shell +kubectl cluster-info # Verify which cluster +kubectl get pods # Verify connectivity to cluster +``` +{{#k8s-readme-sections}} +{{#first}} + +{{/first}} +{{.}} +{{/k8s-readme-sections}} + +### Deploy the application to Kubernetes + +```shell +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 +``` + +You can now exercise the application as you did before but use the port number 8081. + +After you’re done, cleanup. + +```shell +kubectl delete -f app.yaml +``` diff --git a/archetypes/archetypes/src/main/archetype/common/files/app.yaml.mustache b/archetypes/archetypes/src/main/archetype/features/kubernetes/files/app.yaml.hbs similarity index 100% rename from archetypes/archetypes/src/main/archetype/common/files/app.yaml.mustache rename to archetypes/archetypes/src/main/archetype/features/kubernetes/files/app.yaml.hbs diff --git a/archetypes/archetypes/src/main/archetype/features/kubernetes/inputs.xml b/archetypes/archetypes/src/main/archetype/features/kubernetes/inputs.xml new file mode 100644 index 00000000000..02af998fa2e --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/kubernetes/inputs.xml @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/kubernetes/output.xml b/archetypes/archetypes/src/main/archetype/features/kubernetes/output.xml new file mode 100644 index 00000000000..bca8499b530 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/kubernetes/output.xml @@ -0,0 +1,38 @@ + + + + + + + files + + app.yaml.hbs + + + + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/common/files/pom.xml.mustache b/archetypes/archetypes/src/main/archetype/features/maven/files/pom.xml.hbs similarity index 79% rename from archetypes/archetypes/src/main/archetype/common/files/pom.xml.mustache rename to archetypes/archetypes/src/main/archetype/features/maven/files/pom.xml.hbs index 9e35d616f35..62a3159d116 100644 --- a/archetypes/archetypes/src/main/archetype/common/files/pom.xml.mustache +++ b/archetypes/archetypes/src/main/archetype/features/maven/files/pom.xml.hbs @@ -4,12 +4,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - {{parent-groupId}} + io.helidon.applications {{parent-artifactId}} - {{parent-version}} -{{#remote-parent-pom}} + {{helidon-version}} -{{/remote-parent-pom}} {{groupId}} {{artifactId}} @@ -49,10 +47,10 @@ {{#first}} {{/first}} - - {{groupId}} - {{artifactId}} - + + {{groupId}} + {{artifactId}} + {{#last}} {{/last}} @@ -83,6 +81,18 @@ {{#optional}} {{.}} {{/optional}} +{{#exclusions}} +{{#first}} + +{{/first}} + + {{groupId}} + {{artifactId}} + +{{#first}} + +{{/first}} +{{/exclusions}} {{#last}} @@ -105,7 +115,7 @@ {{/maven-plugins}} - {{#maven-profiles}} - {{.}} - {{/maven-profiles}} +{{#maven-profiles}} +{{.}} +{{/maven-profiles}} diff --git a/archetypes/archetypes/src/main/archetype/features/maven/inputs.xml b/archetypes/archetypes/src/main/archetype/features/maven/inputs.xml new file mode 100644 index 00000000000..42030c32b5f --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/maven/inputs.xml @@ -0,0 +1,22 @@ + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/maven/output.xml b/archetypes/archetypes/src/main/archetype/features/maven/output.xml new file mode 100644 index 00000000000..95380dadcd6 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/maven/output.xml @@ -0,0 +1,31 @@ + + + + + + + files + + pom.xml.hbs + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/multi-module/files/pom.xml.hbs b/archetypes/archetypes/src/main/archetype/features/multi-module/files/pom.xml.hbs new file mode 100644 index 00000000000..445b26f090f --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/multi-module/files/pom.xml.hbs @@ -0,0 +1,14 @@ + + + 4.0.0 + {{groupId}} + {{artifactId}}-aggregator + {{project-version}} + pom + + + {{module-name}} + + diff --git a/archetypes/archetypes/src/main/archetype/features/multi-module/inputs.xml b/archetypes/archetypes/src/main/archetype/features/multi-module/inputs.xml new file mode 100644 index 00000000000..7803a394916 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/multi-module/inputs.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + diff --git a/archetypes/archetypes/src/main/archetype/features/multi-module/output.xml b/archetypes/archetypes/src/main/archetype/features/multi-module/output.xml new file mode 100644 index 00000000000..1fecbc10691 --- /dev/null +++ b/archetypes/archetypes/src/main/archetype/features/multi-module/output.xml @@ -0,0 +1,35 @@ + + + + + + ${module-name} + + +