<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.drools</groupId>
        <artifactId>droolsjbpm-integration</artifactId>
        <version>7.22.0.Final</version>
    </parent>

    <artifactId>process-migration-service</artifactId>
    <name>Process Instance Migration Service</name>
    <packaging>war</packaging>

    <properties>
        <version.fabric8-maven>3.5.42</version.fabric8-maven>
        <version.weld-junit>1.3.1.Final</version.weld-junit>
        <version.microprofile-health>1.0</version.microprofile-health>
        <version.org.jboss.weld.weld>2.4.3.Final</version.org.jboss.weld.weld>
        <version.org.jboss.weld.weld-api>2.4.SP2</version.org.jboss.weld.weld-api>
        <!-- Frontend properties -->
        <frontend-maven-plugin.version>1.7.6</frontend-maven-plugin.version>
        <maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
        <node.version>v11.6.0</node.version>
        <!-- Following properties are used only for testing -->
        <container.hostname>localhost</container.hostname>
        <kie.server.context.factory>org.wildfly.naming.client.WildFlyInitialContextFactory</kie.server.context.factory>
        <org.kie.server.persistence.ds>java:/jdbc/jbpm</org.kie.server.persistence.ds>
        <cargo.container.id>wildfly14x</cargo.container.id>
        <kie.server.classifier>ee7</kie.server.classifier>
        <!-- This property needs to be overridden when running tests against
            different version of the WAR (e.g. running SNAPSHOT tests against Beta3 WAR)
            so the tests actually know what exact version of server is being tested -->
        <kie.server.version>${project.version}</kie.server.version>
        <container.port>19090</container.port>
        <kie.server.context>kie-server</kie.server.context>
        <kie.server.controller.context>kie-server-controller-services</kie.server.controller.context>
        <kie.server.classifier>ee7</kie.server.classifier>
        <!-- Path to Kie server WAR file. Used for referencing WAR file in
            on-demand deployment/undeployment. -->
        <!-- <kie.server.war.path>${org.kie.server:kie-server:war:ee7}</kie.server.war.path> -->
        <org.kie.server.controller.templatefile>${project.build.directory}/server-template-storage.xml
        </org.kie.server.controller.templatefile>
        <webservice.http.url>
            http://${container.hostname}:${container.port}/kie-server-test-web-service/AcmeDemoInterface?wsdl
        </webservice.http.url>
        <kie.server.base.http.url>
            http://${container.hostname}:${container.port}/${kie.server.context}/services/rest/server
        </kie.server.base.http.url>

        <!-- Kie server datasource configuration. -->
        <!-- <org.kie.server.persistence.ds/> Defined in container profiles. -->
        <org.kie.server.persistence.dialect>org.hibernate.dialect.H2Dialect</org.kie.server.persistence.dialect>
        <org.kie.server.datasource.connection.url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
        </org.kie.server.datasource.connection.url>
        <org.kie.server.datasource.username>sa</org.kie.server.datasource.username>
        <org.kie.server.datasource.password>sa</org.kie.server.datasource.password>
        <org.kie.server.datasource.driver.class>org.h2.jdbcx.JdbcDataSource</org.kie.server.datasource.driver.class>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.thorntail</groupId>
                <artifactId>bom-all</artifactId>
                <version>${version.thorntail}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.eclipse.microprofile.health</groupId>
                <artifactId>microprofile-health-api</artifactId>
                <version>${version.microprofile-health}</version>
            </dependency>
            <dependency>
                <groupId>org.jboss.weld</groupId>
                <artifactId>weld-junit4</artifactId>
                <version>${version.weld-junit}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!-- KIE Dependencies -->
        <dependency>
            <groupId>org.kie.server</groupId>
            <artifactId>kie-server-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.kie.server</groupId>
            <artifactId>kie-server-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.kie.server</groupId>
            <artifactId>kie-server-controller-client</artifactId>
        </dependency>

        <!-- Thorntail Fractions -->
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>jaxrs</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>thorntail-jdk-specific</artifactId>
                    <groupId>io.thorntail.jdk-specific</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>logging</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>spi</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>microprofile-config</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>microprofile-health</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>ejb</artifactId>
        </dependency>

        <!-- External dependencies -->
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.health</groupId>
            <artifactId>microprofile-health-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-junit4</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>hibernate-jpa-2.1-api</artifactId>
                    <groupId>org.hibernate.javax.persistence</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>javax.activation-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>arquillian</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>thorntail-jdk-specific</artifactId>
                    <groupId>io.thorntail.jdk-specific</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>jboss-modules</artifactId>
                    <groupId>org.jboss.modules</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.kie.soup</groupId>
            <artifactId>kie-soup-maven-integration</artifactId>
        </dependency>
        <dependency>
            <groupId>org.kie.server</groupId>
            <artifactId>kie-server</artifactId>
            <classifier>${kie.server.classifier}</classifier>
            <type>war</type>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>process-migration</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <configuration>
                        <container>
                            <type>installed</type>
                            <artifactInstaller>
                                <groupId>org.wildfly</groupId>
                                <artifactId>wildfly-dist</artifactId>
                                <version>${version.org.wildfly}</version>
                            </artifactInstaller>
                            <systemProperties>
                                <!-- disable JMS support for executor to
                                    use same tests for all containers for jbpm executor -->
                                <org.kie.executor.jms>false</org.kie.executor.jms>
                                <org.kie.server.sync.deploy>true</org.kie.server.sync.deploy>
                            </systemProperties>
                            <dependencies>
                                <dependency>
                                    <groupId>com.h2database</groupId>
                                    <artifactId>h2</artifactId>
                                </dependency>
                            </dependencies>
                        </container>
                        <configuration>
                            <properties>
                                <cargo.jboss.configuration>standalone-full</cargo.jboss.configuration>
                                <cargo.jvmargs>-Xmx1024m</cargo.jvmargs>
                            </properties>
                            <datasources>
                                <datasource>
                                    <jndiName>${org.kie.server.persistence.ds}</jndiName>
                                    <driverClass>${org.kie.server.datasource.driver.class}</driverClass>
                                    <url>${org.kie.server.datasource.connection.url}</url>
                                    <username>${org.kie.server.datasource.username}</username>
                                    <password>${org.kie.server.datasource.password}</password>
                                    <transactionSupport>XA_TRANSACTION</transactionSupport>
                                </datasource>
                            </datasources>
                        </configuration>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <configuration>
                        <systemPropertyVariables>
                            <!-- Reuse yoda user for deploying and undeploying
                                Kie server from within the test -->
                            <kie-server.endpoint>${kie.server.base.http.url}</kie-server.endpoint>
                            <cargo.remote.username>yoda</cargo.remote.username>
                            <cargo.remote.password>usetheforce123@</cargo.remote.password>
                            <!-- Properties values are taken from application-users.properties and project-test.yml files -->
                            <pim.username>kermit</pim.username>
                            <pim.password>thefrog</pim.password>
                            <pim.endpoint>http://localhost:8180</pim.endpoint>
                        </systemPropertyVariables>
                        <includes>
                            <include>**/*IT.java</include>
                        </includes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude>**/*IT.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>${frontend-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${maven-resources-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>io.thorntail</groupId>
                <artifactId>thorntail-maven-plugin</artifactId>
                <version>${version.thorntail}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <configuration>
                    <container>
                        <containerId>${cargo.container.id}</containerId>
                        <systemProperties>
                            <kie.server.base.http.url>${kie.server.base.http.url}</kie.server.base.http.url>
                            <!-- Persistence configuration -->
                            <org.kie.server.persistence.ds>${org.kie.server.persistence.ds}
                            </org.kie.server.persistence.ds>
                            <org.kie.server.persistence.dialect>${org.kie.server.persistence.dialect}
                            </org.kie.server.persistence.dialect>
                        </systemProperties>
                    </container>
                    <deployer/>
                    <deployables>
                        <deployable>
                            <groupId>org.kie.server</groupId>
                            <artifactId>kie-server</artifactId>
                            <!-- default, may be overridden in container
                                specific profiles -->
                            <classifier>${kie.server.classifier}</classifier>
                            <type>war</type>
                            <properties>
                                <context>${kie.server.context}</context>
                            </properties>
                            <pingURL>${kie.server.base.http.url}</pingURL>
                            <pingTimeout>60000</pingTimeout>
                        </deployable>
                    </deployables>
                    <configuration>
                        <users>
                            <user>
                                <name>Administrator</name>
                                <password>usetheforce123@</password>
                                <roles>
                                    <role>kie-server</role>
                                    <role>guest</role>
                                    <role>Administrators</role>
                                </roles>
                            </user>
                            <user>
                                <name>yoda</name>
                                <password>usetheforce123@</password>
                                <roles>
                                    <role>kie-server</role>
                                </roles>
                            </user>
                        </users>
                        <properties>
                            <cargo.servlet.port>${container.port}</cargo.servlet.port>
                            <cargo.jboss.management-http.port>19991</cargo.jboss.management-http.port>
                        </properties>
                    </configuration>
                </configuration>
                <executions>
                    <execution>
                        <id>start-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-container</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <!-- <thorntail.project.stage.file>${basedir}/src/test/resources/project-test.yml</thorntail.project.stage.file> -->
                        <thorntail.project.stage>test</thorntail.project.stage>
                    </systemProperties>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <workingDirectory>frontend</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${node.version}</nodeVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>run tests</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <arguments>test</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>frontend</directory>
                                    <includes>
                                        <include>bundle.js</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-css</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}/css</outputDirectory>
                            <overwrite>true</overwrite>
                            <resources>
                                <resource>
                                    <directory>frontend/src/css/</directory>
                                    <includes>
                                        <include>**/*</include>
                                    </includes>
                                    <excludes>
                                        <exclude>*.map</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>openshift</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>fabric8-maven-plugin</artifactId>
                        <version>${version.fabric8-maven}</version>
                        <configuration>
                            <!-- <enricher> -->
                            <!-- <excludes> -->
                            <!-- <exclude>f8-expose</exclude> -->
                            <!-- </excludes> -->
                            <!-- <config> -->
                            <!-- <fmp-service> -->
                            <!-- <type>NodePort</type> -->
                            <!-- </fmp-service> -->
                            <!-- </config> -->
                            <!-- </enricher> -->
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>resource</goal>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
