Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion archetypes/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -32,3 +32,5 @@ cd `artifactId`
```

Now, just follow instructions in the generated README file.

[//]: # (TODO - Add description of the new archetype rules)
111 changes: 111 additions & 0 deletions archetypes/archetypes/.live-plugins/plugin.groovy
Original file line number Diff line number Diff line change
@@ -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 <exec> and <source> 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<XmlAttributeValue> {

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)
22 changes: 22 additions & 0 deletions archetypes/archetypes/README.md
Original file line number Diff line number Diff line change
@@ -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
22 changes: 18 additions & 4 deletions archetypes/archetypes/filters.properties
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
5 changes: 3 additions & 2 deletions archetypes/archetypes/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2020, 2023 Oracle and/or its affiliates.
Copyright (c) 2020, 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 @@ -52,7 +52,8 @@
<variables>
<text path="helidon-version" transient="true">${project.version}</text>
</variables>
<exec src="flavor.xml"/>
<exec src="inputs.xml"/>
<exec src="output.xml"/>
</entrypoint>
<inputFiltersFile>filters.properties</inputFiltersFile>
<validations>
Expand Down
17 changes: 17 additions & 0 deletions archetypes/archetypes/src/main/archetype/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rename readme-sections

Dernières étapes :

Create issue in build-tools for sorted list

Convention:

relative path for subdirectories, absolute path for upper from cwd.
application.yaml have to be under src/main/resources directory -> done

Follow-up issue

- Media should not own the service, it should be abstracted from the media.


write convention in readme
64 changes: 0 additions & 64 deletions archetypes/archetypes/src/main/archetype/common/common.xml

This file was deleted.

This file was deleted.

Loading