Skip to content

Commit 6bb2091

Browse files
committed
Create new archetype layout
1 parent 2f533b5 commit 6bb2091

File tree

346 files changed

+7155
-5003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+7155
-5003
lines changed

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ jobs:
269269
- { group: r1, start: 1, end: 25 }
270270
- { group: r2, start: 26, end: 50 }
271271
- { group: r3, start: 51, end: 75 }
272-
- { group: r4, start: 75, end: 100 }
272+
- { group: r4, start: 76, end: 100 }
273273
- { group: r5, start: 101, end: -1 }
274274
- { packaging: jar }
275275
runs-on: ubuntu-22.04
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* Copyright (c) 2024 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.intellij.openapi.extensions.*
18+
import com.intellij.patterns.XmlPatterns
19+
import com.intellij.psi.*
20+
import com.intellij.psi.impl.source.resolve.reference.PsiReferenceContributorEP
21+
import com.intellij.psi.util.PsiTreeUtil
22+
import com.intellij.psi.xml.*
23+
import com.intellij.util.ProcessingContext
24+
25+
// depends-on-plugin org.jetbrains.kotlin
26+
27+
/*
28+
This script provides some IntelliJ support for the archetype scripts.
29+
It supports navigation for the src attributes of <exec> and <source> elements.
30+
Setup:
31+
- Install the plugin named "LivePlugin" from the IntelliJ marketplace.
32+
- Then right click on this script and select "Run live plugin"
33+
- Optionally, enable "Run Plugins on IDE start" on the Live Plugins panel
34+
Development:
35+
- Mark the parent directory as as source or resource root
36+
- Enable "Add LivePlugin and IDE Jars to Project" on the Live Plugins panel
37+
- Resolve imports > Add library to classpath > "LivePlugin and IDE jar"
38+
See:
39+
- https://github.com/dkandalov/live-plugin
40+
- https://gist.github.com/dkandalov/49f17eb3f6a2e87fdb1f2dc3d1eba609
41+
*/
42+
43+
class ArchetypeScriptReference extends PsiPolyVariantReferenceBase<XmlAttributeValue> {
44+
45+
static final String SOURCE_ROOT = "src/main/archetype"
46+
47+
ArchetypeScriptReference(XmlAttributeValue element) {
48+
super(element, true)
49+
}
50+
51+
def fileRef() {
52+
def elementFile = element.containingFile.virtualFile
53+
if (element.value.startsWith("/")) {
54+
def index = elementFile.path.lastIndexOf(SOURCE_ROOT)
55+
def path = elementFile.path.substring(0, index + SOURCE_ROOT.length()) + element.value
56+
return elementFile.fileSystem.findFileByPath(path)
57+
} else {
58+
return elementFile.parent.findFileByRelativePath(element.value)
59+
}
60+
}
61+
62+
@Override
63+
ResolveResult[] multiResolve(boolean incomplete) {
64+
def result = fileRef()
65+
if (result != null) {
66+
def psiManager = PsiManager.getInstance(element.project)
67+
def file = psiManager.findFile(result)
68+
if (file != null) {
69+
return new ResolveResult[]{new PsiElementResolveResult(file)}
70+
}
71+
}
72+
return ResolveResult.EMPTY_ARRAY
73+
}
74+
75+
@Override
76+
boolean isReferenceTo(PsiElement element) {
77+
return false
78+
}
79+
}
80+
81+
class ArchetypeScriptContributor extends PsiReferenceContributor {
82+
83+
@Override
84+
void registerReferenceProviders(PsiReferenceRegistrar registrar) {
85+
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue(), new PsiReferenceProvider() {
86+
@Override
87+
PsiReference[] getReferencesByElement(PsiElement element, ProcessingContext context) {
88+
// enable only for archetype-script documents and src attributes
89+
def doc = PsiTreeUtil.getParentOfType(element, XmlDocument.class)
90+
def attr = PsiTreeUtil.getParentOfType(element, XmlAttribute.class)
91+
def tag = PsiTreeUtil.getParentOfType(element, XmlTag.class)
92+
if (doc != null && doc.rootTag.name == "archetype-script"
93+
&& attr != null && attr.name == "src"
94+
&& tag != null && (tag.name == "exec" || tag.name == "source")) {
95+
return new PsiReference[]{
96+
new ArchetypeScriptReference((XmlAttributeValue) element)
97+
}
98+
}
99+
return PsiReference.EMPTY_ARRAY
100+
}
101+
}, PsiReferenceRegistrar.LOWER_PRIORITY)
102+
}
103+
}
104+
105+
def extension = new PsiReferenceContributorEP().tap {
106+
language = "XML"
107+
implementationClass = ArchetypeScriptContributor.class.name
108+
pluginDescriptor = new DefaultPluginDescriptor(PluginId.getId("LivePlugin"),
109+
ArchetypeScriptContributor.class.classLoader)
110+
}
111+
PsiReferenceContributor.EP_NAME.point.registerExtension(extension, pluginDisposable)

archetypes/archetypes/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Archetype
2+
3+
Document description
4+
5+
## Conventions
6+
7+
### Features
8+
9+
- Must have an HTTP endpoint to exercise the feature (no generic path like 'api' or 'endpoint')
10+
- Must have a unit test class
11+
- Must have README.md documentation
12+
- Must have javadoc following Helidon standard
13+
14+
### Architecture
15+
16+
- directories group (files/features/nodes)
17+
- files names is flexible but has to self explainatory
18+
- inputs and output must be splited
19+
- archetype flow has to go through all inputs and then the output
20+
- paths relative and absolute
21+
- snippet should be placed at the same location then the template (in terms of path)
22+
- files must start at line 1 and end with a new line

archetypes/archetypes/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
<variables>
5050
<text path="helidon-version" transient="true">${project.version}</text>
5151
</variables>
52-
<exec src="flavor.xml"/>
52+
<exec src="inputs.xml"/>
53+
<exec src="output.xml"/>
5354
</entrypoint>
5455
</configuration>
5556
</execution>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
rename readme-sections
2+
3+
Dernières étapes :
4+
5+
Create issue in build-tools for sorted list
6+
7+
Convention:
8+
9+
relative path for subdirectories, absolute path for upper from cwd.
10+
application.yaml have to be under src/main/resources directory -> done
11+
12+
Follow-up issue
13+
14+
- Media should not own the service, it should be abstracted from the media.
15+
16+
17+
write convention in readme

archetypes/archetypes/src/main/archetype/common/common.xml

Lines changed: 0 additions & 64 deletions
This file was deleted.

archetypes/archetypes/src/main/archetype/common/customize-project.xml

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)