<?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.trino</groupId>
        <artifactId>trino-root</artifactId>
        <version>460</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>trino-web-ui</artifactId>
    <description>Trino - Web UI</description>

    <properties>
        <frontend.package.goal>package</frontend.package.goal>
        <frontend.check.goal>check</frontend.check.goal>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>jaxrs-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>junit-extensions</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>**/node_modules/**</exclude>
                    <exclude>**/webapp/src/**</exclude>
                    <exclude>**/webapp/dist/node/**</exclude>
                    <exclude>**/webapp-preview/public/**</exclude>
                    <exclude>**/webapp-preview/src/**</exclude>
                    <exclude>**/webapp-preview/*</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <installDirectory>${node.tmpdir}</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <workingDirectory>src/main/resources/webapp/src</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>package (webapp)</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>run ${frontend.package.goal}</arguments>
                            <workingDirectory>src/main/resources/webapp/src</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>check (webapp)</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>verify</phase>
                        <configuration>
                            <arguments>run ${frontend.check.goal}</arguments>
                            <workingDirectory>src/main/resources/webapp/src</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>check (webapp-preview)</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>verify</phase>
                        <configuration>
                            <arguments>run ${frontend.check.goal}</arguments>
                            <workingDirectory>src/main/resources/webapp-preview</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>package (webapp-preview)</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>run ${frontend.package.goal}</arguments>
                            <workingDirectory>src/main/resources/webapp-preview</workingDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>ci</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>env.CI</name>
                </property>
            </activation>
            <properties>
                <frontend.package.goal>package:clean</frontend.package.goal>
                <frontend.check.goal>check:clean</frontend.check.goal>
            </properties>
        </profile>
    </profiles>
</project>
