<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  ~
  ~ Copyright (c) 2020-2030 郑庚伟 ZHENGGENGWEI (码匠君), <herodotus@aliyun.com> Licensed under the AGPL License
  ~
  ~ This file is part of Dante Cloud.
  ~
  ~ Dante Cloud 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.
  ~
  ~ Dante Cloud 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 <https://www.herodotus.cn>.
  -->

<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>cn.herodotus.ecosystem</groupId>
        <artifactId>herodotus-ecosystem-parent</artifactId>
        <version>4.1.0.1</version>
        <relativePath/>
    </parent>

    <groupId>cn.herodotus.dantecloud</groupId>
    <artifactId>dante-cloud</artifactId>
    <name>${project.artifactId}</name>
    <packaging>pom</packaging>

    <description>Top Dante project pom.xml file</description>

    <!-- ${basedir} 项目根目录 -->
    <!-- ${project.build.directory} 构建目录，缺省为target -->
    <!-- ${project.build.outputDirectory} 构建过程输出目录，缺省为target/classes -->
    <!-- ${project.build.finalName} 产出物名称，缺省为${project.artifactId}-${project.version} -->
    <!-- ${project.packaging} 打包类型，缺省为jar -->
    <!-- ${project.xxx} 当前pom文件的任意节点的内容 如project.artifactId -->
    <properties>
        <!--配置参数-->
        <!--为了便于Docker的构建，减少上下文影响，将所有Docker资源放置在同一个目录中进行构建-->
        <docker.build.directory>../../configurations/docker/context/target</docker.build.directory>
        <docker.resource.name>${project.build.finalName}.${project.packaging}</docker.resource.name>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>cn.herodotus.dante</groupId>
                <artifactId>dante-dependencies</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>cn.herodotus.dantecloud</groupId>
                <artifactId>dante-cloud-dependencies</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!-- 环境 -->
    <profiles>
        <!-- 开发 -->
        <profile>
            <id>development</id>
            <activation>
                <!--默认激活配置-->
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!--当前环境-->
                <profile>development</profile>
                <database>postgresql</database>
                <!--基础设施：tencent、alibaba、spring-->
                <facility>alibaba</facility>
                <!--代码构建控制-->
                <!--跳过构建源代码包-->
                <skip.build.source.package>false</skip.build.source.package>
                <!--不copy代码包到docker构建目录-->
                <skip.copy.docker.resource>true</skip.copy.docker.resource>
                <!--不执行git commit 构建-->
                <skip.build.git.commit.info>true</skip.build.git.commit.info>
                <!--Spring Cloud Alibaba 鉴权用户名-->
                <alibaba.username>nacos</alibaba.username>
                <!--Spring Cloud Alibaba 鉴权密码-->
                <alibaba.password>nacos</alibaba.password>
                <!--Spring Cloud Alibaba配置中心命名空间,用于支持多环境.这里必须使用ID，不能使用名称,默认为空-->
                <alibaba.namespace></alibaba.namespace>
                <!--Spring Cloud Alibaba配置中心地址-->
                <alibaba.config.server-addr>192.168.101.10:8848</alibaba.config.server-addr>
                <!--Spring Cloud Alibaba服务发现地址-->
                <alibaba.discovery.server-addr>192.168.101.10:8848</alibaba.discovery.server-addr>
                <alibaba.sentinel.server-addr>192.168.101.10:8858</alibaba.sentinel.server-addr>
                <tencent.polaris.namespace>default</tencent.polaris.namespace>
                <!--Spring Cloud Tencent 配置 【(8091)grpc/tcp，默认注册中心端口;(8090)http/tcp，默认注册中心端口】-->
                <tencent.polaris.server-addr>192.168.101.10:8091</tencent.polaris.server-addr>
                <!--Spring Cloud Tencent Config 配置 【(8093)grpc/tcp，默认配置中心端口】-->
                <tencent.polaris.config-addr>192.168.101.10:8093</tencent.polaris.config-addr>
                <!--Spring Cloud Tencent 本地缓存目录-->
                <tencent.polaris.local.dir>./configurations/backup/cache</tencent.polaris.local.dir>
                <!--Spring Cloud Tencent 动态配置数据源类型 polaris: 从北极星服务端获取配置文件 local: 从本地磁盘读取配置文件-->
                <tencent.polaris.data.source>polaris</tencent.polaris.data.source>
            </properties>
        </profile>
        <!-- Docker -->
        <profile>
            <id>docker</id>
            <properties>
                <!--当前环境-->
                <profile>docker</profile>
                <!--数据库类型-->
                <database>postgresql</database>
                <!--基础设施：tencent、alibaba、spring-->
                <facility>tencent</facility>
                <!--代码构建控制-->
                <!--跳过构建源代码包-->
                <skip.build.source.package>true</skip.build.source.package>
                <!--不copy代码包到docker构建目录-->
                <skip.copy.docker.resource>false</skip.copy.docker.resource>
                <!--不执行git commit 构建-->
                <skip.build.git.commit.info>false</skip.build.git.commit.info>
                <!--Spring Cloud Alibaba 鉴权用户名-->
                <alibaba.username>nacos</alibaba.username>
                <!--Spring Cloud Alibaba 鉴权密码-->
                <alibaba.password>nacos</alibaba.password>
                <!--Spring Cloud Alibaba配置中心地址-->
                <alibaba.config.server-addr>192.168.101.10:8848</alibaba.config.server-addr>
                <!--Spring Cloud Alibaba配置中心命名空间,用于支持多环境.这里必须使用ID，不能使用名称,默认为空-->
                <alibaba.namespace></alibaba.namespace>
                <!--Spring Cloud Alibaba服务发现地址-->
                <alibaba.discovery.server-addr>192.168.101.10:8848</alibaba.discovery.server-addr>
                <alibaba.sentinel.server-addr>192.168.101.10:8858</alibaba.sentinel.server-addr>
                <!--Spring Cloud Tencent 配置 【(8091)grpc/tcp，默认注册中心端口;(8090)http/tcp，默认注册中心端口】-->
                <tencent.polaris.server-addr>192.168.101.10:8091</tencent.polaris.server-addr>
                <!--Spring Cloud Tencent Config 配置 【(8093)grpc/tcp，默认配置中心端口】-->
                <tencent.polaris.config-addr>192.168.101.10:8093</tencent.polaris.config-addr>
                <tencent.polaris.namespace>default</tencent.polaris.namespace>
                <!--Spring Cloud Tencent 本地缓存目录-->
                <tencent.polaris.local.dir>./configurations/backup/cache</tencent.polaris.local.dir>
                <!--Spring Cloud Tencent 动态配置数据源类型 polaris: 从北极星服务端获取配置文件 local: 从本地磁盘读取配置文件-->
                <tencent.polaris.data.source>polaris</tencent.polaris.data.source>
            </properties>
        </profile>
        <!-- 生产 -->
        <profile>
            <id>production</id>
            <properties>
                <!--当前环境-->
                <profile>production</profile>
                <database>mysql8</database>
                <!--基础设施：tencent、alibaba、spring-->
                <facility>tencent</facility>
                <!--代码构建控制-->
                <!--跳过构建源代码包-->
                <skip.build.source.package>false</skip.build.source.package>
                <!--不copy代码包到docker构建目录-->
                <skip.copy.docker.resource>true</skip.copy.docker.resource>
                <!--不执行git commit 构建-->
                <skip.build.git.commit.info>false</skip.build.git.commit.info>
                <!--Spring Cloud Alibaba 鉴权用户名-->
                <alibaba.username>nacos</alibaba.username>
                <!--Spring Cloud Alibaba 鉴权密码-->
                <alibaba.password>nacos</alibaba.password>
                <!--Spring Cloud Alibaba配置中心命名空间,用于支持多环境.这里必须使用ID，不能使用名称,默认为空-->
                <!--<alibaba.namespace>8fdcc073-2e51-4722-8274-3f5b76362bb8</alibaba.namespace>-->
                <alibaba.namespace></alibaba.namespace>
                <!--Spring Cloud Alibaba配置中心地址-->
                <alibaba.config.server-addr>192.168.101.10:8848</alibaba.config.server-addr>
                <!--Spring Cloud Alibaba服务发现地址-->
                <alibaba.discovery.server-addr>192.168.101.10:8848</alibaba.discovery.server-addr>
                <alibaba.sentinel.server-addr>192.168.101.10:8858</alibaba.sentinel.server-addr>
                <tencent.polaris.namespace>default</tencent.polaris.namespace>
                <!--Spring Cloud Tencent 配置 【(8091)grpc/tcp，默认注册中心端口;(8090)http/tcp，默认注册中心端口】-->
                <tencent.polaris.server-addr>192.168.101.10:8091</tencent.polaris.server-addr>
                <!--Spring Cloud Tencent Config 配置 【(8093)grpc/tcp，默认配置中心端口】-->
                <tencent.polaris.config-addr>192.168.101.10:8093</tencent.polaris.config-addr>
                <!--Spring Cloud Tencent 本地缓存目录-->
                <tencent.polaris.local.dir>./configurations/backup/cache</tencent.polaris.local.dir>
                <!--Spring Cloud Tencent 动态配置数据源类型 polaris: 从北极星服务端获取配置文件 local: 从本地磁盘读取配置文件-->
                <tencent.polaris.data.source>polaris</tencent.polaris.data.source>
            </properties>
        </profile>

        <!-- 覆盖 herodotus-ecosystem-parent 中的 release 和 github action profile 实现非服务模块的发布-->
        <!-- 非服务模块代码不涉及动态配置信息，所以不需要有像前面一样的配置信息-->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <configuration>
                            <excludeArtifacts>
                                <excludeArtifact>platform</excludeArtifact>
                                <excludeArtifact>dante-cloud-gateway</excludeArtifact>
                                <excludeArtifact>dante-cloud-message</excludeArtifact>
                                <excludeArtifact>dante-cloud-monitor</excludeArtifact>
                                <excludeArtifact>dante-cloud-uaa</excludeArtifact>
                                <excludeArtifact>dante-cloud-upms</excludeArtifact>
                                <excludeArtifact>services</excludeArtifact>
                                <excludeArtifact>dante-cloud-bpmn-ability</excludeArtifact>
                                <excludeArtifact>dante-cloud-bpmn-logic</excludeArtifact>
                                <excludeArtifact>dante-cloud-oss-ability</excludeArtifact>
                                <excludeArtifact>dante-monolith-application</excludeArtifact>
                            </excludeArtifacts>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>githubAction</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- 必须配置，用于 gpg 非交互式密码输入 -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <configuration>
                            <excludeArtifacts>
                                <excludeArtifact>dante-cloud-platform</excludeArtifact>
                                <excludeArtifact>dante-cloud-gateway</excludeArtifact>
                                <excludeArtifact>dante-cloud-message</excludeArtifact>
                                <excludeArtifact>dante-cloud-monitor</excludeArtifact>
                                <excludeArtifact>dante-cloud-uaa</excludeArtifact>
                                <excludeArtifact>dante-cloud-upms</excludeArtifact>
                                <excludeArtifact>dante-cloud-services</excludeArtifact>
                                <excludeArtifact>dante-cloud-bpmn-ability</excludeArtifact>
                                <excludeArtifact>dante-cloud-bpmn-logic</excludeArtifact>
                                <excludeArtifact>dante-cloud-oss-ability</excludeArtifact>
                                <excludeArtifact>dante-monolith-application</excludeArtifact>
                            </excludeArtifacts>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>${maven-antrun-plugin.version}</version>
                    <configuration>
                        <skip>${skip.copy.docker.resource}</skip>
                    </configuration>
                    <executions>
                        <execution>
                            <id>delete-jar-file</id>
                            <phase>pre-clean</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <target>
                                    <delete file="${docker.build.directory}/${docker.resource.name}"/>
                                </target>
                            </configuration>
                        </execution>
                        <execution>
                            <id>prepare-docker-resource</id>
                            <!--fix: #IA6J53 prepare 阶段会导致 jar 包中 manifest 信息缺失，导致 java -jar 运行失败-->
                            <phase>install</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <target>
                                    <!--jar包保存位置 -->
                                    <copy todir="${docker.build.directory}">
                                        <fileset dir="${project.basedir}/target">
                                            <include name="${docker.resource.name}"/>
                                        </fileset>
                                    </copy>
                                </target>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>io.github.git-commit-id</groupId>
                    <artifactId>git-commit-id-maven-plugin</artifactId>
                    <configuration>
                        <skip>${skip.build.git.commit.info}</skip>
                        <!-- 检查的仓库根目录，${project.basedir}：项目根目录，即包含pom.xml文件的目录 -->
                        <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                        <!-- 生成git属性文件，默认false：不生成 -->
                        <generateGitPropertiesFile>true</generateGitPropertiesFile>
                        <dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
                        <gitDescribe>
                            <skip>false</skip>
                            <always>false</always>
                            <dirty>-dirty</dirty>
                        </gitDescribe>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <configuration>
                    <skipSource>${skip.build.source.package}</skipSource>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <modules>
        <module>dante-cloud-dependencies</module>
        <module>dante-cloud-modules</module>
        <module>dante-cloud-packages</module>
        <module>dante-cloud-platform</module>
        <module>dante-cloud-services</module>
    </modules>
</project>