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

    <groupId>com.pangramia.yt</groupId>
    <artifactId>thrift-services</artifactId>
    <!-- This version is for the Thrift API definition. The installable package will use this version. -->
    <version>3.3.0-SNAPSHOT</version>

    <properties>
        <thrift.version>0.16.0</thrift.version>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <!-- Thrift library -->
        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libthrift</artifactId>
            <version>${thrift.version}</version>
        </dependency>
        
        <!-- SLF4J for logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.36</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Thrift compiler plugin -->
            <plugin>
                <groupId>org.apache.thrift.tools</groupId>
                <artifactId>maven-thrift-plugin</artifactId>
                <version>0.1.11</version>

                <configuration>
                    <thriftExecutable>thrift</thriftExecutable>
                    <thriftSourceRoot>${project.basedir}</thriftSourceRoot>
                    <generator>java</generator>
                    <outputDirectory>${project.build.directory}/generated-sources/thrift</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>thrift-sources-java</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>thrift-sources-py</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <generator>py</generator>
                            <outputDirectory>${project.basedir}/gen_py</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Java compiler plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <!-- Clean plugin to remove gen_py directory -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${project.basedir}/gen_py</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
