<?xml version="1.0" encoding="UTF-8"?>
<!--

    The Kuali Financial System, a comprehensive financial management system for higher education.

    Copyright 2005-2026 Kuali, Inc.

    This program 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.

    This program 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 <http://www.gnu.org/licenses/>.

-->
<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>
        <artifactId>kfs</artifactId>
        <groupId>org.kuali.kfs</groupId>
        <version>finp-12204-h-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>kfs-web</artifactId>
    <packaging>war</packaging>
    <name>Kuali Financial Web Application</name>

    <properties>
        <!-- Maven built-in properties -->
        <maven.build.timestamp.format>yyyyMMddHHmmS</maven.build.timestamp.format>

        <!-- KFS custom/overridable Maven/plugins properties -->
        <plugin.frontend.workingDirectory>src/main/webapp</plugin.frontend.workingDirectory>

        <!--     Miscellaneous -->
        <yarn.targetScript>build</yarn.targetScript>
        <yarn.testScript>test</yarn.testScript>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <!-- Include NewRelic Agent in the WAR -->
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.newrelic.agent.java</groupId>
                                    <artifactId>newrelic-agent</artifactId>
                                    <version>${newrelic.version}</version>
                                    <type>jar</type>
                                    <outputDirectory>
                                        ${project.build.directory}/${project.build.finalName}/newrelic
                                    </outputDirectory>
                                    <destFileName>newrelic-agent.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <containerConfigXML>deploy/tomcat/context.xml</containerConfigXML>
                    <warSourceExcludes>app/,node_modules/,test-utils/,coverage/,generation-scripts/,
                        global-declarations/,oss-attribution/,webpack.common.mjs,webpack.prod.mjs,webpack.dev.mjs,
                        .prettierignore,.prettierrc.json,package-update-skip.json,package.json,
                        stylelint.config.mjs,tsconfig.json,vitest.config.ts,yarn.lock,eslint.config.mjs
                    </warSourceExcludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${plugin.frontend.version}</version>
                <configuration>
                    <installDirectory>${HOME}/.m2/maven-frontend-plugin/${node.version}</installDirectory>
                    <workingDirectory>${plugin.frontend.workingDirectory}</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install-node-and-yarn</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${node.version}</nodeVersion>
                            <yarnVersion>${yarn.version}</yarnVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn-install</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>install --frozen-lockfile --cache-folder ${HOME}/.cache/yarn</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn-generate-css-variables</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>generate-css-color-variables</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn-lint</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>lint:ci</arguments>
                            <skip>${js.lint.skip}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn-build</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>${yarn.targetScript}</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>${yarn.testScript}</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!--
          - Scope: COMPILE
          -->
        <dependency>
            <groupId>org.kuali.kfs</groupId>
            <artifactId>kfs-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!--
          - Scope: PROVIDED
          -->
        <dependency>
            <groupId>com.newrelic.agent.java</groupId>
            <artifactId>newrelic-agent</artifactId>
            <version>${newrelic.version}</version>
            <scope>provided</scope>
        </dependency>

        <!--
          - Scope: TEST
          -->
        <dependency>
            <groupId>org.kuali.kfs</groupId>
            <artifactId>kfs-core</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>frontend-update-dependencies</id>
            <properties>
                <nodeVersion>${node.version}</nodeVersion>
                <yarnVersion>${yarn.version}</yarnVersion>
            </properties>
            <build>
                <defaultGoal>
                    com.github.eirslett:frontend-maven-plugin:install-node-and-yarn@install-node-and-yarn
                    com.github.eirslett:frontend-maven-plugin:yarn@yarn-install
                </defaultGoal>
            </build>
        </profile>
    </profiles>
</project>
