<?xml version="1.0" encoding="UTF-8"?>
<!--

    eiam-console - Employee Identity and Access Management
    Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

-->
<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>
        <groupId>cn.topiam</groupId>
        <artifactId>eiam</artifactId>
        <version>1.0.2-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>eiam-console</artifactId>

    <dependencies>
        <!--审计-->
        <dependency>
            <groupId>cn.topiam</groupId>
            <artifactId>eiam-audit</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!--引入应用-->
        <dependency>
            <groupId>cn.topiam</groupId>
            <artifactId>eiam-application-all</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!--认证-->
        <dependency>
            <groupId>cn.topiam</groupId>
            <artifactId>eiam-authentication-all</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!-- 引入身份源 -->
        <dependency>
            <groupId>cn.topiam</groupId>
            <artifactId>eiam-identity-source-all</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!--引入协议-->
        <dependency>
            <groupId>cn.topiam</groupId>
            <artifactId>eiam-protocol-all</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!-- core-->
        <dependency>
            <groupId>cn.topiam</groupId>
            <artifactId>eiam-core</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
    <!-- build -->
    <build>
        <!--打包后名称-->
        <finalName>topiam-employee-console-${project.version}</finalName>
        <plugins>
            <!--spring-boot-maven-plugin-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--清理-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>${maven-clean-plugin.version}</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src/main/console-fe/</directory>
                            <followSymlinks>false</followSymlinks>
                            <includes>
                                <include>build/**</include>
                                <include>yarn.lock</include>
                                <include>package-lock.json</include>
                                <include>pnpm-lock.yaml</include>
                                <include>yarn-error.log</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <!-- 将 npm run build 后的 dist 内容复制到 resources 目录下 -->
            <resource>
                <directory>src/main/console-fe/build</directory>
                <targetPath>fe</targetPath>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
    </build>
    <profiles>
        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <!--编译打包前端项目-->
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${frontend-maven-plugin.version}</version>
                        <configuration>
                            <installDirectory>target</installDirectory>
                            <workingDirectory>src/main/console-fe</workingDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install node and pnpm</id>
                                <goals>
                                    <goal>install-node-and-pnpm</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <nodeVersion>v18.17.1</nodeVersion>
                                    <pnpmVersion>v8.7.0</pnpmVersion>
                                    <nodeDownloadRoot>https://npm.taobao.org/mirrors/node/</nodeDownloadRoot>
                                </configuration>
                            </execution>
                            <execution>
                                <id>pnpm install</id>
                                <goals>
                                    <goal>pnpm</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>install</arguments>
                                    <pnpmRegistryURL>https://registry.npm.taobao.org</pnpmRegistryURL>
                                    <pnpmInheritsProxyConfigFromMaven>true</pnpmInheritsProxyConfigFromMaven>
                                </configuration>
                            </execution>
                            <execution>
                                <id>pnpm run build</id>
                                <goals>
                                    <goal>pnpm</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>run build:pre</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!--编译打包前端项目-->
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${frontend-maven-plugin.version}</version>
                        <configuration>
                            <installDirectory>target</installDirectory>
                            <workingDirectory>src/main/console-fe</workingDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install node and pnpm</id>
                                <goals>
                                    <goal>install-node-and-pnpm</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <nodeVersion>v18.17.1</nodeVersion>
                                    <pnpmVersion>v8.7.0</pnpmVersion>
                                    <nodeDownloadRoot>https://npm.taobao.org/mirrors/node/</nodeDownloadRoot>
                                </configuration>
                            </execution>
                            <execution>
                                <id>pnpm install</id>
                                <goals>
                                    <goal>pnpm</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>install</arguments>
                                    <pnpmRegistryURL>https://registry.npm.taobao.org</pnpmRegistryURL>
                                    <pnpmInheritsProxyConfigFromMaven>true</pnpmInheritsProxyConfigFromMaven>
                                </configuration>
                            </execution>
                            <execution>
                                <id>pnpm run build</id>
                                <goals>
                                    <goal>pnpm</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>run build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>