<?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>takin-common</artifactId>
        <groupId>io.shulie.takin</groupId>
        <version>common-2.0.2-SNAPSHOT</version>
    </parent>

    <artifactId>pinpoint-collector-client</artifactId>
    <version>1.0.2</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libthrift</artifactId>
            <version>0.17.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.3</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>build-thrift</id>
            <properties>
                <thrift.executable>${thrift.executable.path}</thrift.executable>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                            <execution>
                                <id>generate-sources</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <target>
                                        <mkdir dir="${basedir}/generated-sources/thrift" />
                                        <delete>
                                            <fileset dir="${basedir}/generated-sources/thrift" includes="**/*" />
                                        </delete>
                                        <mkdir dir="${basedir}/generated-sources/thrift" />
                                        <exec executable="${thrift.executable}" failonerror="true">
                                            <arg value="--gen" />
                                            <arg value="java:beans" />
                                            <arg value="-o" />
                                            <arg value="${basedir}/generated-sources/thrift" />
                                            <arg value="${basedir}/src/main/thrift/StressTestAgentData.thrift" />
                                        </exec>
                                        <copy todir="src/main/java" overwrite="true">
                                            <fileset dir="${basedir}/generated-sources/thrift/gen-javabean" />
                                        </copy>
                                        <delete dir="${basedir}/generated-sources" />
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>