<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>config-lib</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.wildfly</groupId>
        <artifactId>api-gen-parent</artifactId>
        <version>0.1.0.Final</version>
        <relativePath>../</relativePath>
    </parent>

    <dependencies>

        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>api-gen</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.4.0</version>

                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.wildfly.apigen.generator.Generator</mainClass>
                            <arguments>
                                <argument>${project.basedir}/src/main/resources/generator-config.json</argument>
                                <argument>${project.build.directory}/generated-sources</argument>
                            </arguments>
                            <systemProperties>
                                <systemProperty>
                                    <key>java.util.logging.SimpleFormatter.format</key>
                                    <value>%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$-6s %2$s %5$s%6$s%n</value>
                                </systemProperty>
                            </systemProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.16</version>
                <executions>
                    <execution>
                        <id>verify</id>
                        <phase>verify</phase>
                        <configuration>
                            <sourceDirectories>
                                <sourceDirectory>
                                    ${project.build.directory}/generated-sources
                                </sourceDirectory>
                            </sourceDirectories>
                            <configLocation>checkstyle.xml</configLocation>
                            <encoding>UTF-8</encoding>
                            <consoleOutput>true</consoleOutput>
                            <logViolationsToConsole>true</logViolationsToConsole>
                            <failsOnError>true</failsOnError>
                        </configuration>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>APIGEN_CFG_DIR</name>
                            <value>${project.basedir}/src/main/resources</value>
                        </property>
                        <property>
                            <name>java.util.logging.SimpleFormatter.format</name>
                            <value>%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$-6s %2$s %5$s%6$s%n</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>