<?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>io.prestosql</groupId>
        <artifactId>presto-root</artifactId>
        <version>316</version>
    </parent>

    <artifactId>presto-docs</artifactId>
    <name>presto-docs</name>
    <packaging>pom</packaging>

    <properties>
        <air.main.basedir>${project.parent.basedir}</air.main.basedir>
    </properties>

    <!--
    Generate HTML docs quickly while developing:

    brew install python
    pip2 install sphinx

    make -C presto-docs clean html

    open presto-docs/target/html/index.html
    -->

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.mycila</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <configuration>
                        <excludes combine.children="append">
                            <exclude>**/*.conf</exclude>
                            <exclude>**/*.css_t</exclude>
                            <exclude>src/main/sphinx/ext/sitemap.py</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>io.airlift.drift</groupId>
                <artifactId>drift-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>generate-thrift-idl</goal>
                        </goals>
                        <configuration>
                            <outputFile>${project.build.directory}/PrestoThriftService.thrift</outputFile>
                            <classes>
                                <class>io.prestosql.plugin.thrift.api.PrestoThriftService</class>
                            </classes>
                            <recursive>true</recursive>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>io.prestosql</groupId>
                        <artifactId>presto-thrift-api</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>validate-reserved</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>io.prestosql.sql.ReservedIdentifiers</mainClass>
                            <arguments>
                                <argument>validateDocs</argument>
                                <argument>${project.basedir}/src/main/sphinx/language/reserved.rst</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>validate-thrift-idl</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>diff</executable>
                            <arguments>
                                <argument>-b</argument>
                                <argument>-c</argument>
                                <argument>${project.basedir}/src/main/sphinx/include/PrestoThriftService.thrift</argument>
                                <argument>${project.build.directory}/PrestoThriftService.thrift</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <includeProjectDependencies>false</includeProjectDependencies>
                    <includePluginDependencies>true</includePluginDependencies>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>io.prestosql</groupId>
                        <artifactId>presto-parser</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>io.airlift.maven.plugins</groupId>
                <artifactId>sphinx-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                    <force>true</force>
                    <warningsAsErrors>true</warningsAsErrors>
                    <sourceDirectory>${project.basedir}/src/main/sphinx</sourceDirectory>
                    <outputDirectory>${project.build.directory}/html</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>docs</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>src/main/assembly/docs.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>

                    <execution>
                        <id>sources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/assembly/sources.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
