<?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">
    <parent>
        <groupId>com.hibegin</groupId>
        <artifactId>zrlog-base</artifactId>
        <version>3.5.4</version>
    </parent>
    <artifactId>zrlog-admin-web</artifactId>
    <version>3.5.6</version>
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <finalName>zrlog-admin-web</finalName>
        <libOutputPath>lib</libOutputPath>
        <frontendBuildOutputPath>../resources/admin</frontendBuildOutputPath>
        <zrlog-xx-template.version>3.5.4</zrlog-xx-template.version>
        <gpg.passphrase/>
    </properties>

    <repositories>
        <repository>
            <id>central-snapshots</id>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>central-center</id>
            <url>https://repo1.maven.org/maven2/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>

    <name>ZrLog Admin Web</name>
    <url>https://github.com/zrlog-extensions/zrlog-admin-web</url>
    <description>ZrLog admin web</description>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>https://apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <email>support@zrlog.com</email>
            <url>https://blog.zrlog.com</url>
        </developer>
    </developers>
    <scm>
        <connection>scm:git:https://github.com/zrlog-extensions/zrlog-admin-web</connection>
        <developerConnection>scm:git:https://github.com/zrlog-extensions/zrlog-admin-web</developerConnection>
        <url>https://github.com/zrlog-extensions/zrlog-admin-web</url>
    </scm>
    <issueManagement>
        <system>Github Issue</system>
        <url>https://github.com/zrlog-extensions/zrlog-admin-web</url>
    </issueManagement>

    <dependencies>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-service</artifactId>
        </dependency>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-template</artifactId>
        </dependency>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-admin-token</artifactId>
        </dependency>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-freemarker-template</artifactId>
            <version>${zrlog-xx-template.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.hibegin</groupId>
            <artifactId>zrlog-polyglot-template</artifactId>
            <version>${zrlog-xx-template.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>9.3.0</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>jar</id>
            <build>
                <finalName>${finalName}-${project.version}</finalName>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>clean</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                                <configuration>
                                    <filesets>
                                        <fileset>
                                            <directory>${libOutputPath}</directory>
                                        </fileset>
                                    </filesets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-dependencies</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${libOutputPath}</outputDirectory>
                                    <overWriteReleases>false</overWriteReleases>
                                    <overWriteSnapshots>false</overWriteSnapshots>
                                    <overWriteIfNewer>true</overWriteIfNewer>
                                    <excludeArtifactIds>
                                        junit,hamcrest-core
                                    </excludeArtifactIds>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.2.0</version>
                        <configuration>
                            <finalName>${finalName}</finalName>
                            <classifier>starter</classifier>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                    <classpathPrefix>${libOutputPath}</classpathPrefix>
                                    <mainClass>com.zrlog.admin.Application</mainClass>
                                </manifest>
                                <manifestEntries>
                                    <Class-Path>.</Class-Path>
                                </manifestEntries>
                            </archive>
                            <outputDirectory>./</outputDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <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>target</installDirectory>
                            <nodeDownloadRoot>https://npmmirror.com/mirrors/node/</nodeDownloadRoot>
                            <yarnDownloadRoot>https://github.com/yarnpkg/yarn/releases/download/</yarnDownloadRoot>
                            <npmRegistryURL>https://registry.npmmirror.com</npmRegistryURL>
                        </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 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>


    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <release>${java.version}</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <excludes>
                        <exclude>**/Application.class</exclude>
                        <exclude>**/DevZrLogConfig.class</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.11.2</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <passphrase>${gpg.passphrase}</passphrase>
                    <useAgent>false</useAgent>
                    <executable>gpg</executable>
                    <gpgArguments>
                        <argument>--pinentry-mode</argument>
                        <argument>loopback</argument>
                    </gpgArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.8.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>true</autoPublish>
                    <waitUntil>published</waitUntil>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
