You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* `<id/>`, maven wants this. It is not used by the processor.
103
85
* `*<apiPath/>*`, defines the path to the openapi yaml file. This is usually the same for all processors and adding it directly into the plugin `<configuration/>` block sets it for all processors.
104
86
105
87
Next step is to configure the goals for processing. The plugin has only a single goal `process` that can run any processor. It is configured by an `<execution/>` element to run a specific processor.
@@ -113,7 +95,7 @@ Here is an example to run `openapi-processor-spring` that explains the configura
113
95
<plugin>
114
96
<executions>
115
97
<execution>
116
-
<id>spring</id> <!--1-->
98
+
<id>spring-interfaces</id> <!--1-->
117
99
<phase>generate-sources</phase> <!--2-->
118
100
119
101
<configuration>
@@ -153,7 +135,7 @@ Here is an example to run `openapi-processor-spring` that explains the configura
153
135
154
136
<2> `*<phase/>*` **phase** (mandatory): openapi-processor-spring generates java code, so the `<phase/>` should be `generate-source`. This tells maven to run the goal before compiling anything.
155
137
156
-
<3> `*<id/>*` **processor id** (mandatory): this configures the openapi-processor the goal should run. The processor id must match exactly with the name of the processor. The convention is, that the last part of the processors artifact name is the processor id.
138
+
<3> `*<id/>*` **processor id** (mandatory): this configures the openapi-processor the goal should run. The processor id must match exactly with the name of the processor. The convention is, that the last part of the processor artifact name is the processor id.
157
139
+
158
140
If the artifact of a processor is called `openapi-processor-x`, the last part `x` is the id of the processor. For example for `openapi-processor-spring` the id is `spring`, for `openapi-processor-json` the id is `json`.
159
141
@@ -191,7 +173,7 @@ To run a second processor add another `<execution>` element. Here is an example
191
173
<plugin>
192
174
<executions>
193
175
<execution>
194
-
<id>spring</id>
176
+
<id>spring-interfaces</id>
195
177
<phase>generate-sources</phase>
196
178
197
179
<configuration>
@@ -201,7 +183,7 @@ To run a second processor add another `<execution>` element. Here is an example
201
183
</execution>
202
184
203
185
<execution>
204
-
<id>json</id>
186
+
<id>json-resource</id>
205
187
<phase>generate-resources</phase> <!--1-->
206
188
207
189
<configuration>
@@ -215,6 +197,50 @@ To run a second processor add another `<execution>` element. Here is an example
215
197
216
198
<1> uses `generate-resources` phase for the json output, to consider it as a resource.
217
199
200
+
== executing the goal
201
+
202
+
The `<execution>` s created in the previous chapter will automatically run the processor in the given `<phase>` s with commands like `./mvnw compile`.
203
+
204
+
Running the goal directly with `./mvnw openapi-processor:process` to check the source code generation will not work because there is no configuration without `<phase>`.
205
+
206
+
=== selecting an execution
207
+
208
+
This can be solved in two ways:
209
+
210
+
First, it is possible to the run the goal with an explicit `<execution>` like this:
where `spring-interfaces` is the `<id>` of the execution.
218
+
219
+
== adding a default execution
220
+
221
+
The other solution is to change the `execution` that should run by default to a default `<execution>`. When running `./mvnw openapi-processor:process` from the shell, maven will look for an `<execution>` with the id `<id>default-cli</id>` and if available run it.
222
+
223
+
[source,xml]
224
+
----
225
+
<plugin>
226
+
<executions>
227
+
<execution>
228
+
<id>default-cli</id> <!--1-->
229
+
<phase>generate-sources</phase>
230
+
231
+
<configuration>
232
+
<id>spring</id>
233
+
<!-- ... -->
234
+
</configuration>
235
+
</execution>
236
+
</executions>
237
+
</plugin>
238
+
----
239
+
240
+
<1> using maven's default execution id instead of a user selected id.
241
+
242
+
With this configuration maven will use it when directly running the `process` goal from the shell, and it will also run it when the given phase is active.
0 commit comments