Skip to content

Commit a756770

Browse files
authored
Update schema (#1098)
Signed-off-by: tvallin <thibault.vallin@oracle.com>
1 parent fe506cb commit a756770

File tree

4 files changed

+206
-9
lines changed

4 files changed

+206
-9
lines changed

archetype/engine-v2/src/main/schema/archetype.xsd

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2021, 2023 Oracle and/or its affiliates.
4+
Copyright (c) 2021, 2025 Oracle and/or its affiliates.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -81,6 +81,7 @@
8181
</xs:documentation>
8282
</xs:annotation>
8383
</xs:attribute>
84+
<xs:attributeGroup ref="a:if-group"/>
8485
</xs:complexType>
8586

8687
<xs:complexType name="glob-type">
@@ -788,6 +789,7 @@
788789
<xs:element name="inputs" type="a:input-types"/>
789790
<xs:element name="step" type="a:step-type"/>
790791
<xs:element name="validations" type="a:validations-type"/>
792+
<xs:element name="output" type="a:output-type"/>
791793
</xs:choice>
792794
</xs:sequence>
793795
</xs:group>
@@ -843,7 +845,6 @@
843845
<xs:sequence>
844846
<xs:element name="help" type="a:help-type" minOccurs="0"/>
845847
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
846-
<xs:element name="output" type="a:output-type" minOccurs="0"/>
847848
</xs:sequence>
848849
<xs:attributeGroup ref="a:input-group"/>
849850
<xs:attributeGroup ref="a:name-group"/>
@@ -869,7 +870,6 @@
869870
<xs:sequence>
870871
<xs:element name="help" type="a:help-type" minOccurs="0"/>
871872
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
872-
<xs:element name="output" type="a:output-type" minOccurs="0"/>
873873
</xs:sequence>
874874
<xs:attribute name="value" type="xs:string" use="required">
875875
<xs:annotation>
@@ -910,7 +910,6 @@
910910
<xs:sequence>
911911
<xs:element name="help" type="a:help-type" minOccurs="0"/>
912912
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
913-
<xs:element name="output" type="a:output-type" minOccurs="0"/>
914913
</xs:sequence>
915914
<xs:attribute name="value" type="xs:string" use="required">
916915
<xs:annotation>
@@ -1004,7 +1003,6 @@
10041003
<xs:element name="list" type="a:list-input-type"/>
10051004
</xs:choice>
10061005
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
1007-
<xs:element name="output" type="a:output-type" minOccurs="0"/>
10081006
</xs:sequence>
10091007
</xs:complexType>
10101008

@@ -1024,8 +1022,8 @@
10241022
<xs:element name="source" type="a:source-type"/>
10251023
<xs:element name="call" type="a:call-type"/>
10261024
<xs:element name="inputs" type="a:input-types"/>
1025+
<xs:element name="output" type="a:output-type"/>
10271026
</xs:choice>
1028-
<xs:element name="output" type="a:output-type" minOccurs="0"/>
10291027
</xs:sequence>
10301028
<xs:attributeGroup ref="a:if-group"/>
10311029
<xs:attributeGroup ref="a:name-group"/>
@@ -1344,7 +1342,6 @@
13441342
<xs:sequence>
13451343
<xs:element name="help" type="a:help-type" minOccurs="0"/>
13461344
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
1347-
<xs:element name="output" type="a:output-type" minOccurs="0"/>
13481345
</xs:sequence>
13491346
<xs:attribute type="xs:string" name="name" use="required">
13501347
<xs:annotation>
@@ -1368,7 +1365,6 @@
13681365
<xs:element name="help" type="a:help-type" minOccurs="0"/>
13691366
<xs:element name="methods" type="a:method-types" minOccurs="0" />
13701367
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
1371-
<xs:element name="output" type="a:output-type" minOccurs="0"/>
13721368
</xs:sequence>
13731369
</xs:complexType>
13741370
</xs:element>

archetype/engine-v2/src/test/java/io/helidon/build/archetype/engine/v2/ControllerTest.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2021, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package io.helidon.build.archetype.engine.v2;
1818

19+
import java.util.Iterator;
1920
import java.util.LinkedList;
2021
import java.util.List;
2122
import java.util.Map;
@@ -143,6 +144,41 @@ void testInvocationCondition() {
143144
assertThat(values.size(), is(0));
144145
}
145146

147+
@Test
148+
void testOutput() {
149+
Script script = load("controller/output.xml");
150+
Context context = Context.builder()
151+
.cwd(script.scriptPath().getParent())
152+
.build();
153+
List<String> values = modelValues(script, context);
154+
Iterator<String> iterator = values.iterator();
155+
156+
assertThat(values.size(), is(12));
157+
assertThat(iterator.next(), is("script1"));
158+
assertThat(iterator.next(), is("script2"));
159+
assertThat(iterator.next(), is("step1"));
160+
assertThat(iterator.next(), is("step2"));
161+
assertThat(iterator.next(), is("inputs1"));
162+
assertThat(iterator.next(), is("inputs2"));
163+
assertThat(iterator.next(), is("boolean1"));
164+
assertThat(iterator.next(), is("boolean2"));
165+
assertThat(iterator.next(), is("enum1"));
166+
assertThat(iterator.next(), is("enum2"));
167+
assertThat(iterator.next(), is("method1"));
168+
assertThat(iterator.next(), is("method2"));
169+
}
170+
171+
@Test
172+
void testCall() {
173+
Script script = load("controller/call.xml");
174+
Context context = Context.builder()
175+
.cwd(script.scriptPath().getParent())
176+
.build();
177+
List<String> values = modelValues(script, context);
178+
179+
assertThat(values, contains("blue"));
180+
}
181+
146182
private static List<String> modelValues(Block block, Context context) {
147183
List<String> values = new LinkedList<>();
148184
Controller.walk(new Model.Visitor<>() {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2025 Oracle and/or its affiliates.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<archetype-script xmlns="https://helidon.io/archetype/2.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="https://helidon.io/archetype/2.0 file:/archetype.xsd">
22+
23+
<methods>
24+
<method name="blue">
25+
<output>
26+
<model>
27+
<value key="color">blue</value>
28+
</model>
29+
</output>
30+
</method>
31+
<method name="red">
32+
<output>
33+
<model>
34+
<value key="color">red</value>
35+
</model>
36+
</output>
37+
</method>
38+
</methods>
39+
<step name="step">
40+
<presets>
41+
<boolean path="blue">true</boolean>
42+
<boolean path="red">false</boolean>
43+
</presets>
44+
<inputs>
45+
<boolean id="blue" name="Blue" default="true"/>
46+
<boolean id="red" name="Red" default="false"/>
47+
</inputs>
48+
<call method="blue" if="${blue}"/>
49+
<call method="red" if="${red}"/>
50+
</step>
51+
</archetype-script>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2025 Oracle and/or its affiliates.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<archetype-script xmlns="https://helidon.io/archetype/2.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="https://helidon.io/archetype/2.0 https://helidon.io/xsd/archetype-2.0.xsd">
22+
23+
<methods>
24+
<method name="method">
25+
<output>
26+
<model>
27+
<value key="method1">method1</value>
28+
</model>
29+
</output>
30+
<output>
31+
<model>
32+
<value key="method2">method2</value>
33+
</model>
34+
</output>
35+
</method>
36+
</methods>
37+
<output>
38+
<model>
39+
<value key="script1">script1</value>
40+
</model>
41+
</output>
42+
<output>
43+
<model>
44+
<value key="script2">script2</value>
45+
</model>
46+
</output>
47+
<step name="Step">
48+
<output>
49+
<model>
50+
<value key="step1">step1</value>
51+
</model>
52+
</output>
53+
<output>
54+
<model>
55+
<value key="step2">step2</value>
56+
</model>
57+
</output>
58+
<inputs>
59+
<output>
60+
<model>
61+
<value key="inputs1">inputs1</value>
62+
</model>
63+
</output>
64+
<output>
65+
<model>
66+
<value key="inputs2">inputs2</value>
67+
</model>
68+
</output>
69+
</inputs>
70+
<inputs>
71+
<boolean id="bool" name="Bool">
72+
<output>
73+
<model>
74+
<value key="boolean1">boolean1</value>
75+
</model>
76+
</output>
77+
<output>
78+
<model>
79+
<value key="boolean2">boolean2</value>
80+
</model>
81+
</output>
82+
</boolean>
83+
<enum id="enum" name="Enum" default="option">
84+
<option value="option" name="Option">
85+
<output>
86+
<model>
87+
<value key="enum1">enum1</value>
88+
</model>
89+
</output>
90+
<output>
91+
<model>
92+
<value key="enum2">enum2</value>
93+
</model>
94+
</output>
95+
</option>
96+
</enum>
97+
<list id="list" name="List">
98+
<option value="option" name="Option">
99+
<output>
100+
<model>
101+
<value key="list1">list1</value>
102+
</model>
103+
</output>
104+
<output>
105+
<model>
106+
<value key="list2">list2</value>
107+
</model>
108+
</output>
109+
</option>
110+
</list>
111+
</inputs>
112+
</step>
113+
<call method="method"/>
114+
</archetype-script>

0 commit comments

Comments
 (0)