<?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>
        <groupId>tech.aroma</groupId>
        <artifactId>aroma</artifactId>
        <version>3.2</version>
    </parent>

    <artifactId>aroma-thrift</artifactId>
    <version>2.2</version>
    <name>${project.artifactId}</name>
    <packaging>jar</packaging>

    <url>https://github.com/RedRoma/aroma-thrift</url>
    <description>
        Part of the Aroma Project.
        This project contains the Service and Model Definitions.
        From this the Server and Client interfaces are generated for the Aroma Service.
    </description>

    <issueManagement>
        <system>GitHub Issues</system>
        <url>https://github.com/RedRoma/aroma-thrift/issues</url>
    </issueManagement>

    <scm>
        <connection>scm:git:git@github.com:RedRoma/aroma-thrift.git</connection>
        <developerConnection>scm:git:git@github.com:RedRoma/aroma-thrift.git</developerConnection>
        <url>git@github.com:RedRoma/aroma-thrift-annotations.git</url>
    </scm>

    <inceptionYear>2015</inceptionYear>

    <prerequisites>
        <maven>3.0.3</maven>
    </prerequisites>

    <!-- END OF POM METADATA -->

    <properties>

        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>

        <!--Thrift Compiler Properties-->
        <thrift.compiler>thrift</thrift.compiler>
        <src.main>${project.basedir}/src/main</src.main>
        <src.thrift.dir>${src.main}/thrift</src.thrift.dir>
        <thrift.dest.dir> ${project.build.directory}/generated-sources/thrift</thrift.dest.dir>
        <thrift.dest.dir.java>${project.build.directory}/generated-sources/java</thrift.dest.dir.java>
        <thrift.dest.dir.doc>${project.basedir}/src/main/docs</thrift.dest.dir.doc>
        <thrift.dest.dir.js>${project.basedir}/src/main/js</thrift.dest.dir.js>
        <thrift.dest.dir.node>${project.basedir}/src/main/nodejs</thrift.dest.dir.node>
        <thrift.dest.dir.cpp>${project.basedir}/src/main/cpp</thrift.dest.dir.cpp>
        <thrift.dest.dir.cocoa>${project.basedir}/src/main/cocoa</thrift.dest.dir.cocoa>
        <thrift.dest.dir.php>${project.basedir}/src/main/php</thrift.dest.dir.php>

        <kotlin.version>1.2.71</kotlin.version>
    </properties>

    <dependencies>

        <!--=======================-->
        <!--UNIT TESTING-->
        <!--=======================-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.nhaarman</groupId>
            <artifactId>mockito-kotlin</artifactId>
        </dependency>

        <dependency>
            <groupId>com.natpryce</groupId>
            <artifactId>hamkrest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit</artifactId>
            <scope>test</scope>
        </dependency>


        <!--=======================-->
        <!--ALCHEMY-->
        <!--=======================-->
        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-annotations</artifactId>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-arguments</artifactId>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-thrift</artifactId>
        </dependency>


        <!--=======================-->
        <!--THRIFT-->
        <!--=======================-->
        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libthrift</artifactId>
            <version>0.11.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpcore</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <!--=======================-->
        <!--APACHE HTTP CORE-->
        <!--=======================-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.10</version>
        </dependency>

        <!--=======================-->
        <!--KOTLIN-->
        <!--=======================-->
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk7</artifactId>
            <version>${kotlin.version}</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <!--COMPILE THE THRIFT SOURCE-->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <configuration>
                            <target>
                                <!-- Define fileset of thrift files -->
                                <fileset id="thrift.src.files" dir="${src.thrift.dir}">
                                    <include name="**/*.thrift"/>
                                </fileset>

                                <mkdir dir="${thrift.dest.dir}" />
                                <mkdir dir="${thrift.dest.dir.doc}" />
                                <mkdir dir="${thrift.dest.dir.js}" />
                                <mkdir dir="${thrift.dest.dir.node}" />
                                <mkdir dir="${thrift.dest.dir.cpp}" />
                                <mkdir dir="${thrift.dest.dir.cocoa}" />
                                <mkdir dir="${thrift.dest.dir.php}" />

                                <delete includeemptydirs="true">
                                    <fileset dir="${thrift.dest.dir.doc}" includes="**/*"/>
                                    <fileset dir="${thrift.dest.dir.js}" includes="**/*"/>
                                    <fileset dir="${thrift.dest.dir.node}" includes="**/*"/>
                                    <fileset dir="${thrift.dest.dir.cpp}" includes="**/*"/>
                                    <fileset dir="${thrift.dest.dir.cocoa}" includes="**/*"/>
                                    <fileset dir="${thrift.dest.dir.php}" includes="**/*"/>
                                </delete>


                                <!--Generate Doc Files-->
                                <!-- Invoke thrift binary for each of these files -->
                                <apply executable="${thrift.compiler}" resultproperty="thrift.compile.result"
                                       failifexecutionfails="true" failonerror="true" resolveExecutable="true"
                                       searchpath="true" dir="." verbose="true">
                                    <arg value="-o"/>
                                    <arg value="${thrift.dest.dir}"/>
                                    <arg value="--gen"/>
                                    <arg value="html:standalone"/>
                                    <arg value="--gen"/>
                                    <arg value="java"/>
                                    <arg value="--gen"/>
                                    <arg value="js"/>
                                    <arg value="--gen"/>
                                    <arg value="js:node"/>
                                    <arg value="--gen"/>
                                    <arg value="cpp"/>
                                    <arg value="--gen"/>
                                    <arg value="cocoa"/>
                                    <arg value="--gen"/>
                                    <arg value="php"/>
                                    <srcfile/>
                                    <fileset refid="thrift.src.files"/>
                                </apply>

                                <move todir="${thrift.dest.dir.doc}">
                                    <fileset dir="${thrift.dest.dir}/gen-html" />
                                </move>

                                <move todir="${thrift.dest.dir.java}">
                                    <fileset dir="${thrift.dest.dir}/gen-java" />
                                </move>

                                <move todir="${thrift.dest.dir.js}">
                                    <fileset dir="${thrift.dest.dir}/gen-js" />
                                </move>

                                <move todir="${thrift.dest.dir.node}">
                                    <fileset dir="${thrift.dest.dir}/gen-nodejs" />
                                </move>

                                <move todir="${thrift.dest.dir.cpp}">
                                    <fileset dir="${thrift.dest.dir}/gen-cpp" />
                                </move>

                                <move todir="${thrift.dest.dir.cocoa}">
                                    <fileset dir="${thrift.dest.dir}/gen-cocoa" />
                                </move>

                                <move todir="${thrift.dest.dir.php}">
                                    <fileset dir="${thrift.dest.dir}/gen-php" />
                                </move>

                            </target>
                            <sourceRoot>
                                ${thrift.dest.dir.java}
                            </sourceRoot>

                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


            <!--=======================-->
            <!--KOTLIN-->
            <!--=======================-->

            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <configuration>
                    <jvmTarget>1.6</jvmTarget>
                </configuration>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.build.directory}/generated-sources/java</sourceDir>
                                <sourceDir>${project.basedir}/src/main/java</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/src/test/java</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


        </plugins>
    </build>

</project>
