<?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/POM/4.0.0/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.hibegin</groupId>
        <artifactId>zrlog-admin-web-parent</artifactId>
        <version>4.0.0</version>
    </parent>
    <artifactId>zrlog-admin-web-ui</artifactId>
    <name>ZrLog Admin Web UI</name>
    <dependencies>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-admin-web-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-admin-common</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-install-web</artifactId>
            <version>${zrlog-install-web.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <resources>
            <resource><directory>src/main/resources</directory></resource>
            <resource><directory>src/main/frontend/build</directory><targetPath>admin</targetPath></resource>
        </resources>
    </build>
    <profiles>
        <profile>
            <id>nodeBuild</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.12.1</version>
                        <configuration>
                            <nodeVersion>v20.20.2</nodeVersion>
                            <yarnVersion>v1.22.18</yarnVersion>
                            <npmVersion>8.11.0</npmVersion>
                            <workingDirectory>src/main/frontend</workingDirectory>
                            <installDirectory>../.frontend-tools</installDirectory>
                            <nodeDownloadRoot>https://npmmirror.com/mirrors/node/</nodeDownloadRoot>
                            <yarnDownloadRoot>https://github.com/yarnpkg/yarn/releases/download/</yarnDownloadRoot>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install node and yarn</id>
                                <goals>
                                    <goal>install-node-and-yarn</goal>
                                </goals>
                                <phase>generate-resources</phase>
                            </execution>
                            <execution>
                                <id>yarn install</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>install --registry=https://registry.npmmirror.com --frozen-lockfile
                                    </arguments>
                                </configuration>
                                <phase>generate-resources</phase>
                            </execution>
                            <execution>
                                <id>yarn test dev-server</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>test:dev-server</arguments>
                                    <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
                                </configuration>
                                <phase>generate-resources</phase>
                            </execution>
                            <execution>
                                <id>yarn build</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <environmentVariables>
                                        <BUILD_PATH>${frontendBuildOutputPath}</BUILD_PATH>
                                    </environmentVariables>
                                    <arguments>build</arguments>
                                </configuration>
                                <phase>generate-resources</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
