<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~  Copyright 1999-2019 Seata.io Group.
  ~
  ~  Licensed under the Apache License, Version 2.0 (the "License");
  ~  you may not use this file except in compliance with the License.
  ~  You may obtain a copy of the License at
  ~
  ~       https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing, software
  ~  distributed under the License is distributed on an "AS IS" BASIS,
  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~  See the License for the specific language governing permissions and
  ~  limitations under the License.
  -->
<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>

    <groupId>io.seata</groupId>
    <artifactId>seata-build</artifactId>
    <packaging>pom</packaging>
    <version>${revision}</version>

    <name>Seata Build ${project.version}</name>
    <description>plugin management for Seata built with Maven</description>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <organization>
        <name>Seata</name>
        <url>https://github.com/seata</url>
    </organization>

    <url>https://seata.io</url>

    <developers>
        <developer>
            <id>Seata</id>
            <name>Seata</name>
            <url>https://seata.io</url>
            <email>dev-seata@googlegroups.com</email>
        </developer>
    </developers>

    <issueManagement>
        <system>github</system>
        <url>https://github.com/seata/seata/issues</url>
    </issueManagement>

    <scm>
        <url>git@github.com:seata/seata.git</url>
        <connection>scm:git@github.com:seata/seata.git</connection>
        <developerConnection>scm:git@github.com:seata/seata.git</developerConnection>
    </scm>

    <properties>
        <!-- seata version -->
        <revision>1.6.1</revision>

        <!-- Compiler settings properties -->
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- The version of spring-boot for 'spring-boot-dependencies' and 'spring-boot-maven-plugin' -->
        <spring-boot.version>2.5.13</spring-boot.version>
        <spring-framework.version>5.3.19</spring-framework.version>

        <!-- For test -->
        <junit-jupiter.version>5.8.2</junit-jupiter.version>
        <junit-platform.version>1.8.2</junit-platform.version>

        <!-- Maven plugin versions -->
        <!-- Build -->
        <easyj-maven-plugin.version>1.0.5</easyj-maven-plugin.version>
        <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
        <!-- Compiler -->
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
        <kotlin-maven-plugin.version>1.3.72</kotlin-maven-plugin.version>
        <!-- Check -->
        <maven-pmd-plugin.version>3.8</maven-pmd-plugin.version>
        <p3c-pmd.version>1.3.6</p3c-pmd.version>
        <maven-javadoc-plugin.version>3.0.0</maven-javadoc-plugin.version>
        <license-maven-plugin.version>3.0</license-maven-plugin.version>
        <mojo-license-maven-plugin.version>1.20</mojo-license-maven-plugin.version>
        <maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
        <maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
        <!-- Test -->
        <maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
        <jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>
        <!-- Packaging -->
        <maven-source-plugin.version>2.2.1</maven-source-plugin.version>
        <maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
        <maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
        <maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
        <maven-dependency-plugin.version>3.0.2</maven-dependency-plugin.version>
        <maven-assembly-plugin.version>3.0.0</maven-assembly-plugin.version>
        <jib-maven-plugin.version>3.2.0</jib-maven-plugin.version>
        <!-- Deploy && GPG -->
        <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.7</nexus-staging-maven-plugin.version>
        <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
        <!-- Other -->
        <maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
        <os-maven-plugin.version>1.5.0.Final</os-maven-plugin.version>

        <!-- Default values of the Maven plugins -->
        <checkstyle.skip>true</checkstyle.skip>
        <license.skip>true</license.skip>
        <maven.test.skip>false</maven.test.skip>
        <maven.surefire.argLine></maven.surefire.argLine>
        <gpg.keyname>A1C4DAB9B220DBA0C277E945D6A1420D747D1EE0</gpg.keyname>
        <gpg.arg1/>
        <gpg.arg2/>

        <!-- For docker image-->
        <image.publish.skip>true</image.publish.skip>
        <image.tags>latest</image.tags>

        <dependencies.copy.skip>true</dependencies.copy.skip>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${maven-deploy-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>${maven-shade-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${maven-dependency-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${maven-checkstyle-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.xolstice.maven.plugins</groupId>
                    <artifactId>protobuf-maven-plugin</artifactId>
                    <version>${protobuf-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>com.mycila</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>${license-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>${mojo-license-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>icu.easyj.maven.plugins</groupId>
                    <artifactId>easyj-maven-plugin</artifactId>
                    <version>${easyj-maven-plugin.version}</version>
                    <!-- This goal can replace flatten-maven-plugin to flatten the pom, and replace '${revision}' to the actual version. -->
                    <executions>
                        <execution>
                            <id>simplify-pom</id>
                            <goals>
                                <goal>simplify-pom</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <simplifiedPomFileName>.flattened-pom.xml</simplifiedPomFileName>
                        <useTabIndent>true</useTabIndent>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- Compiler -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <parameters>true</parameters>
                </configuration>
            </plugin>
            <!-- Resources -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources-plugin.version}</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <!-- Jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
                <configuration>
                    <archive>
                        <addMavenDescriptor>true</addMavenDescriptor>
                        <index>true</index>
                        <manifest>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Build>${maven.build.timestamp}</Implementation-Build>
                        </manifestEntries>
                    </archive>
                    <excludes>
                        <exclude>**/META-INF/additional-spring-configuration-metadata.json</exclude>
                        <exclude>protobuf/**</exclude>
                        <exclude>**/*.proto</exclude>
                        <exclude>static/console-fe/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <!-- Clean -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>${maven-clean-plugin.version}</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>./</directory>
                            <includes>
                                <include>*-pom.xml</include>
                                <include>**/db_store/**</include>
                                <include>**/sessionStore/**</include>
                                <include>**/root.data</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <!-- EasyJ -->
            <plugin>
                <groupId>icu.easyj.maven.plugins</groupId>
                <artifactId>easyj-maven-plugin</artifactId>
            </plugin>
            <!-- Enforcer -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven-enforcer-plugin.version}</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>[3.6.0,)</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- profile: release -->
        <profile>
            <id>release</id>
            <properties>
                <image.tags>${project.version},latest</image.tags>
            </properties>
            <build>
                <plugins>
                    <!-- Javadoc -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <charset>${project.build.sourceEncoding}</charset>
                            <encoding>${project.build.sourceEncoding}</encoding>
                            <failOnError>false</failOnError>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Staging -->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus-staging-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>oss_seata</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <!-- GPG -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <keyname>${gpg.keyname}</keyname>
                                    <gpgArguments>
                                        <arg>${gpg.arg1}</arg>
                                        <arg>${gpg.arg2}</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <!-- distribution management -->
            <distributionManagement>
                <repository>
                    <id>oss_seata</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
                <snapshotRepository>
                    <id>oss_seata</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
        </profile>

        <!-- profile: release-by-github-actions -->
        <profile>
            <id>release-by-github-actions</id>
            <properties>
                <gpg.arg1>--pinentry-mode</gpg.arg1>
                <gpg.arg2>loopback</gpg.arg2>
            </properties>
        </profile>

        <!-- profile: args-for-test-by-jdk17 -->
        <profile>
            <id>args-for-test-by-jdk17</id>
            <activation>
                <jdk>17</jdk>
            </activation>
            <properties>
                <maven.surefire.argLine>
                    --add-opens java.base/java.lang=ALL-UNNAMED
                    --add-opens java.base/java.net=ALL-UNNAMED
                    --add-opens java.base/java.math=ALL-UNNAMED
                    --add-opens java.base/java.text=ALL-UNNAMED
                    --add-opens java.base/java.util=ALL-UNNAMED
                    --add-opens java.base/java.util.regex=ALL-UNNAMED
                    --add-opens java.base/java.util.concurrent=ALL-UNNAMED

                    --add-opens java.sql/java.sql=ALL-UNNAMED
                    --add-opens java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED

                    --illegal-access=permit
                    -Dillegal-access=permit
                </maven.surefire.argLine>
            </properties>
        </profile>
    </profiles>
</project>
