<?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>
        <artifactId>allure-core</artifactId>
        <groupId>ru.yandex.qatools.allure</groupId>
        <version>1.4.16</version>
    </parent>

    <artifactId>allure-report-face</artifactId>
    <packaging>war</packaging>

    <name>Allure Report Face</name>

    <properties>
        <sonar.language>js</sonar.language>
        <sonar.sources>src/main/webapp/js,src/main/webapp/plugins</sonar.sources>
        <sonar.tests>src/test/webapp/core,src/test/webapp/plugins</sonar.tests>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.javascript.jstestdriver.reportsPath>
            ${project.build.directory}/surefire-reports/
        </sonar.javascript.jstestdriver.reportsPath>
        <sonar.javascript.lcov.reportPath>${project.build.directory}/site/coverage/total-coverage.dat</sonar.javascript.lcov.reportPath>

        <sonar.exclusions>vendor/**</sonar.exclusions>
        <sonar.tests.exclusions>vendor/**</sonar.tests.exclusions>
    </properties>

    <build>
        <sourceDirectory>src/main/webapp</sourceDirectory>
        <testSourceDirectory>src/test/webapp</testSourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.9</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/webjars</outputDirectory>

                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>font-awesome</artifactId>
                                    <version>4.2.0</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>bootstrap</artifactId>
                                    <version>3.2.0-2</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>d3js</artifactId>
                                    <version>3.4.11</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>jquery</artifactId>
                                    <version>2.1.1</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>angularjs</artifactId>
                                    <version>1.2.26</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>angular-ui-router</artifactId>
                                    <version>0.2.13</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>angular-ui-bootstrap</artifactId>
                                    <version>0.11.2</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>angular-loading-bar</artifactId>
                                    <version>0.6.0</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>angular-translate</artifactId>
                                    <version>2.6.0</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>angular-translate-interpolation-messageformat</artifactId>
                                    <version>0.1.2</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>angular-translate-loader-partial</artifactId>
                                    <version>2.6.0</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>messageformat.js</artifactId>
                                    <version>0.1.4</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars</groupId>
                                    <artifactId>highlightjs</artifactId>
                                    <version>8.2-1</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.webjars.bower</groupId>
                                    <artifactId>Sortable</artifactId>
                                    <version>1.2.0</version>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.lesscss</groupId>
                <artifactId>lesscss-maven-plugin</artifactId>
                <version>1.7.0.1.1</version>
                <configuration>
                    <sourceDirectory>${project.basedir}/src/main/less</sourceDirectory>
                    <outputDirectory>${project.basedir}/src/main/webapp/css</outputDirectory>
                    <compress>true</compress>
                    <includes>
                        <include>app.less</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>build-styles</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <includes>
                                <include>index.html</include>
                            </includes>
                            <filtering>true</filtering>
                        </resource>
                        <resource>
                            <includes>
                                <include>webjars/jquery/2.1.1/jquery.min.js</include>
                                <include>webjars/d3js/3.4.11/d3.min.js</include>
                                <include>webjars/angularjs/1.2.26/angular.min.js</include>
                                <include>webjars/angularjs/1.2.26/angular-animate.min.js</include>
                                <include>webjars/angular-ui-bootstrap/0.11.2/ui-bootstrap-tpls.min.js</include>
                                <include>webjars/angular-ui-router/0.2.13/angular-ui-router.js</include>
                                <include>webjars/angular-loading-bar/0.6.0/loading-bar.js</include>
                                <include>webjars/angular-translate/2.6.0/angular-translate.js</include>
                                <include>webjars/angular-translate-loader-partial/2.6.0/angular-translate-loader-partial.js</include>
                                <include>webjars/messageformat.js/0.1.4/messageformat.js</include>
                                <include>webjars/angular-translate-interpolation-messageformat/0.1.2/angular-translate-interpolation-messageformat.js</include>
                                <include>webjars/highlightjs/8.2-1/highlight.min.js</include>
                                <include>webjars/font-awesome/4.2.0/fonts/**</include>
                                <include>webjars/Sortable/1.2.0/ng-sortable.js</include>
                                <include>webjars/Sortable/1.2.0/Sortable.min.js</include>
                            </includes>
                            <directory>${project.build.directory}/webjars/META-INF/resources</directory>
                            <filtering>false</filtering>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.searls</groupId>
                <artifactId>jasmine-maven-plugin</artifactId>
                <version>1.3.1.2</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>unit-test-running</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>
                </executions>
                <configuration>
                    <keepServerAlive>true</keepServerAlive>
                    <jsSrcDir>src/main/webapp</jsSrcDir>
                    <sourceIncludes>
                        <sourceInclude>js/**</sourceInclude>
                        <sourceInclude>plugins/**</sourceInclude>
                    </sourceIncludes>
                    <jsTestSrcDir>src/test/webapp</jsTestSrcDir>
                    <specIncludes>
                        <specInclude>vendor/**</specInclude>
                        <specInclude>core/**</specInclude>
                        <specInclude>plugins/**</specInclude>
                    </specIncludes>
                    <jasmineTargetDir>${project.build.directory}/surefire-reports</jasmineTargetDir>
                    <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
                    <preloadSources>
                        <source>target/webjars/META-INF/resources/webjars/jquery/2.1.1/jquery.js</source>
                        <source>target/webjars/META-INF/resources/webjars/d3js/3.4.11/d3.min.js</source>
                        <source>target/webjars/META-INF/resources/webjars/angularjs/1.2.26/angular.js</source>
                        <source>target/webjars/META-INF/resources/webjars/angularjs/1.2.26/angular-animate.js</source>
                        <source>target/webjars/META-INF/resources/webjars/angularjs/1.2.26/angular-mocks.js</source>
                    </preloadSources>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>coverage</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.timurstrekalov</groupId>
                        <artifactId>saga-maven-plugin</artifactId>
                        <version>1.5.3</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>coverage</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <reportFormats>RAW</reportFormats>
                            <baseDir>http://0.0.0.0:${jasmine.serverPort}</baseDir>
                            <outputDir>${project.build.directory}/site/coverage</outputDir>
                            <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
                            <noInstrumentPatterns>
                                <pattern>.*/test/.*</pattern>
                                <pattern>.*/vendor/.*</pattern>
                                <pattern>.*/webjars/.*</pattern>
                            </noInstrumentPatterns>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.google.code.maven-replacer-plugin</groupId>
                        <artifactId>replacer</artifactId>
                        <version>1.5.3</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>replace</goal>
                                </goals>
                                <phase>verify</phase>
                                <configuration>
                                    <ignoreMissingFile>true</ignoreMissingFile>
                                    <file>${project.build.directory}/site/coverage/total-coverage.dat</file>
                                    <replacements>
                                        <replacement>
                                            <token>SF:*src/</token>
                                            <value>SF:${project.basedir}/src/main/webapp/</value>
                                        </replacement>
                                    </replacements>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>dev</id>
            <properties>
                <allure.results.directory>${project.build.directory}/allure-results</allure.results.directory>
                <allure.report.directory>${project.build.directory}/allure-report</allure.report.directory>
                <allure.issues.tracker.pattern>http://github.com/allure-framework/allure-core/issues/%s</allure.issues.tracker.pattern>
                <allure.tests.management.pattern>http://github.com/allure-framework/allure-core/tests/%s</allure.tests.management.pattern>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>ru.yandex.qatools.allure</groupId>
                    <artifactId>allure-report-data</artifactId>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-allure-model-test-resources</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${allure.results.directory}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>
                                                ${project.parent.basedir}/allure-model/src/test/resources/allure-results
                                            </directory>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <mainClass>ru.yandex.qatools.allure.data.DummyReportGenerator</mainClass>
                            <arguments>
                                <argument>${allure.results.directory}</argument>
                                <argument>${allure.report.directory}</argument>
                            </arguments>
                            <systemProperties>
                                <property>
                                    <key>allure.issues.tracker.pattern</key>
                                    <value>${allure.issues.tracker.pattern}</value>
                                </property>
                                <property>
                                    <key>allure.tests.management.pattern</key>
                                    <value>${allure.tests.management.pattern}</value>
                                </property>
                            </systemProperties>
                            <additionalClasspathElements>
                                <classpathElement>
                                    ${settings.localRepository}/org/slf4j/slf4j-simple/1.7.12/slf4j-simple-1.7.12.jar
                                </classpathElement>
                            </additionalClasspathElements>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.slf4j</groupId>
                                <artifactId>slf4j-simple</artifactId>
                                <version>1.7.12</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <configuration>
                            <scanIntervalSeconds>3</scanIntervalSeconds>
                            <contextHandlers>
                                <contextHandler implementation="org.eclipse.jetty.server.handler.ContextHandler">
                                    <contextPath>/data</contextPath>
                                    <resourceBase>target/allure-report/data/</resourceBase>
                                    <handler implementation="org.eclipse.jetty.server.handler.ResourceHandler" />
                                </contextHandler>
                                <contextHandler implementation="org.eclipse.jetty.server.handler.ContextHandler">
                                    <contextPath>/webjars</contextPath>
                                    <resourceBase>target/webjars/META-INF/resources/webjars/</resourceBase>
                                    <handler implementation="org.eclipse.jetty.server.handler.ResourceHandler" />
                                </contextHandler>
                            </contextHandlers>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
