Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Maven Plugin Setup

Shaun Francis edited this page Sep 6, 2017 · 1 revision

Add the following plugin to your root maven pom:

<plugin>
    <artifactId>generator-plugin</artifactId>
    <groupId>uk.gov.justice.maven.generator</groupId>
    <version>${generator-maven-plugin.version}</version>
    <executions>
        <execution>
            <id>internal-jsons</id>
            <configuration>
                <generatorName>uk.gov.justice.generation.SchemaToJavaGenerator</generatorName>
                <basePackageName>uk.gov.justice.events.pojo</basePackageName>
                <sourceDirectory>${basedir}/src/main/resources/events/json/schema</sourceDirectory>
                <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
                <parserName>uk.gov.justice.generation.io.files.parser.FileTypeParser</parserName>
                <includes>
                    <include>**/*.json</include>
                </includes>
                <excludes>
                </excludes>
            </configuration>
            <goals>
                <goal>generate</goal>
            </goals>
            <phase>generate-sources</phase>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>uk.gov.justice.generators</groupId>
            <artifactId>pojo-generation-core</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</plugin>

The following properties are relevant and should be adjusted to taste:

basePackageName:

<basePackageName>uk.gov.justice.events.pojo</basePackageName>

The package name of the generated pojo classes

sourceDirectory:

<sourceDirectory>${basedir}/src/main/resources/events/json/schema</sourceDirectory>

The directory where the json schema file should be found. This is then further refined using maven include/exclude tags:

<includes>
	<include>**/*.json</include>
</includes>
<excludes>
</excludes>

outputDirectory:

<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>

The directory that the java code will be generated to. This should usually be the 'generated-sources' directory in target as they will then be compiled into your application during the maven compile phase.

Clone this wiki locally