<?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>com.atlassian.jira.plugins</groupId>
        <artifactId>jira-greenhopper-parent-pom</artifactId>
        <version>7.8.0-DAILY20180111023548</version>
    </parent>

    <artifactId>greenhopper-dbprovide</artifactId>
    <packaging>pom</packaging>

    <name>JIRA Agile Database provide</name>
    <description>Database provide configuration for JIRA Agile</description>

    <properties>
        <datasource.hostname>localhost</datasource.hostname>
        <datasource.username>jirauser2</datasource.username>
        <datasource.password>jirauser2</datasource.password>

        <db.type>postgres</db.type>
        <db.dump />
        <db.dumpLogsOnError>ALL</db.dumpLogsOnError>
        <jiradb.settingsFile>${project.build.directory}/boxdb.properties</jiradb.settingsFile>
        <jiradb.performChildModuleCheck>false</jiradb.performChildModuleCheck>
    </properties>

    <profiles>
        <profile>
            <id>dbprovide</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>jiradb-maven-plugin</artifactId>
                        <version>${jiradb.version}</version>
                        <executions>
                            <execution>
                                <id>prepare-db</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>dbstop</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>jiradb-maven-plugin</artifactId>
                        <version>${jiradb.version}</version>
                        <executions>
                            <execution>
                                <id>clean-db</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>clean</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jira-postgres</id>
            <activation>
                <property>
                    <name>tpm.postgres</name>
                </property>
            </activation>
            <properties>
                <db.type>postgres</db.type>
                <db.version>${tpm.postgres}</db.version>
            </properties>
        </profile>

        <profile>
            <id>jira-oracle</id>
            <activation>
                <property>
                    <name>tpm.oracle</name>
                </property>
            </activation>
            <properties>
                <db.user>${datasource.username}</db.user>
                <db.password>${datasource.password}</db.password>

                <db.type>oracle</db.type>
                <db.version>${tpm.oracle}</db.version>
                <db.dump>${project.basedir}/src/main/resources/jira_70_oracle_11g_dump.dmp</db.dump>
                <db.initialize>false</db.initialize>
                <oracle.dbca.total.memory>2048</oracle.dbca.total.memory>
                <boxdb.startupTimeout>3600</boxdb.startupTimeout>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>au.net.causal.maven.plugins</groupId>
                            <artifactId>boxdb-maven-plugin</artifactId>
                            <configuration>
                                <box>
                                    <scriptExecutions>
                                        <scriptExecution>
                                            <directory>${project.basedir}/src/main/resources/scripts</directory>
                                            <stage>CREATE</stage>
                                            <scripts>
                                                <script>create-oracle.sql</script>
                                            </scripts>
                                        </scriptExecution>
                                    </scriptExecutions>
                                </box>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <id>jira-mysql</id>
            <activation>
                <property>
                    <name>tpm.mysql</name>
                </property>
            </activation>
            <properties>
                <db.type>mysql</db.type>
                <db.version>${tpm.mysql}</db.version>
            </properties>
        </profile>
    </profiles>

</project>
