<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright Kroxylicious Authors.

    Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0

-->
<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>

    <parent>
        <groupId>io.kroxylicious</groupId>
        <artifactId>kroxylicious-parent</artifactId>
        <version>0.5.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>kroxylicious-krpc-plugin</artifactId>
    <name>Code generation plugin</name>
    <packaging>maven-plugin</packaging>

    <properties>
        <maven-plugin-api.version>3.9.6</maven-plugin-api.version>
        <maven-plugin-annotations.version>3.11.0</maven-plugin-annotations.version>
        <maven-core.version>3.9.6</maven-core.version>
        <plexus-build-api.version>1.2.0</plexus-build-api.version>
    </properties>

    <dependencies>
        <!-- third party dependencies - runtime and compile -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>${maven-core.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>${maven-plugin-api.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>${maven-plugin-annotations.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <!-- according to https://github.com/codehaus-plexus/plexus-build-api this replaces org.sonatype.plexus:plexus-build-api -->
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-build-api</artifactId>
            <version>${plexus-build-api.version}</version>
        </dependency>

        <!-- third party dependencies - test -->
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <excludePackageNames>io.kroxylicious.krpccodegen.schema</excludePackageNames>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-message-specs</id>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <artifact>org.apache.kafka:kafka-clients:${kafka.version}</artifact>
                            <includes>common/message/*.json</includes>
                            <outputDirectory>${project.build.directory}/message-specs</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- We need to ensure that the descriptor is generated at compile phase -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-descriptor</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <goalPrefix>kroxylicious-krpc</goalPrefix>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
