Skip to content

Available Maven Plugin Settings

dermakov edited this page Sep 12, 2024 · 13 revisions

The main way to configure Kobby Maven Plugin is to use plugin execution configuration. The script below shows all available plugin settings with default values in pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <build>
        <plugins>
            <plugin>
                <groupId>io.github.ermadmi78</groupId>
                <artifactId>kobby-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-kotlin</goal>
                        </goals>
                        <configuration>
                            <!-- Schema location and parsing rules configuration -->
                            <schema>
                                <!-- List of GraphQL schema files to generate Kobby DSL -->
                                <!-- By default all `**/*.graphqls` files in `src/main/resources` -->
                                <files>
                                    <file>src/main/resources/my/project/country.graphqls</file>
                                </files>

                                <!-- Configuration of schema files location scanning -->
                                <scan>
                                    <!-- Root directory to scan schema files -->
                                    <dir>src/main/resources</dir>

                                    <!-- List of ANT style include patterns to scan schema files -->
                                    <includes>
                                        <include>**/*.graphqls</include>
                                    </includes>

                                    <!-- List of ANT style exclude patterns to scan schema files -->
                                    <excludes>
                                    </excludes>
                                </scan>

                                <!-- Configuration of Kobby GraphQL directives parsing -->
                                <directive>
                                    <!-- Name of `primaryKey` directive -->
                                    <primaryKey>primaryKey</primaryKey>

                                    <!-- Name of `required` directive -->
                                    <required>required</required>

                                    <!-- Name of `default` directive -->
                                    <default>default</default>

                                    <!-- Name of `selection' directive -->
                                    <selection>selection</selection>
                                </directive>
                            </schema>

                            <!-- Configuration of Kotlin DSL generation -->
                            <kotlin>
                                <!-- Is Kotlin DSL generation enabled-->
                                <enabled>true</enabled>

                                <!-- Mapping GraphQL scalars to Kotlin classes -->
                                <scalars>
                                    <!-- This example maps `JSON` scalar to `Map<String, Any?>` class -->
                                    <!-- GraphQL scalar name-->
                                    <JSON>
                                        <!-- Kotlin package name-->
                                        <packageName>kotlin.collections</packageName>

                                        <!-- Kotlin class name-->
                                        <className>Map</className>

                                        <!-- List of Kotlin class generics -->
                                        <generics>
                                            <generic>
                                                <!-- Generic package name -->
                                                <packageName>kotlin</packageName>

                                                <!-- Generic class name -->
                                                <className>String</className>
                                            </generic>
                                            <generic>
                                                <!-- Generic package name -->
                                                <packageName>kotlin</packageName>

                                                <!-- Generic class name -->
                                                <className>Any</className>

                                                <!-- Is generic nullable. By default is `false` -->
                                                <nullable>true</nullable>
                                            </generic>
                                        </generics>

                                        <!-- Example of Kotlinx Serializer configuration -->
                                        <serializer>
                                            <!-- Serializer package name -->
                                            <packageName>my.serializer</packageName>

                                            <!-- Serializer class name -->
                                            <className>MySerializer</className>
                                        </serializer>
                                    </JSON>
                                </scalars>

                                <!-- Is root package name for generated DSL -->
                                <!-- should be relative to GraphQL schema directory -->
                                <relativePackage>true</relativePackage>

                                <!-- Root package name for generated DSL -->
                                <packageName>kobby.kotlin</packageName>

                                <!-- Output directory for generated DSL -->
                                <outputDirectory>target/generated-sources/kobby-kotlin</outputDirectory>

                                <!-- Configuration of DSL context generation (entry point to DSL) -->
                                <context>
                                    <!-- Context package name relative to root package name -->
                                    <!-- By default, is empty -->
                                    <packageName></packageName>

                                    <!-- Name of generated DSL context -->
                                    <!-- By default, is name of GraphQL schema file -->
                                    <!-- or `graphql` if there are multiple schema files -->
                                    <name>graphql</name>

                                    <!-- Prefix of generated `Context` interface -->
                                    <!-- By default is capitalized context name -->
                                    <prefix></prefix>

                                    <!-- Postfix of generated `Context` interface -->
                                    <postfix></postfix>

                                    <!-- Name of `query` function in `Context` interface -->
                                    <query>query</query>

                                    <!-- Name of `mutation` function in `Context` interface -->
                                    <mutation>mutation</mutation>

                                    <!-- Name of `subscription` function in `Context` interface -->
                                    <subscription>subscription</subscription>

                                    <!-- Is generation of the commit function enabled for subscription -->
                                    <!-- https://github.com/ermadmi78/kobby/issues/31 -->
                                    <commitEnabled>false</commitEnabled>
                                </context>

                                <!-- Configuration of DTO classes generation -->
                                <dto>
                                    <!-- Package name for DTO classes. -->
                                    <!-- Relative to root package name. -->
                                    <packageName>dto</packageName>

                                    <!-- Prefix of DTO classes -->
                                    <!-- generated from GraphQL objects, interfaces and unions -->
                                    <prefix></prefix>

                                    <!-- Postfix of DTO classes -->
                                    <!-- generated from GraphQL objects, interfaces and unions -->
                                    <postfix>Dto</postfix>

                                    <!-- Prefix of DTO classes generated from GraphQL enums -->
                                    <enumPrefix></enumPrefix>

                                    <!-- Postfix of DTO classes generated from GraphQL enums -->
                                    <enumPostfix></enumPostfix>

                                    <!-- Prefix of DTO classes generated from GraphQL inputs -->
                                    <inputPrefix></inputPrefix>

                                    <!-- Postfix of DTO classes generated from GraphQL inputs -->
                                    <inputPostfix></inputPostfix>

                                    <!-- Kobby can generate `equals` and `hashCode` functions -->
                                    <!-- for entities classes -->
                                    <!-- based on fields marked with `@primaryKey` directive. -->
                                    <!-- This parameter provides an ability -->
                                    <!-- to apply the same generation logic to DTO classes -->
                                    <applyPrimaryKeys>false</applyPrimaryKeys>

                                    <!-- Generate immutable DTO class  -->
                                    <!-- if number of GraphQL type fields <= property value. -->
                                    <!-- Otherwise, generate a mutable DTO class. -->
                                    <!-- Set the property value to 0 -->
                                    <!-- to always generate mutable DTO classes. -->
                                    <!-- https://github.com/ermadmi78/kobby/issues/43 -->
                                    <maxNumberOfFieldsForImmutableDtoClass>
                                        245
                                    </maxNumberOfFieldsForImmutableDtoClass>

                                    <!-- Generate immutable Input class -->
                                    <!-- if number of GraphQL Input type fields <= property value. -->
                                    <!-- Otherwise, generate a mutable Input class. -->
                                    <!-- Set the property value to 0 -->
                                    <!-- to always generate mutable Input classes. -->
                                    <!-- https://github.com/ermadmi78/kobby/issues/43 -->
                                    <maxNumberOfFieldsForImmutableInputClass>
                                        245
                                    </maxNumberOfFieldsForImmutableInputClass>

                                    <!-- Configuration of Kotlinx Serialization support -->
                                    <!-- for DTO classes -->
                                    <!-- Note that Kotlinx serialization and Jackson serialization -->
                                    <!-- are not supported simultaneously -->
                                    <serialization>
                                        <!-- Is Kotlinx Serialization enabled -->
                                        <!-- By default, `true` if -->
                                        <!-- `org.jetbrains.kotlinx:kotlinx-serialization-json` -->
                                        <!-- artifact is in the project dependencies -->
                                        <enabled>true</enabled>

                                        <!-- Name of the class descriptor property -->
                                        <!-- for polymorphic serialization -->
                                        <classDiscriminator>__typename</classDiscriminator>

                                        <!-- Specifies whether encounters of unknown properties -->
                                        <!-- in the input JSON should be ignored -->
                                        <!-- instead of throwing SerializationException -->
                                        <ignoreUnknownKeys>true</ignoreUnknownKeys>

                                        <!-- Specifies whether default values of Kotlin properties -->
                                        <!-- should be encoded to JSON -->
                                        <encodeDefaults>false</encodeDefaults>

                                        <!-- Specifies whether resulting JSON -->
                                        <!-- should be pretty-printed -->
                                        <prettyPrint>false</prettyPrint>
                                    </serialization>

                                    <!-- Configuration of Jackson annotations generation -->
                                    <!-- for DTO classes -->
                                    <!-- Note that Kotlinx serialization and Jackson serialization -->
                                    <!-- are not supported simultaneously -->
                                    <jackson>
                                        <!-- Is Jackson annotations generation enabled -->
                                        <!-- By default `true` if -->
                                        <!-- `com.fasterxml.jackson.core:jackson-annotations` -->
                                        <!-- artifact is in the project dependencies -->
                                        <enabled>true</enabled>

                                        <!-- Customize the @JsonTypeInfo -->
                                        <!-- annotation's `use` property. -->
                                        <typeInfoUse>NAME</typeInfoUse>

                                        <!-- Customize the @JsonTypeInfo -->
                                        <!-- annotation's `include` property. -->
                                        <typeInfoInclude>PROPERTY</typeInfoInclude>

                                        <!-- Customize the @JsonTypeInfo -->
                                        <!-- annotation's `property` property. -->
                                        <typeInfoProperty>__typename</typeInfoProperty>

                                        <!-- Customize the @JsonInclude -->
                                        <!-- annotation's `value` property. -->
                                        <jsonInclude>NON_ABSENT</jsonInclude>
                                    </jackson>

                                    <!-- Configuration of DTO builders generation -->
                                    <builder>
                                        <!-- Is DTO builders generation enabled -->
                                        <enabled>true</enabled>

                                        <!-- Prefix of DTO builder classes -->
                                        <prefix></prefix>

                                        <!-- Postfix of DTO builder classes -->
                                        <postfix>Builder</postfix>

                                        <!-- Name of DTO based "toBuilder" function for DTO classes -->
                                        <toBuilderFun>toBuilder</toBuilderFun>

                                        <!-- Name of builder based "toDto" function for DTO classes -->
                                        <toDtoFun>toDto</toDtoFun>

                                        <!-- Name of builder based "toInput" function -->
                                        <!-- for DTO input classes -->
                                        <toInputFun>toInput</toInputFun>

                                        <!-- Name of builder based `copy` function for DTO classes -->
                                        <copyFun>copy</copyFun>
                                    </builder>

                                    <!-- Configuration of helper DTO classes generation -->
                                    <!-- for implementing the GraphQL interaction protocol -->
                                    <graphQL>
                                        <!-- Is helper DTO classes generation enabled -->
                                        <enabled>true</enabled>

                                        <!-- Package name for helper DTO classes -->
                                        <!-- relative to DTO package name -->
                                        <packageName>graphql</packageName>

                                        <!-- Prefix for helper DTO classes -->
                                        <prefix></prefix>

                                        <!-- Postfix for helper DTO classes -->
                                        <postfix></postfix>
                                    </graphQL>
                                </dto>

                                <!-- Configuration of DSL Entities interfaces generation -->
                                <entity>
                                    <!-- Is entities interfaces generation enabled -->
                                    <enabled>true</enabled>

                                    <!-- Package name for entities interfaces -->
                                    <!-- relative to root package name -->
                                    <packageName>entity</packageName>

                                    <!-- Prefix for entities interfaces -->
                                    <prefix></prefix>

                                    <!-- Postfix for entities interfaces -->
                                    <postfix></postfix>

                                    <!-- Generate context access function in entity interface -->
                                    <!-- Default true since release 2.0.0 -->
                                    <!-- https://github.com/ermadmi78/kobby/issues/20 -->
                                    <!-- https://github.com/ermadmi78/kobby/issues/29 -->
                                    <!-- https://github.com/ermadmi78/kobby/issues/35 -->
                                    <contextFunEnabled>true</contextFunEnabled>

                                    <!-- Context access function name in entity interface -->
                                    <!-- https://github.com/ermadmi78/kobby/issues/20 -->
                                    <contextFunName>__context</contextFunName>

                                    <!-- Name of `withCurrentProjection` function in entity interface -->
                                    <withCurrentProjectionFun>
                                        __withCurrentProjection
                                    </withCurrentProjectionFun>

                                    <!-- Configuration of DSL Entity Projection interfaces generation -->
                                    <projection>
                                        <!-- Prefix for projection interfaces -->
                                        <projectionPrefix></projectionPrefix>

                                        <!-- Postfix for projection interfaces -->
                                        <projectionPostfix>Projection</projectionPostfix>

                                        <!-- Name of projection argument in field functions -->
                                        <projectionArgument>__projection</projectionArgument>

                                        <!-- Prefix for projection fields -->
                                        <!-- that are not marked with the directive `@default` -->
                                        <withPrefix></withPrefix>

                                        <!-- Postfix for projection fields -->
                                        <!-- that are not marked with the directive `@default` -->
                                        <withPostfix></withPostfix>

                                        <!-- Prefix for default projection fields -->
                                        <!-- (marked with the directive `@default`) -->
                                        <withoutPrefix>__without</withoutPrefix>

                                        <!-- Postfix for default projection fields -->
                                        <!-- (marked with the directive `@default`) -->
                                        <withoutPostfix></withoutPostfix>

                                        <!-- Name of `minimize` function in projection interface -->
                                        <minimizeFun>__minimize</minimizeFun>

                                        <!-- Prefix for qualification interfaces -->
                                        <qualificationPrefix></qualificationPrefix>

                                        <!-- Postfix for qualification interfaces -->
                                        <qualificationPostfix>Qualification</qualificationPostfix>

                                        <!-- Prefix for qualified projection interface -->
                                        <qualifiedProjectionPrefix></qualifiedProjectionPrefix>

                                        <!-- Postfix for qualified projection interface -->
                                        <qualifiedProjectionPostfix>
                                            QualifiedProjection
                                        </qualifiedProjectionPostfix>

                                        <!-- Prefix for qualification functions -->
                                        <onPrefix>__on</onPrefix>

                                        <!-- Postfix for qualification functions -->
                                        <onPostfix></onPostfix>
                                    </projection>

                                    <!-- Configuration of DSL Entity Selection interfaces generation -->
                                    <selection>
                                        <!-- Prefix for selection interfaces -->
                                        <selectionPrefix></selectionPrefix>

                                        <!-- Postfix for selection interfaces -->
                                        <selectionPostfix>Selection</selectionPostfix>

                                        <!-- Name of selection argument in field functions -->
                                        <selectionArgument>__selection</selectionArgument>

                                        <!-- Prefix for query interfaces -->
                                        <queryPrefix></queryPrefix>

                                        <!-- Postfix for query interfaces -->
                                        <queryPostfix>Query</queryPostfix>

                                        <!-- Name of query argument in field functions -->
                                        <queryArgument>__query</queryArgument>
                                    </selection>
                                </entity>

                                <!-- Configuration of DSL Entities implementation classes generation -->
                                <impl>
                                    <!-- Package name for entities implementation classes -->
                                    <!-- relative to root package name -->
                                    <packageName>entity.impl</packageName>

                                    <!-- Prefix for entities implementation classes -->
                                    <prefix></prefix>

                                    <!-- Postfix for entities implementation classes -->
                                    <postfix>Impl</postfix>

                                    <!-- Is implementation classes should be internal -->
                                    <internal>true</internal>

                                    <!-- Prefix for inner fields in implementation classes -->
                                    <innerPrefix>__inner</innerPrefix>

                                    <!-- Postfix for inner fields in implementation classes -->
                                    <innerPostfix></innerPostfix>
                                </impl>

                                <!-- Configuration of adapter classes generation -->
                                <adapter>
                                    <!-- Configuration of Ktor adapter classes generation -->
                                    <ktor>
                                        <!-- Is simple Ktor adapter generation enabled -->
                                        <!-- By default `true` if `io.ktor:ktor-client-cio-jvm` -->
                                        <!-- artifact is in the project dependencies -->
                                        <simpleEnabled>true</simpleEnabled>

                                        <!-- Is composite Ktor adapter generation enabled -->
                                        <!-- By default `true` if `io.ktor:ktor-client-cio-jvm` -->
                                        <!-- artifact is in the project dependencies -->
                                        <compositeEnabled>true</compositeEnabled>

                                        <!-- Package name for Ktor adapter classes -->
                                        <!-- relative to root package name -->
                                        <packageName>adapter.ktor</packageName>

                                        <!-- Prefix for Ktor adapter classes -->
                                        <prefix></prefix>

                                        <!-- Postfix for Ktor adapter classes -->
                                        <postfix>KtorAdapter</postfix>

                                        <!-- Default receive message timeout in milliseconds -->
                                        <!-- for subscriptions in Ktor composite adapter -->
                                        <!-- https://github.com/ermadmi78/kobby/issues/23 -->
                                        <!-- https://github.com/ermadmi78/kobby/issues/40 -->
                                        <receiveTimeoutMillis>10000</receiveTimeoutMillis>
                                    </ktor>
                                </adapter>
                            </kotlin>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>