Skip to content

Commit 51ceb49

Browse files
authored
[plugin] update Maven Mojo names to follow hyphen-name (#719)
* [plugin] update Maven Mojo names to follow hyphen-name Maven plugins generally follow `hyphen-name` for defining different Mojos and build lifecycle phases. Updating GraphQL Kotlin Maven plugin to follow the convention. * fix build We can execute multiple goals in single execution OR specify execution IDs for each execution
1 parent 2e63572 commit 51ceb49

File tree

12 files changed

+40
-72
lines changed

12 files changed

+40
-72
lines changed

docs/plugins/maven-plugin.md

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ GraphQL Kotlin Maven Plugin provides functionality to introspect GraphQL schemas
99

1010
You can find detailed information about `graphql-kotlin-maven-plugin` and all its goals by running `mvn help:describe -Dplugin=com.expediagroup:graphql-kotlin-maven-plugin -Ddetail`.
1111

12-
### downloadSDL
12+
### download-sdl
1313

1414
GraphQL endpoints are often public and as such many servers might disable introspection queries in production environment.
1515
Since GraphQL schema is needed to generate type safe clients, as alternative GraphQL servers might expose private
1616
endpoints (e.g. accessible only from within network, etc) that could be used to download schema in Schema Definition
1717
Language (SDL) directly. This Mojo attempts to download schema from the specified `graphql.endpoint`, validates the
1818
result whether it is a valid schema and saves it locally as `schema.graphql` under build directory. In general, this
1919
goal provides limited functionality by itself and instead should be used to generate input for the subsequent
20-
`generateClient` goal.
20+
`generate-client` goal.
2121

2222
**Attributes**
2323

@@ -29,7 +29,7 @@ goal provides limited functionality by itself and instead should be used to gene
2929
| -------- | ---- | -------- | ----------- |
3030
| `endpoint` | String | yes | Target GraphQL server SDL endpoint that will be used to download schema.<br/>**User property is**: `graphql.endpoint`. |
3131

32-
### generateClient
32+
### generate-client
3333

3434
Generate GraphQL client code based on the provided GraphQL schema and target queries.
3535

@@ -68,7 +68,7 @@ Generate GraphQL client code based on the provided GraphQL schema and target que
6868
</converters>
6969
```
7070

71-
### generateTestClient
71+
### generate-test-client
7272

7373
Generate GraphQL test client code based on the provided GraphQL schema and target queries.
7474

@@ -107,11 +107,11 @@ Generate GraphQL test client code based on the provided GraphQL schema and targe
107107
</converters>
108108
```
109109

110-
### introspectSchema
110+
### introspect-schema
111111

112112
Executes GraphQL introspection query against specified `graphql.endpoint` and saves the underlying schema file as
113113
`schema.graphql` under build directory. In general, this goal provides limited functionality by itself and instead
114-
should be used to generate input for the subsequent `generateClient` goal.
114+
should be used to generate input for the subsequent `generate-client` goal.
115115

116116
**Attributes**
117117

@@ -127,11 +127,11 @@ should be used to generate input for the subsequent `generateClient` goal.
127127

128128
### Downloading Schema SDL
129129

130-
DownloadSDL Mojo requires target GraphQL server `endpoint` to be specified. Task can be executed directly from the
130+
Download SDL Mojo requires target GraphQL server `endpoint` to be specified. Task can be executed directly from the
131131
command line by explicitly specifying `graphql.endpoint` property.
132132

133133
```shell script
134-
$ mvn com.expediagroup:graphql-kotlin-maven-plugin:downloadSDL -Dgraphql.endpoint="http://localhost:8080/sdl"
134+
$ mvn com.expediagroup:graphql-kotlin-maven-plugin:download-sdl -Dgraphql.endpoint="http://localhost:8080/sdl"
135135
```
136136

137137
Mojo can also be configured in your Maven build file
@@ -143,9 +143,8 @@ Mojo can also be configured in your Maven build file
143143
<version>${graphql-kotlin.version}</version>
144144
<executions>
145145
<execution>
146-
<id>download-sdl</id>
147146
<goals>
148-
<goal>downloadSDL</goal>
147+
<goal>download-sdl</goal>
149148
</goals>
150149
<configuration>
151150
<endpoint>http://localhost:8080/sdl</endpoint>
@@ -155,15 +154,15 @@ Mojo can also be configured in your Maven build file
155154
</plugin>
156155
```
157156

158-
By default, `downloadSDL` goal will be executed as part of the `generate-sources` [build lifecycle phase](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html).
157+
By default, `download-sdl` goal will be executed as part of the `generate-sources` [build lifecycle phase](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html).
159158

160159
### Introspecting Schema
161160

162161
Introspection Mojo requires target GraphQL server `endpoint` to be specified. Task can be executed directly from the
163162
command line by explicitly specifying `graphql.endpoint` property
164163

165164
```shell script
166-
$ mvn com.expediagroup:graphql-kotlin-maven-plugin:introspectSchema -Dgraphql.endpoint="http://localhost:8080/graphql"
165+
$ mvn com.expediagroup:graphql-kotlin-maven-plugin:introspect-schema -Dgraphql.endpoint="http://localhost:8080/graphql"
167166
```
168167

169168
Mojo can also be configured in your Maven build file
@@ -175,9 +174,8 @@ Mojo can also be configured in your Maven build file
175174
<version>${graphql-kotlin.version}</version>
176175
<executions>
177176
<execution>
178-
<id>introspect-schema</id>
179177
<goals>
180-
<goal>introspectSchema</goal>
178+
<goal>introspect-schema</goal>
181179
</goals>
182180
<configuration>
183181
<endpoint>http://localhost:8080/graphql</endpoint>
@@ -187,7 +185,7 @@ Mojo can also be configured in your Maven build file
187185
</plugin>
188186
```
189187

190-
By default, `introspectSchema` goal will be executed as part of the `generate-sources` [build lifecycle phase](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html).
188+
By default, `introspect-schema` goal will be executed as part of the `generate-sources` [build lifecycle phase](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html).
191189

192190
### Generating Client
193191

@@ -196,7 +194,7 @@ generated under specified `packageName`. When using default configuration and st
196194
directories, task can be executed directly from the command line by explicitly providing required properties.
197195

198196
```shell script
199-
$ mvn com.expediagroup:graphql-kotlin-maven-plugin:generateClient -Dgraphql.schemaFile="mySchema.graphql" -Dgraphql.packageName="com.example.generated"
197+
$ mvn com.expediagroup:graphql-kotlin-maven-plugin:generate-client -Dgraphql.schemaFile="mySchema.graphql" -Dgraphql.packageName="com.example.generated"
200198
```
201199

202200
Mojo can also be configured in your Maven build file and it provides additional configuration options
@@ -208,9 +206,8 @@ Mojo can also be configured in your Maven build file and it provides additional
208206
<version>${graphql-kotlin.version}</version>
209207
<executions>
210208
<execution>
211-
<id>generate-client</id>
212209
<goals>
213-
<goal>generateClient</goal>
210+
<goal>generate-client</goal>
214211
</goals>
215212
<configuration>
216213
<packageName>com.example.generated</packageName>
@@ -261,9 +258,8 @@ Afterwards we need to configure our plugin to use this custom converter
261258
<version>${graphql-kotlin.version}</version>
262259
<executions>
263260
<execution>
264-
<id>generate-client</id>
265261
<goals>
266-
<goal>generateClient</goal>
262+
<goal>generate-client</goal>
267263
</goals>
268264
<configuration>
269265
<allowDeprecatedFields>false</allowDeprecatedFields>
@@ -297,20 +293,12 @@ This generated schema is subsequently used to generate GraphQL client code based
297293
<version>${graphql-kotlin.version}</version>
298294
<executions>
299295
<execution>
300-
<id>introspect-schema</id>
301296
<goals>
302-
<goal>introspectSchema</goal>
297+
<goal>introspect-schema</goal>
298+
<goal>generate-client</goal>
303299
</goals>
304300
<configuration>
305301
<endpoint>http://localhost:8080/graphql</endpoint>
306-
</configuration>
307-
</execution>
308-
<execution>
309-
<id>generate-client</id>
310-
<goals>
311-
<goal>generateClient</goal>
312-
</goals>
313-
<configuration>
314302
<packageName>com.example.generated</packageName>
315303
<schemaFile>${project.build.directory}/schema.graphql</schemaFile>
316304
</configuration>
@@ -319,6 +307,6 @@ This generated schema is subsequently used to generate GraphQL client code based
319307
</plugin>
320308
```
321309

322-
>NOTE: Both `introspectSchema` and `generateClient` goals are bound to the same `generate-sources` Maven lifecycle phase.
310+
>NOTE: Both `introspect-schema` and `generate-client` goals are bound to the same `generate-sources` Maven lifecycle phase.
323311
>As opposed to Gradle, Maven does not support explicit ordering of goals. Maven Mojos will be executed in the order they
324-
>are defined in your `pom.xml` build file.
312+
>are defined in your `pom.xml` build file.

examples/client/maven-client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<execution>
5050
<id>introspect-schema</id>
5151
<goals>
52-
<goal>introspectSchema</goal>
52+
<goal>introspect-schema</goal>
5353
</goals>
5454
<configuration>
5555
<endpoint>http://localhost:8080/graphql</endpoint>
@@ -58,7 +58,7 @@
5858
<execution>
5959
<id>generate-client</id>
6060
<goals>
61-
<goal>generateClient</goal>
61+
<goal>generate-client</goal>
6262
</goals>
6363
<configuration>
6464
<packageName>com.expediagroup.graphql.generated</packageName>

plugins/graphql-kotlin-maven-plugin/README.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@ Plugin should be configured as part of your `pom.xml` build file.
1616
<version>${graphql-kotlin.version}</version>
1717
<executions>
1818
<execution>
19-
<id>introspect-schema</id>
2019
<goals>
21-
<goal>introspectSchema</goal>
20+
<goal>introspect-schema</goal>
21+
<goal>generate-client</goal>
2222
</goals>
2323
<configuration>
2424
<endpoint>http://localhost:8080/graphql</endpoint>
25-
</configuration>
26-
</execution>
27-
<execution>
28-
<id>generate-client</id>
29-
<goals>
30-
<goal>generateClient</goal>
31-
</goals>
32-
<configuration>
3325
<packageName>com.expediagroup.graphql.generated</packageName>
3426
<schemaFile>${project.build.directory}/schema.graphql</schemaFile>
3527
</configuration>
@@ -40,11 +32,11 @@ Plugin should be configured as part of your `pom.xml` build file.
4032

4133
## Goals
4234

43-
### downloadSDL
35+
### download-sdl
4436

4537
This Mojo attempts to download schema from the specified `graphql.endpoint`, validates the result whether it is a valid
4638
schema and saves it locally as `schema.graphql` under build directory. In general, this goal provides limited functionality
47-
by itself and instead should be used to generate input for the subsequent `generateClient` goal.
39+
by itself and instead should be used to generate input for the subsequent `generate-client` goal.
4840

4941
**Attributes**
5042

@@ -56,7 +48,7 @@ by itself and instead should be used to generate input for the subsequent `gener
5648
| -------- | ---- | -------- | ----------- |
5749
| `endpoint` | String | yes | Target GraphQL server SDL endpoint that will be used to download schema.<br/>**User property is**: `graphql.endpoint`. |
5850

59-
### generateClient
51+
### generate-client
6052

6153
Generate GraphQL client code based on the provided GraphQL schema and target queries.
6254

@@ -95,7 +87,7 @@ Generate GraphQL client code based on the provided GraphQL schema and target que
9587
</converters>
9688
```
9789

98-
### generateTestClient
90+
### generate-test-client
9991

10092
Generate GraphQL test client code based on the provided GraphQL schema and target queries.
10193

@@ -134,11 +126,11 @@ Generate GraphQL test client code based on the provided GraphQL schema and targe
134126
</converters>
135127
```
136128

137-
### introspectSchema
129+
### introspect-schema
138130

139131
Executes GraphQL introspection query against specified `graphql.endpoint` and saves the underlying schema file as
140132
`schema.graphql` under build directory. In general, this goal provides limited functionality by itself and instead
141-
should be used to generate input for the subsequent `generateClient` goal.
133+
should be used to generate input for the subsequent `generate-client` goal.
142134

143135
**Attributes**
144136

plugins/graphql-kotlin-maven-plugin/src/integration/complete-setup/pom.xml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,12 @@
8282
<version>@graphql-kotlin.version@</version>
8383
<executions>
8484
<execution>
85-
<id>introspect-schema</id>
8685
<goals>
87-
<goal>introspectSchema</goal>
86+
<goal>introspect-schema</goal>
87+
<goal>generate-client</goal>
8888
</goals>
8989
<configuration>
9090
<endpoint>@graphql.endpoint@/graphql</endpoint>
91-
</configuration>
92-
</execution>
93-
<execution>
94-
<id>generate-client</id>
95-
<goals>
96-
<goal>generateClient</goal>
97-
</goals>
98-
<configuration>
9991
<packageName>com.expediagroup.graphql.plugin.generated</packageName>
10092
<schemaFile>${project.build.directory}/schema.graphql</schemaFile>
10193
<converters>

plugins/graphql-kotlin-maven-plugin/src/integration/download-sdl/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@
7676
<version>@graphql-kotlin.version@</version>
7777
<executions>
7878
<execution>
79-
<id>download-sdl</id>
8079
<goals>
81-
<goal>downloadSDL</goal>
80+
<goal>download-sdl</goal>
8281
</goals>
8382
<configuration>
8483
<endpoint>@graphql.endpoint@/sdl</endpoint>

plugins/graphql-kotlin-maven-plugin/src/integration/generate-client/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@
8282
<version>@graphql-kotlin.version@</version>
8383
<executions>
8484
<execution>
85-
<id>generate-client</id>
8685
<goals>
87-
<goal>generateClient</goal>
86+
<goal>generate-client</goal>
8887
</goals>
8988
<configuration>
9089
<packageName>com.expediagroup.graphql.plugin.generated</packageName>

plugins/graphql-kotlin-maven-plugin/src/integration/generate-test-client/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@
8282
<version>@graphql-kotlin.version@</version>
8383
<executions>
8484
<execution>
85-
<id>generate-client</id>
8685
<goals>
87-
<goal>generateTestClient</goal>
86+
<goal>generate-test-client</goal>
8887
</goals>
8988
<configuration>
9089
<packageName>com.expediagroup.graphql.plugin.generated</packageName>

plugins/graphql-kotlin-maven-plugin/src/integration/introspect-schema/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@
7777
</configuration>
7878
<executions>
7979
<execution>
80-
<id>introspect-schema</id>
8180
<goals>
82-
<goal>introspectSchema</goal>
81+
<goal>introspect-schema</goal>
8382
</goals>
8483
<configuration>
8584
<endpoint>@graphql.endpoint@/graphql</endpoint>

plugins/graphql-kotlin-maven-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/maven/DownloadSDLMojo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import java.io.File
2727
/**
2828
* Download GraphQL schema from a specified SDL endpoint.
2929
*/
30-
@Mojo(name = "downloadSDL", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
30+
@Mojo(name = "download-sdl", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
3131
class DownloadSDLMojo : AbstractMojo() {
3232

3333
/**

plugins/graphql-kotlin-maven-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/maven/GenerateClientMojo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.io.File
2626
* Generate GraphQL Kotlin client data model based on the provided GraphQL schema and target queries. Upon successful client generation
2727
* project main sources will be updated with newly generated client code.
2828
*/
29-
@Mojo(name = "generateClient", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
29+
@Mojo(name = "generate-client", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
3030
class GenerateClientMojo : GenerateClientAbstractMojo() {
3131

3232
/**

0 commit comments

Comments
 (0)