jsonschema2pojo maven plugin configuration in execution not considered

Viewed 8543

I am trying to use the jsonschema2pojo plugin for generating POJOs based on both schema and json sourceTypes. The configurations are specified per execution. But every time the plugin is reporting "One of sourceDirectory or sourcePaths must be provided". I am able to run it when the configuration is provided at the plugin level ( global ). But then I can only specify one sourceType.

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jsonschema2pojo</groupId>
                <artifactId>jsonschema2pojo-maven-plugin</artifactId>
                <version>0.5.1</version>
                <executions>
                    <execution>
                        <id>generate-schema</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
                            <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
                            <annotationStyle>jackson2</annotationStyle>
                            <generateBuilders>false</generateBuilders>
                            <initializeCollections>true</initializeCollections>
                            <refFragmentPathDelimiters>#/</refFragmentPathDelimiters>
                            <sourceType>jsonschema</sourceType>
                            <targetPackage>com.company.app.integration.sabre.stub.rest</targetPackage>
                            <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-json</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
                            <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
                            <annotationStyle>jackson2</annotationStyle>
                            <generateBuilders>false</generateBuilders>
                            <initializeCollections>true</initializeCollections>
                            <refFragmentPathDelimiters>#/</refFragmentPathDelimiters>
                            <sourceType>json</sourceType>
                            <targetPackage>com.company.app.integration.sabre.stub.rest</targetPackage>
                            <sourceDirectory>${basedir}/src/main/resources/json</sourceDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

Is there any way to have the plugin use the configuration at execution level per goal ?

Plugin version: 0.5.1

2 Answers

tl;dr

When running the 'compile' from Maven projects lifecycle, the plugin is considering the configuration from execution and is working as expected.


I am using Intellij and was trying to generate the pojo from Plugins -> jsonschema2pojo -> jsonschema2pojo:generate under 'Maven Projects' window. This was giving the above error and was not taking the configuration per execution.

When I run compile from the Maven Lifecycle, it is picking the configuration in the execution and is generating the files as specified.

I am not yet sure if this is a issue with the plugin or maven or if its a issue at all !!

Related