<?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">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.atlassian.rm</groupId>
        <artifactId>team-management</artifactId>
        <version>1001.0.0-D20170209T023732</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>team-management-client-common</artifactId>

    <name>Portfolio 2 / Team Management [Client Common]</name>

    <!-- "exporting" is handled via gulp/grunt only -->
    <packaging>pom</packaging>

    <dependencies>

        <dependency>
            <groupId>com.atlassian.rm</groupId>
            <artifactId>common-client</artifactId>
            <version>${project.version}</version>
            <type>pom</type>
        </dependency>

    </dependencies>

    <build>

        <pluginManagement>

            <plugins>

                <!-- client builds -->

                <plugin>

                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>

                    <executions>

                        <execution>

                            <id>grunt-build</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>

                            <configuration>

                                <executable>${path.to.common.client}/${node.modules.bin}/${grunt.executable}</executable>

                                <arguments>
                                    <argument>--base</argument>
                                    <argument>${path.to.common.client}</argument>
                                </arguments>

                                <environmentVariables>
                                    <PATH>${basedir}/${path.to.node.folder}${path.separator}${env.PATH}</PATH>
                                </environmentVariables>

                            </configuration>

                        </execution>

                    </executions>

                </plugin>

            </plugins>

        </pluginManagement>

    </build>

    <profiles>

        <profile>

            <id>client-unit-tests</id>
            <activation>
                <property>
                    <name>!skipTests</name>
                </property>
            </activation>

            <build>

                <pluginManagement>

                    <plugins>

                        <plugin>

                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>exec-maven-plugin</artifactId>

                            <executions>

                                <execution>

                                    <id>jasmine-unit-tests</id>
                                    <phase>test</phase>
                                    <goals>
                                        <goal>exec</goal>
                                    </goals>

                                    <configuration>

                                        <executable>${path.to.common.client}/${node.modules.bin}/${karma.executable}</executable>

                                        <arguments>
                                            <argument>start</argument>
                                            <argument>karma.conf.js</argument>
                                        </arguments>

                                        <environmentVariables>
                                            <PATH>${basedir}/${path.to.node.folder}${path.separator}${env.PATH}</PATH>
                                        </environmentVariables>

                                    </configuration>

                                </execution>

                            </executions>

                        </plugin>

                    </plugins>

                </pluginManagement>

            </build>

        </profile>

        <profile>

            <id>client-build</id>
            <activation>
                <property>
                    <name>!skipClient</name>
                </property>
            </activation>

            <build>

                <plugins>

                    <plugin>

                        <artifactId>maven-clean-plugin</artifactId>

                        <configuration>
                            <filesets combine.children="append">
                                <fileset>
                                    <directory>src/main/resources</directory>
                                    <includes>
                                        <include>scripts</include>
                                        <include>scripts-common/</include>
                                        <include>scripts-lib-common/</include>
                                    </includes>
                                </fileset>
                                <fileset>
                                    <directory>src/test/resources</directory>
                                    <includes>
                                        <include>scripts</include>
                                        <include>scripts-common/</include>
                                        <include>scripts-lib-common/</include>
                                    </includes>
                                </fileset>
                            </filesets>
                        </configuration>

                    </plugin>

                    <plugin>

                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>

                    </plugin>

                </plugins>

            </build>

        </profile>

    </profiles>

</project>