Skip to content

Commit

Permalink
Update schema
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <[email protected]>
  • Loading branch information
tvallin committed Jan 8, 2025
1 parent 98aba54 commit 6024b5d
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 8 deletions.
11 changes: 4 additions & 7 deletions archetype/engine-v2/src/main/schema/archetype.xsd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021, 2023 Oracle and/or its affiliates.
Copyright (c) 2021, 2025 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 @@ -81,6 +81,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="a:if-group"/>
</xs:complexType>

<xs:complexType name="glob-type">
Expand Down Expand Up @@ -788,6 +789,7 @@
<xs:element name="inputs" type="a:input-types"/>
<xs:element name="step" type="a:step-type"/>
<xs:element name="validations" type="a:validations-type"/>
<xs:element name="output" type="a:output-type"/>
</xs:choice>
</xs:sequence>
</xs:group>
Expand Down Expand Up @@ -843,7 +845,6 @@
<xs:sequence>
<xs:element name="help" type="a:help-type" minOccurs="0"/>
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="output" type="a:output-type" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="a:input-group"/>
<xs:attributeGroup ref="a:name-group"/>
Expand All @@ -869,7 +870,6 @@
<xs:sequence>
<xs:element name="help" type="a:help-type" minOccurs="0"/>
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="output" type="a:output-type" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="value" type="xs:string" use="required">
<xs:annotation>
Expand Down Expand Up @@ -910,7 +910,6 @@
<xs:sequence>
<xs:element name="help" type="a:help-type" minOccurs="0"/>
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="output" type="a:output-type" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="value" type="xs:string" use="required">
<xs:annotation>
Expand Down Expand Up @@ -1004,7 +1003,6 @@
<xs:element name="list" type="a:list-input-type"/>
</xs:choice>
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="output" type="a:output-type" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

Expand All @@ -1024,8 +1022,8 @@
<xs:element name="source" type="a:source-type"/>
<xs:element name="call" type="a:call-type"/>
<xs:element name="inputs" type="a:input-types"/>
<xs:element name="output" type="a:output-type"/>
</xs:choice>
<xs:element name="output" type="a:output-type" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="a:if-group"/>
<xs:attributeGroup ref="a:name-group"/>
Expand Down Expand Up @@ -1344,7 +1342,6 @@
<xs:sequence>
<xs:element name="help" type="a:help-type" minOccurs="0"/>
<xs:group ref="a:directive-group" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="output" type="a:output-type" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="name" use="required">
<xs:annotation>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
* Copyright (c) 2021, 2025 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 @@ -143,6 +143,17 @@ void testInvocationCondition() {
assertThat(values.size(), is(0));
}

@Test
void testOutput() {
Script script = load("controller/output.xml");
Context context = Context.builder()
.cwd(script.scriptPath().getParent())
.build();
List<String> values = modelValues(script, context);
assertThat(values, contains("script1", "script2", "step1", "step2", "inputs1", "inputs2",
"boolean1", "boolean2", "enum1", "enum2", "method1", "method2"));
}

private static List<String> modelValues(Block block, Context context) {
List<String> values = new LinkedList<>();
Controller.walk(new Model.Visitor<>() {
Expand Down
47 changes: 47 additions & 0 deletions archetype/engine-v2/src/test/resources/controller/call.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2025 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.
-->
<archetype-script xmlns="https://helidon.io/archetype/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://helidon.io/archetype/2.0 file:/archetype.xsd">

<methods>
<method name="blue">
<output>
<model>
<value key="color">blue</value>
</model>
</output>
</method>
<method name="red">
<output>
<model>
<value key="color">red</value>
</model>
</output>
</method>
</methods>
<step name="step">
<inputs>
<boolean id="blue" name="Blue" default="true"/>
<boolean id="red" name="Red" default="true"/>
</inputs>
<call method="blue" if="${blue}"/>
<call method="red" if="${red}"/>
</step>
</archetype-script>
114 changes: 114 additions & 0 deletions archetype/engine-v2/src/test/resources/controller/output.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2025 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.
-->
<archetype-script xmlns="https://helidon.io/archetype/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://helidon.io/archetype/2.0 https://helidon.io/xsd/archetype-2.0.xsd">

<methods>
<method name="method">
<output>
<model>
<value key="method1">method1</value>
</model>
</output>
<output>
<model>
<value key="method2">method2</value>
</model>
</output>
</method>
</methods>
<output>
<model>
<value key="script1">script1</value>
</model>
</output>
<output>
<model>
<value key="script2">script2</value>
</model>
</output>
<step name="Step">
<output>
<model>
<value key="step1">step1</value>
</model>
</output>
<output>
<model>
<value key="step2">step2</value>
</model>
</output>
<inputs>
<output>
<model>
<value key="inputs1">inputs1</value>
</model>
</output>
<output>
<model>
<value key="inputs2">inputs2</value>
</model>
</output>
</inputs>
<inputs>
<boolean id="bool" name="Bool">
<output>
<model>
<value key="boolean1">boolean1</value>
</model>
</output>
<output>
<model>
<value key="boolean2">boolean2</value>
</model>
</output>
</boolean>
<enum id="enum" name="Enum" default="option">
<option value="option" name="Option">
<output>
<model>
<value key="enum1">enum1</value>
</model>
</output>
<output>
<model>
<value key="enum2">enum2</value>
</model>
</output>
</option>
</enum>
<list id="list" name="List">
<option value="option" name="Option">
<output>
<model>
<value key="list1">list1</value>
</model>
</output>
<output>
<model>
<value key="list2">list2</value>
</model>
</output>
</option>
</list>
</inputs>
</step>
<call method="method"/>
</archetype-script>

0 comments on commit 6024b5d

Please sign in to comment.