<?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">
    <parent>
        <artifactId>control-components-orchestrator</artifactId>
        <groupId>com.scytl.products.ov.channel.cc.orchestrator</groupId>
        <version>2.1.7</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>or-ws-rest</artifactId>
    <packaging>war</packaging>
    <name>Online Voting - Control Components Orchestrator - Webservices</name>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.scytl.products.ov.channel.commons</groupId>
                <artifactId>ov-commons-integration-tests</artifactId>
                <version>${project.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Needed to overwrite the SpringBoot conflicting log4j12 dependency - do not remove -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j-api.version}</version>
        </dependency>      
        <dependency>
            <groupId>com.scytl.products.ov.channel.cc.orchestrator</groupId>
            <artifactId>orchestrator-commons</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.scytl.products.ov.channel.cc.orchestrator</groupId>
            <artifactId>ov-cc-or-choice-codes-services</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.scytl.products.ov.channel.cc.orchestrator</groupId>
            <artifactId>ov-cc-or-mixing-services</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.scytl.products.ov.channel.commons</groupId>
            <artifactId>ov-commons-integration-tests</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>javaee-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>retrofit-mock</artifactId>
            <version>${retrofit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.scytl.products.ov.channel.commons</groupId>
            <artifactId>ov-commons-dto</artifactId>
        </dependency>

        <!-- In-memory embedded message broker for tests -->
        <dependency>
            <groupId>org.apache.qpid</groupId>
            <artifactId>qpid-broker-core</artifactId>
            <version>${qpid.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.qpid</groupId>
            <artifactId>qpid-broker-plugins-amqp-0-8-protocol</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.qpid</groupId>
            <artifactId>qpid-broker-plugins-memory-store</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
    </build>
    <profiles>
        <profile>
            <id>skipTestRun</id>
            <activation>
                <property>
                    <name>skipTests</name>
                    <value>!true</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.scytl.products.ov.channel.commons</groupId>
                    <artifactId>ov-commons-dto</artifactId>
                    <version>${project.version}</version>
                    <type>test-jar</type>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>com.scytl.products.ov.channel.commons.lib</groupId>
                    <artifactId>ov-commons-lib</artifactId>
                    <version>${project.version}</version>
                    <type>test-jar</type>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/*TestSuite.java</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- The profile below can be used if the HTML API files should be generated -->
            <!-- It includes the installation of node, npm and raml2html -->
            <id>generate-all-html-apis</id>
            <build>
                <finalName>${project.artifactId}</finalName>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${frontend-maven-plugin.version}</version>
                        <!-- install local installation of node and npm in the target directory -->
                        <configuration>
                            <installDirectory>target</installDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install node and npm</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>${node.version}</nodeVersion>
                                    <npmVersion>${npm.version}</npmVersion>
                                    <nodeDownloadRoot>https://nexus.scytl.net/service/local/repositories/applications/content/org/nodejs/node/</nodeDownloadRoot>
                                    <npmDownloadRoot>https://nexus.scytl.net/service/local/repositories/applications/content/com/github/npm/npm/</npmDownloadRoot>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <!-- Install raml2html  -->
                            <execution>
                                <id>id0</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>npm</executable>
                                    <commandlineArgs>install --prefix ./target/node/node_modules/npm-${npm.version} raml2html</commandlineArgs>
                                </configuration>
                            </execution>
                            <!-- Generate API file  -->
                            <execution>
                                <id>id1</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>target/node/node_modules/npm/node_modules/raml2html/bin/raml2html</executable>
                                    <commandlineArgs>-i src/main/resources/api.raml -o target/api.html</commandlineArgs>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
