<?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.audit</groupId>
        <artifactId>atlassian-audit</artifactId>
        <version>1.9.2</version>
    </parent>

    <artifactId>atlassian-audit-plugin</artifactId>
    <version>1.9.2</version>
    <packaging>atlassian-plugin</packaging>

    <name>Atlassian Audit Plugin</name>
    <description>This plugin offers extensive event coverage and a user-friendly design. In Data Center, you can also select an optimal event volume and log audit events to a file.</description>

    <properties>
        <!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <includeITsPattern>%regex[it[/\\].*]</includeITsPattern>
        <!-- Frontend build config -->
        <fe.plugin.version>1.8.0</fe.plugin.version>
        <fe.node.installdir>.node</fe.node.installdir>
        <fe.location>/frontend</fe.location>
        <fe.node.version>v12.9.1</fe.node.version> <!-- the "v" is important, update ./frontend/package.json if you
        change this -->
        <fe.yarn.version>v1.21.1</fe.yarn.version>
        <minify.plugin.version>1.3.0</minify.plugin.version>
        <skipYarnInstall>false</skipYarnInstall>
        <skipWebpackBuild>false</skipWebpackBuild>

        <!-- Contract Testing config-->
        <ct.location>/contract-testing</ct.location>

        <jvmHeap>-Xmx1536m -Xms512m -XX:ReservedCodeCacheSize=256m -XX:MaxMetaspaceSize=512m</jvmHeap>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.audit</groupId>
            <artifactId>atlassian-audit-api</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.audit</groupId>
            <artifactId>atlassian-audit-spi</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.audit</groupId>
            <artifactId>atlassian-audit-rest-model</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.0.10.RELEASE</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>5.0.10.RELEASE</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.upgrade</groupId>
            <artifactId>upgrade-task-framework-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Spring Osgi Config -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- AO -->
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <version>${atlassian.ao.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>

        <!-- Scheduler -->

        <dependency>
            <groupId>com.atlassian.scheduler</groupId>
            <artifactId>atlassian-scheduler-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.event</groupId>
            <artifactId>atlassian-event</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Rest -->
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-module</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>2.0.10</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.supercsv</groupId>
            <artifactId>super-csv</artifactId>
        </dependency>
        <dependency>
            <groupId>io.atlassian.util.concurrent</groupId>
            <artifactId>atlassian-util-concurrent</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Analytics -->
        <dependency>
            <groupId>com.atlassian.analytics</groupId>
            <artifactId>analytics-api</artifactId>
            <scope>provided</scope>
        </dependency>


        <!-- Front end -->
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webfragment-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.json</groupId>
            <artifactId>atlassian-json-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.21.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-test</artifactId>
            <version>3.2.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.176</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.vmlens</groupId>
            <artifactId>concurrent-junit</artifactId>
            <version>1.0.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <!-- 
                This profile is run by default.
                See the activeByDefault setting
            -->
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>io.fabric8</groupId>
                            <artifactId>docker-maven-plugin</artifactId>
                            <version>0.33.0</version>
                        </plugin>
                        <plugin>
                            <groupId>io.swagger.core.v3</groupId>
                            <artifactId>swagger-maven-plugin</artifactId>
                            <version>2.0.10</version>
                        </plugin>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>sql-maven-plugin</artifactId>
                            <version>1.4</version>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <configuration>
                            <outputFileName>swagger</outputFileName>
                            <outputPath>${project.build.directory}/swagger-generated</outputPath>
                            <outputFormat>JSON</outputFormat>
                            <resourcePackages>
                                <package>com.atlassian.audit.rest</package>
                            </resourcePackages>
                        </configuration>
                        <executions>
                            <execution>
                                <id>swagger-resolve</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>resolve</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>amps-maven-plugin</artifactId>
                        <version>${amps.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <enableQuickReload>true</enableQuickReload>
                            <instructions>
                                <!-- Plugin configuration -->
                                <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                                <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                                <!-- Add package to export here -->
                                <Import-Package>
                                    net.java.ao;version="3.2.3",
                                    com.atlassian.audit.api.internal.*,
                                    com.atlassian.upgrade.api.*;resolution:="optional",
                                    com.atlassian.upgrade.spi.*;resolution:="optional",
                                    org.springframework.osgi.*;resolution:="optional",
                                    org.eclipse.gemini.blueprint.*;resolution:="optional",
                                    sun.misc*;resolution:="optional",
                                    *
                                </Import-Package>
                                <!-- Ensure plugin is spring powered -->
                                <Spring-Context>*</Spring-Context>
                            </instructions>
                            <skipITs>true</skipITs>
                            <products>
                                <product>
                                    <id>bitbucket</id>
                                    <version>${bitbucket.version}</version>
                                    <productDataVersion>${bitbucket.version}</productDataVersion>
                                    <httpPort>${bitbucket.http.port}</httpPort>
                                    <jvmArgs>${jvmHeap}</jvmArgs>
                                    <systemPropertyVariables>
                                        <bitbucket.version>${bitbucket.version}
                                        </bitbucket.version> <!-- system property required by Functest RPC plugin -->
                                        <xvfb.enable>${xvfb.enable}</xvfb.enable>
                                        <xvfb.display>${xvfb.display}</xvfb.display>
                                        <context.path>${bitbucket.context.path}</context.path>
                                        <atl.audit.version>${project.version}</atl.audit.version>
                                        <johnson.spring.lifecycle.synchronousStartup>true
                                        </johnson.spring.lifecycle.synchronousStartup>
                                    </systemPropertyVariables>
                                </product>
                                <product>
                                    <id>confluence</id>
                                    <version>${confluence.version}</version>
                                    <productDataVersion>${confluence.data.version}</productDataVersion>
                                    <jvmArgs>
                                        -XX:+UseG1GC -Datlassian.darkfeature.confluence.onboarding.bypass=true
                                        -Datlassian.darkfeature.confluence.pulp=true
                                        -Dtroubleshooting.dev.mode=true ${jvmHeap}
                                    </jvmArgs>
                                </product>
                                <product>
                                    <id>jira</id>
                                    <version>${jira.version}</version>
                                    <productDataVersion>${jira.version}</productDataVersion>
                                    <jvmArgs>
                                        -XX:+UseG1GC -Datlassian.darkfeature.jira.onboarding.feature.disabled=true
                                        -Datlassian.mail.senddisabled=false -Djira.startup.warnings.disable=true
                                        -Dcom.atlassian.jira.advanced.audit.log.enabled
                                        -Dtroubleshooting.dev.mode=true ${jvmHeap}
                                    </jvmArgs>
                                </product>
                                <product>
                                    <id>refapp</id>
                                    <version>${refapp.version}</version>
                                </product>
                            </products>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-tests</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>${includeITsPattern}</include>
                                    </includes>
                                    <systemProperties>
                                        <product>confluence</product>
                                    </systemProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${fe.plugin.version}</version>
                        <configuration>
                            <workingDirectory>${basedir}${fe.location}</workingDirectory>
                            <nodeVersion>${fe.node.version}</nodeVersion>
                            <yarnVersion>${fe.yarn.version}</yarnVersion>
                            <installDirectory>${fe.node.installdir}</installDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install node and yarn</id>
                                <goals>
                                    <goal>install-node-and-yarn</goal>
                                </goals>
                                <phase>generate-resources</phase>
                            </execution>
                            <execution>
                                <id>yarn install</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <skip>${skipYarnInstall}</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>webpack</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>build</arguments>
                                    <skip>${skipWebpackBuild}</skip>
                                    <environmentVariables>
                                        <PLUGIN_KEY>${atlassian.plugin.key}</PLUGIN_KEY>
                                    </environmentVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.atlassian.minify</groupId>
                        <artifactId>minify-maven-plugin</artifactId>
                        <version>${minify.plugin.version}</version>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>contract-testing</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>amps-maven-plugin</artifactId>
                        <version>${amps.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <skipITs>true</skipITs>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${fe.plugin.version}</version>
                        <configuration>
                            <workingDirectory>${basedir}${ct.location}</workingDirectory>
                            <nodeVersion>${fe.node.version}</nodeVersion>
                            <yarnVersion>${fe.yarn.version}</yarnVersion>
                            <installDirectory>${fe.node.installdir}</installDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install node and yarn</id>
                                <goals>
                                    <goal>install-node-and-yarn</goal>
                                </goals>
                                <phase>integration-test</phase>
                            </execution>
                            <execution>
                                <id>install-node-dependencies</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <phase>integration-test</phase>
                            </execution>
                            <execution>
                                <id>validate-swagger-spec</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>validate</arguments>
                                </configuration>
                                <phase>integration-test</phase>
                            </execution>
                            <execution>
                                <id>share-swagger-spec</id>
                                <goals>
                                    <goal>yarn share</goal>
                                </goals>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.atlassian.minify</groupId>
                        <artifactId>minify-maven-plugin</artifactId>
                        <version>${minify.plugin.version}</version>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>postgres</id>
            <properties>
                <db.host>localhost</db.host>
                <db.name>ao_test</db.name>
                <db.username>ao_user</db.username>
                <db.password>ao_password</db.password>
                <docker.image>postgres:9.4</docker.image>
                <docker.wait.log>PostgreSQL init process complete</docker.wait.log>
                <jdbc.version>42.2.6</jdbc.version>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>${jdbc.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install node and yarn</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>yarn install</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>webpack</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>swagger-resolve</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <jdbc.url>jdbc:postgresql://localhost:${db.port}/${db.name}?loggerLevel=DEBUG</jdbc.url>
                                <jdbc.schema>public</jdbc.schema>
                                <jdbc.user>${db.username}</jdbc.user>
                                <jdbc.password>${db.password}</jdbc.password>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                            <images>
                                <image>
                                    <name>${docker.image}</name>
                                    <run>
                                        <ports>
                                            <port>db.port:5432</port>
                                        </ports>
                                        <env>
                                            <POSTGRES_DB>${db.name}</POSTGRES_DB>
                                            <POSTGRES_USER>${db.username}</POSTGRES_USER>
                                            <POSTGRES_PASSWORD>${db.password}</POSTGRES_PASSWORD>
                                        </env>
                                        <wait>
                                            <log>${docker.wait.log}</log>
                                            <time>1200000</time>
                                        </wait>
                                        <log>
                                            <prefix>postgres</prefix>
                                        </log>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>mysql</id>
            <properties>
                <db.host>localhost</db.host>
                <db.name>ao_test</db.name>
                <db.username>ao_user</db.username>
                <db.password>ao_password</db.password>
                <db.schema>ao_schema</db.schema>
                <ao.test.database>mysql</ao.test.database>
                <docker.wait.log>starting as process 1</docker.wait.log>
                <docker.image>mysql:5.5</docker.image>
                <db.system.username>root</db.system.username>
                <db.system.password>root</db.system.password>
                <jdbc.version>8.0.18</jdbc.version>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>${jdbc.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install node and yarn</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>yarn install</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>webpack</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>swagger-resolve</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <jdbc.url>jdbc:mysql://localhost:${db.port}/${db.name}?autoReconnect=true</jdbc.url>
                                <jdbc.schema>${db.schema}</jdbc.schema>
                                <jdbc.user>${db.username}</jdbc.user>
                                <jdbc.password>${db.password}</jdbc.password>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                            <images>
                                <image>
                                    <name>${docker.image}</name>
                                    <run>
                                        <ports>
                                            <port>db.port:3306</port>
                                        </ports>
                                        <env>
                                            <MYSQL_DATABASE>${db.name}</MYSQL_DATABASE>
                                            <MYSQL_USER>${db.username}</MYSQL_USER>
                                            <MYSQL_PASSWORD>${db.password}</MYSQL_PASSWORD>
                                            <MYSQL_ROOT_PASSWORD>${db.system.password}</MYSQL_ROOT_PASSWORD>
                                        </env>
                                        <wait>
                                            <log>${docker.wait.log}</log>
                                            <time>120000</time>
                                        </wait>
                                        <log>
                                            <prefix>mysql</prefix>
                                        </log>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>sqlserver</id>
            <properties>
                <!-- Current latest version. Override in bamboo-specs -->
                <docker.tag>2019-RC1</docker.tag>
                <docker.image>mcr.microsoft.com/mssql/server:${docker.tag}</docker.image>
                <!-- Ready for connection != ready -->
                <docker.wait.log>.*Recovery is complete. This is an informational message only. No user action is required..*</docker.wait.log>
                <db.host>localhost</db.host>
                <db.port>1433</db.port>
                <db.name>ao_test</db.name>
                <!-- This is used for creating database and schema in maven by sql-maven-plugin -->
                <db.url.no.db>jdbc:sqlserver://${db.host}:${db.port}</db.url.no.db>
                <!-- These are used by DynamicJdbcConfiguration.buildJdbcConfiguration to build connection -->
                <db.username>sa</db.username>
                <!-- SQL Server requires complex password -->
                <db.password>AO_password12</db.password>
                <db.url>${db.url.no.db};databaseName=${db.name}</db.url>
                <db.schema>ao_schema</db.schema>
                <ao.test.database>sqlserver</ao.test.database>
                <sqljdbc.version>7.4.1.jre8</sqljdbc.version>
            </properties>

            <!-- From now on sqljdbc is default driver as jtds is outdated -->
            <dependencies>
                <dependency>
                    <groupId>com.microsoft.sqlserver</groupId>
                    <artifactId>mssql-jdbc</artifactId>
                    <version>${sqljdbc.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install node and yarn</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>yarn install</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>webpack</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>swagger-resolve</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <inherited>false</inherited>
                        <configuration>
                            <images>
                                <image>
                                    <name>${docker.image}</name>
                                    <run>
                                        <ports>
                                            <port>${db.port}:${db.port}</port>
                                        </ports>
                                        <env>
                                            <SA_PASSWORD>${db.password}</SA_PASSWORD>
                                            <ACCEPT_EULA>Y</ACCEPT_EULA>
                                            <MSSQL_PID>Express</MSSQL_PID>
                                        </env>
                                        <wait>
                                            <log>${docker.wait.log}</log>
                                            <time>120000</time>
                                        </wait>
                                        <log>
                                            <prefix>mssql</prefix>
                                        </log>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>com.microsoft.sqlserver</groupId>
                                <artifactId>mssql-jdbc</artifactId>
                                <version>${sqljdbc.version}</version>
                            </dependency>
                        </dependencies>

                        <configuration>
                            <username>${db.username}</username>
                            <password>${db.password}</password>
                            <url>${db.url.no.db}</url>
                            <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
                        </configuration>

                        <executions>
                            <execution>
                                <id>create-db</id>
                                <phase>pre-integration-test</phase>

                                <goals>
                                    <goal>execute</goal>
                                </goals>

                                <configuration>
                                    <autocommit>true</autocommit>
                                    <sqlCommand>
                                        CREATE DATABASE ${db.name};
                                        USE ${db.name};
                                        CREATE SCHEMA ${db.schema};
                                    </sqlCommand>
                                    <onError>abort</onError>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <jdbc.url>${db.url.no.db};databaseName=${db.name}</jdbc.url>
                                <jdbc.schema>${db.schema}</jdbc.schema>
                                <jdbc.user>${db.username}</jdbc.user>
                                <jdbc.password>${db.password}</jdbc.password>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>oracle</id>
            <properties>
                <oracle.docker.image>docker.atl-paas.net/buildeng/oracle11g</oracle.docker.image>
                <oracle.driver.version>19.3.0.0</oracle.driver.version>
                <oracle.artifactId>ojdbc8</oracle.artifactId>
                <oracle.jdbc.timezoneAsRegion>false</oracle.jdbc.timezoneAsRegion>
                <ao.test.database>oracle</ao.test.database>
                <db.url>jdbc:oracle:thin:@localhost:${db.port}:${db.sid}</db.url>
                <db.sid>orcl</db.sid>
                <db.username>ao_user</db.username>
                <db.password>ao_password</db.password>
                <docker.image>${oracle.docker.image}</docker.image>
                <docker.wait.log>(?s).*DATABASE IS READY TO USE.*</docker.wait.log>
                <docker.skip>false</docker.skip>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.oracle.ojdbc</groupId>
                    <artifactId>${oracle.artifactId}</artifactId>
                    <version>${oracle.driver.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install node and yarn</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>yarn install</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>webpack</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>swagger-resolve</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                            <images>
                                <image>
                                    <name>${docker.image}</name>
                                    <alias>oracle</alias>
                                    <run>
                                        <ports>
                                            <port>db.port:1521</port>
                                        </ports>
                                        <wait>
                                            <log>${docker.wait.log}</log>
                                            <time>1000000</time>
                                        </wait>
                                        <log>
                                            <prefix>oracle</prefix>
                                        </log>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>com.oracle.ojdbc</groupId>
                                <artifactId>${oracle.artifactId}</artifactId>
                                <version>${oracle.driver.version}</version>
                                <scope>runtime</scope>
                            </dependency>
                        </dependencies>

                        <configuration>
                            <username>SYS AS SYSDBA</username>
                            <password>oracle</password>
                            <url>${db.url}</url>
                            <driver>oracle.jdbc.OracleDriver</driver>
                        </configuration>

                        <executions>
                            <execution>
                                <id>create-db</id>
                                <phase>pre-integration-test</phase>

                                <goals>
                                    <goal>execute</goal>
                                </goals>

                                <configuration>
                                    <autocommit>true</autocommit>
                                    <sqlCommand>
                                        DROP USER ${db.username} CASCADE;
                                        CREATE USER ${db.username} IDENTIFIED BY ${db.password} DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS;
                                        GRANT ALL PRIVILEGES TO  ${db.username} WITH ADMIN OPTION;
                                        GRANT CONNECT TO  ${db.username};
                                    </sqlCommand>
                                    <onError>continue</onError>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <jdbc.url>${db.url}</jdbc.url>
                                <jdbc.schema>${db.username}</jdbc.schema>
                                <jdbc.user>${db.username}</jdbc.user>
                                <jdbc.password>${db.password}</jdbc.password>
                                <ao.transaction.isolation.level>TRANSACTION_READ_COMMITTED</ao.transaction.isolation.level>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
