<?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>cn.zorbus</groupId>
        <artifactId>spring-boot-tutorial</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <artifactId>spring-boot-14-docker</artifactId>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- spring 版本 -->
        <spring-boot.version>3.1.0</spring-boot.version>
        <spring-cloud.version>2022.0.3</spring-cloud.version>
        <!-- 依赖管理 -->
        <snakeyaml.version>2.0</snakeyaml.version>
        <compiler.version>3.11.0</compiler.version>
        <org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
        <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <!-- 指定最后的 JAR 名称 -->
        <finalName>${project.artifactId}</finalName>
        <!-- 打包之后排除 *.properties -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                    <excludeDevtools>false</excludeDevtools>
                    <image>
                        <!--要使用的构建器映像的名称。默认：paketobuildpacks/builder:base-->
                        <builder>registry.cn-hangzhou.aliyuncs.com/shishaodong/paketobuildpacks_builder:0.3.261-base
                        </builder>
                        <!-- 运行时 Image -->
                        <runImage>registry.cn-hangzhou.aliyuncs.com/shishaodong/paketobuildpacks_run:1.2.70-base-cnb
                        </runImage>
                        <!--映像生成的映像的名称。-->
                        <!--suppress UnresolvedMavenProperty -->
                        <name>
                            registry.cn-hangzhou.aliyuncs.com/shishaodong/${project.artifactId}:${project.version}-${git.commit.id.abbrev}
                        </name>
                        <env>
                            <BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
                            <BPE_OVERRIDE_LANG>en_US.UTF-8</BPE_OVERRIDE_LANG>
                            <BPE_OVERRIDE_LC_ALL>en_US.UTF-8</BPE_OVERRIDE_LC_ALL>
                            <BPE_OVERRIDE_TZ>Asia/Shanghai</BPE_OVERRIDE_TZ>
                        </env>
                        <!-- 拉取镜像的策略，可选的值：ALWAYS, NEVER, IF_NOT_PRESENT。默认 ALWAYS-->
                        <pullPolicy>IF_NOT_PRESENT</pullPolicy>
                        <!--是否需要在建立缓存前清理缓存。默认false-->
                        <cleanCache>false</cleanCache>
                        <!-- 启用构造器操作的详细日志记录。默认false-->
                        <verboseLogging>true</verboseLogging>
                        <!-- 执行完build 自动push。默认 false -->
                        <publish>false</publish>
                        <!-- mvn clean spring-boot:build-image -Dproject.path=/绝对路径/spring-boot-examples -f pom.xml -->
                        <bindings>
                            <binding>
                                ${project.basedir}/k8s/buildpack/bellsoft-liberica/buildpack.toml:/cnb/buildpacks/paketo-buildpacks_bellsoft-liberica/10.2.3/buildpack.toml
                            </binding>
                            <binding>
                                ${project.basedir}/k8s/buildpack/spring-boot/buildpack.toml:/cnb/buildpacks/paketo-buildpacks_spring-boot/5.25.1/buildpack.toml
                            </binding>
                            <binding>
                                ${project.basedir}/k8s/buildpack/syft/buildpack.toml:/cnb/buildpacks/paketo-buildpacks_syft/1.30.1/buildpack.toml
                            </binding>
                        </bindings>
                    </image>
                    <docker>
                        <tlsVerify>false</tlsVerify>
                    </docker>
                </configuration>
            </plugin>
            <!-- 打包时加入当前 GIT 提交信息 -->
            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <offline>true</offline>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <!-- git.commit.id.abbrev属性值的长度，取值范围在[2, 40]，默认值7 -->
                    <abbrevLength>8</abbrevLength>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>${lombok-mapstruct-binding.version}</version>
                        </path>
                        <!-- spring-boot-configuration-processor 生效需要加入这行 -->
                        <path>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-configuration-processor</artifactId>
                            <version>${spring-boot.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>