<?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">
    <parent>
        <artifactId>arthas-all</artifactId>
        <groupId>com.taobao.arthas</groupId>
        <version>${revision}</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>web-ui</artifactId>
    <packaging>pom</packaging>

    <name>web-ui</name>
    <url>https://github.com/alibaba/arthas</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <yarn.registry.url>https://registry.npmmirror.com/</yarn.registry.url>
        <yarn.download.url>http://npmmirror.com</yarn.download.url>
        <node.download.url>https://npmmirror.com/mirrors/node/</node.download.url>
        <node.version>v16.16.0</node.version>
        <yarn.version>v1.22.19</yarn.version>
    </properties>

    <build>
        <finalName>web-ui</finalName>

        <!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <!-- Use the latest released version:
                    https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
                        <id>install node and yarn</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <!-- optional: default phase is "generate-resources" -->
                        <phase>generate-resources</phase>
                    </execution>
                    <execution>
                        <id>set registry</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>config set registry ${yarn.registry.url}</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn install</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <!-- optional: The default argument is actually
                                "install", so unless you need to run some other yarn command,
                                you can remove this whole <configuration> section.
                                -->
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>vite build:ui</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>vite build --mode ui</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>vite build:tunnel</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>vite build --mode tunnel</arguments>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <nodeVersion>${node.version}</nodeVersion>
                    <yarnVersion>${yarn.version}</yarnVersion>

                    <!-- optional: where to download node from. Defaults to https://nodejs.org/dist/ -->
                    <nodeDownloadRoot>${node.download.url}</nodeDownloadRoot>
                    <!-- optional: where to download yarn from. Defaults to https://github.com/yarnpkg/yarn/releases/download/ -->
                    <!--                        <yarnDownloadRoot>${yarn.registry.url}</yarnDownloadRoot>-->
                    <workingDirectory>arthasWebConsole</workingDirectory>

                    <installDirectory>target</installDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>copy dist</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>arthasWebConsole/dist</directory>
                                </resource>
                            </resources>
                            <outputDirectory>${project.build.directory}/static</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin> -->
        </plugins>
    </build>
</project>