<?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>

    <parent>
        <artifactId>quickbuf-parent</artifactId>
        <groupId>us.hebi.quickbuf</groupId>
        <version>1.1.0</version>
    </parent>

    <artifactId>quickbuf-compat</artifactId>

    <properties>
        <javaModuleName>us.hebi.quickbuf.compat</javaModuleName>
        <maven.compiler.source>6</maven.compiler.source>
        <maven.compiler.target>6</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>quickbuf-runtime</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>quickbuf-runtime</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency> <!-- optionally supplied by user -->
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency> <!-- optionally supplied by user -->
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Generate sources via plugin -->
            <plugin>
                <groupId>com.github.os72</groupId>
                <artifactId>protoc-jar-maven-plugin</artifactId>
                <version>${protoc.jar.version}</version>
                <executions>
                    <execution>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <protocVersion>${protobuf.version}</protocVersion>

                            <inputDirectories>
                                <include>${proto.dir}/</include>
                            </inputDirectories>

                            <outputTargets>

                                <!-- Generate sources (override package so we don't have name collisions with gen-java) -->
                                <outputTarget>
                                    <!-- Linux finds absolute file, Windows finds it via executing PATH -->
                                    <pluginPath>
                                        ${project.parent.basedir}/generator/target/protoc-gen-quickbuf${protoc.pluginExt}
                                    </pluginPath>
                                    <type>quickbuf</type>
                                    <outputOptions>
                                        replace_package=(protos.test.protobuf)=protos.test.quickbuf,indent=4,store_unknown_fields=true,enforce_has_checks=false,input_order=quickbuf
                                    </outputOptions>
                                    <addSources>test</addSources>
                                </outputTarget>

                                <!-- Generate Java sources for sanity checks -->
                                <outputTarget>
                                    <type>java</type>
                                    <addSources>test</addSources>
                                </outputTarget>

                            </outputTargets>

                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Plugins required for publishing to Maven Central -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jdk17compat</id>
            <activation>
                <jdk>(11,)</jdk>
            </activation>
            <properties>
                <!-- increase language level for jdk11+ to allow compiling. Release with 8 or 11 -->
                <maven.compiler.source>7</maven.compiler.source>
                <maven.compiler.target>7</maven.compiler.target>
            </properties>
        </profile>
    </profiles>

</project>