<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  itests-web
  $Id:$
  $HeadURL:$
  %%
  Copyright (C) 2016 - 2026 iNovex Information Systems, 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 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/>.
  #L%
  -->
<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>mobi-itests</artifactId>
        <groupId>com.mobi</groupId>
        <version>4.3.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>itests-web</artifactId>
    <name>itests-web</name>

    <dependencies>
        <!-- Karaf Dependencies -->
        <dependency>
            <groupId>com.mobi</groupId>
            <artifactId>mobi-distribution</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
            <type>tar.gz</type>
            <exclusions>
                <exclusion>
                    <artifactId>org.apache.karaf.client</artifactId>
                    <groupId>org.apache.karaf</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <properties>
        <distributionName>mobi</distributionName>
        <distribution>mobi-distribution</distribution>
        <source-files>Dockerfile, import.sh, dataFiles, mobi-distribution.tar.gz</source-files>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.7.1</version>
                <executions>
                    <execution>
                        <id>make-sources-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptors>
                        <descriptor>src/assembly/src.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>run-functional</id>
            <activation>
                <property>
                    <name>skipFunctional</name>
                    <value>false</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>3.1.1</version>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.mobi</groupId>
                                    <artifactId>mobi-distribution</artifactId>
                                    <version>${project.version}</version>
                                    <type>tar.gz</type>
                                    <overWrite>false</overWrite>
                                    <destFileName>mobi-distribution.tar.gz</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.basedir}/target/classes</outputDirectory>
                            <overWriteReleases>true</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>npm-lint</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>npm</executable>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>lint</argument>
                                    </arguments>
                                    <workingDirectory>${project.basedir}</workingDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.15.1</version>
                        <executions>
                            <execution>
                                <id>install node and npm</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>v18.19.0</nodeVersion>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm install</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <phase>generate-test-sources</phase>
                            </execution>
                            <execution>
                                <id>npm run test</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <arguments>run test-headless</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
                <resources>
                    <resource>
                        <directory>${project.basedir}/src/test/resources/build-resources</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </build>
        </profile>
    </profiles>
</project>
