<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright (c) Codice Foundation
 *
 * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or 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 Lesser General Public License for more details. A copy of the GNU Lesser General Public License is distributed along with this program and can be found at
 * <http://www.gnu.org/licenses/lgpl.html>.
 *
 **/
-->
<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>
    <parent>
        <artifactId>catalog-ui</artifactId>
        <groupId>org.codice.ddf.search</groupId>
        <version>5.2.34</version>
    </parent>
    <groupId>org.codice.ddf.search</groupId>
    <artifactId>ui-frontend</artifactId>
    <name>DDF :: UI</name>
    <packaging>pom</packaging>
    <properties>
        <buildEnv>production</buildEnv>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <finalName>packages</finalName>
                    <descriptors>
                        <descriptor>packages.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>create-archive</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <id>install node and yarn</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${node.version}</nodeVersion>
                            <yarnVersion>${yarn.version}</yarnVersion>
                            <nodeDownloadRoot>${node.download.root}</nodeDownloadRoot>
                            <yarnDownloadRoot>${yarn.download.root}</yarnDownloadRoot>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn install</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>install --network-concurrency 1 --frozen-lockfile</arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>yarn test</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <!--Do not run this plugin execution if we are skipping tests-->
                            <skip>${skipTests}</skip>
                            <arguments>run test</arguments>
                            <environmentVariables>
                                <NODE_ENV>${buildEnv}</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                    </execution>

                    <execution>
                        <id>yarn build</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                            <environmentVariables>
                                <NODE_ENV>${buildEnv}</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                    </execution>
                    <!-- TODO - Resolve test errors https://github.com/codice/ddf-ui/issues/66 -->
                    <!--                    <execution>-->
                    <!--                        <id>test</id>-->
                    <!--                        <phase>test</phase>-->
                    <!--                        <goals>-->
                    <!--                            <goal>yarn</goal>-->
                    <!--                        </goals>-->
                    <!--                        <configuration>-->
                    <!--                            <arguments>run test</arguments>-->
                    <!--                        </configuration>-->
                    <!--                    </execution>-->
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <inherited>false</inherited>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <!-- NOTE: please don't edit these artifacts manually. -->
                                <![CDATA[ They were calculated by running "ace pom --fix". ]]>
                                <!-- Please re-run the command if the artifacts need to be updated. -->
                                <artifact>
                                    <file>target/features.xml</file>
                                    <type>xml</type>
                                    <classifier>features</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/admin/target/kanri.jar</file>
                                    <type>jar</type>
                                    <classifier>kanri</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/admin/target/kanri.tgz</file>
                                    <type>tgz</type>
                                    <classifier>kanri</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/catalog-ui-search/target/catalog-ui-search.jar</file>
                                    <type>jar</type>
                                    <classifier>catalog-ui-search</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/catalog-ui-search/dist/catalog-ui-search.tgz</file>
                                    <type>tgz</type>
                                    <classifier>catalog-ui-search-src</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/cesium-assets/target/cesium-assets.jar</file>
                                    <type>jar</type>
                                    <classifier>cesium-assets</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/cesium-assets/target/cesium-assets.tgz</file>
                                    <type>tgz</type>
                                    <classifier>cesium-assets</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/logout/target/logout.jar</file>
                                    <type>jar</type>
                                    <classifier>logout</classifier>
                                </artifact>
                                <artifact>
                                    <file>packages/logout/target/logout.tgz</file>
                                    <type>tgz</type>
                                    <classifier>logout</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check-artifact-size</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <ArtifactSizeEnforcerRule implementation="org.codice.maven.artifactsize.ArtifactSizeEnforcerRule">
                                    <maxArtifactSize>48.4_MB</maxArtifactSize>
                                </ArtifactSizeEnforcerRule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <haltOnFailure>true</haltOnFailure>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>INSTRUCTION</counter>
                                            <minimum>0</minimum>
                                        </limit>
                                        <limit>
                                            <counter>BRANCH</counter>
                                            <minimum>0</minimum>
                                        </limit>
                                        <limit>
                                            <counter>COMPLEXITY</counter>
                                            <minimum>0</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>dev</id>
            <activation>
                <property>
                    <name>webBuildEnv</name>
                    <value>dev</value>
                </property>
            </activation>
            <properties>
                <buildEnv>development</buildEnv>
            </properties>
        </profile>
    </profiles>
</project>
