<?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>pl.fhframework</groupId>
        <artifactId>fh-boot-bom</artifactId>
        <version>4.10.8</version>
        <relativePath>../../bom-project-lite/fh-boot-bom</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>fhdp-example</artifactId>

    <properties>
        <fh.version>4.10.8</fh.version>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>pl.fhframework.dp</groupId>
                <artifactId>fhdp-bom</artifactId>
                <version>${fh.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>pl.fhframework</groupId>
            <artifactId>fh-docs</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>pl.fhframework.dp</groupId>
            <artifactId>fhdp-commons-fh-lite</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>pl.fhframework.dp</groupId>
            <artifactId>fhdp-components</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>pl.fhframework</groupId>
            <artifactId>fh-compiler</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>pl.fhframework</groupId>
            <artifactId>coreApplication</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>pl.fhframework.core.security.provider</groupId>
            <artifactId>securityDataProvider-jdbc</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>pl.fhframework.core.security.permission</groupId>
            <artifactId>permissionProvider-jdbc</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>pl.fhframework</groupId>
            <artifactId>fhLogback</artifactId>
            <version>${fh.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- ANT copies XMLs of dynamic classes and keeps last modified timestamps (maven-resources-plugin does NOT) -->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <configuration>
                            <tasks>
                                <copy todir="${project.build.outputDirectory}" preservelastmodified="true">
                                    <fileset dir="src/main/java">
                                        <include name="**/*.frm" />
                                        <include name="**/*.duc" />
                                        <include name="**/*.dmo" />
                                        <include name="**/*.dru" />
                                        <include name="**/*.srv" />
                                        <include name="menu.xml" />
                                        <include name="module.xml" />
                                    </fileset>
                                </copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>install-node-and-yarn</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v18.16.0</nodeVersion>
                            <yarnVersion>v1.22.22</yarnVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn config</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>config set registry https://registry.yarnpkg.com</arguments>
                        </configuration>
                    </execution>
<!--                    <execution>-->
<!--                        <id>yarn cache clean 1/2</id>-->
<!--                        <phase>generate-resources</phase>-->
<!--                        <goals>-->
<!--                            <goal>yarn</goal>-->
<!--                        </goals>-->
<!--                        <configuration>-->
<!--                            <arguments>cache clean</arguments>-->
<!--                        </configuration>-->
<!--                    </execution>-->
<!--                    <execution>-->
<!--                        <id>yarn cache clean 2/2</id>-->
<!--                        <phase>generate-resources</phase>-->
<!--                        <goals>-->
<!--                            <goal>yarn</goal>-->
<!--                        </goals>-->
<!--                        <configuration>-->
<!--                            <arguments>&#45;&#45;update-checksums</arguments>-->
<!--                        </configuration>-->
<!--                    </execution>-->
                    <execution>
                        <id>yarn install</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                    </execution>
<!--                    <execution>-->
<!--                        <id>yarn upgrade</id>-->
<!--                        <phase>generate-resources</phase>-->
<!--                        <goals>-->
<!--                            <goal>yarn</goal>-->
<!--                        </goals>-->
<!--                        <configuration>-->
<!--                            <arguments>upgrade fhdp-fh-starter</arguments>-->
<!--                        </configuration>-->
<!--                    </execution>-->
<!--                    <execution>-->
<!--                        <id>yarn upgrade 2</id>-->
<!--                        <phase>generate-resources</phase>-->
<!--                        <goals>-->
<!--                            <goal>yarn</goal>-->
<!--                        </goals>-->
<!--                        <configuration>-->
<!--                            <arguments>upgrade fhdp-charts</arguments>-->
<!--                        </configuration>-->
<!--                    </execution>-->
                    <execution>
                        <id>yarn run build</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>run build --env envMode=${NODE_ENV}</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>pl.fhframework.app.DefaultApplication</mainClass>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>runtime</includeScope>
                            <outputDirectory>target/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
