<?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.bitbucket.server</groupId>
        <artifactId>bitbucket-parent</artifactId>
        <version>9.4.7</version>
    </parent>

    <artifactId>bitbucket-plugins-parent</artifactId>
    <packaging>pom</packaging>

    <name>Bitbucket Server - Plugins Parent</name>

    <properties>
        <swagger.target>${project.build.directory}</swagger.target>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>check-dependencies-plugins</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <phase>validate</phase>
                            <configuration>
                                <rules>
                                    <bannedDependencies>
                                        <excludes>
                                            <exclude>com.google.collections:google-collections</exclude>
                                            <exclude>commons-logging:commons-logging:*:compile</exclude>
                                            <exclude>log4j:log4j</exclude>
                                            <exclude>quartz:quartz</exclude>
                                            <exclude>org.springframework:*:*:*:compile</exclude>
                                        </excludes>
                                        <message>Please check dependency:tree for banned dependencies</message>
                                        <searchTransitive>true</searchTransitive>
                                    </bannedDependencies>
                                </rules>
                                <fail>true</fail>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>normal-build</id>
            <activation>
                <property>
                    <name>!api-compat</name>
                </property>
            </activation>
            <modules>
                <module>access-tokens</module>
                <module>analytics-whitelist</module>
                <module>ao-common</module>
                <module>audit</module>
                <module>branch-api</module>
                <module>branch</module>
                <module>build</module>
                <module>build-bamboo</module>
                <module>build-jenkins</module>
                <module>bundled-hooks</module>
                <module>chaperone</module>
                <module>cluster-info</module>
                <module>code-insights-api</module>
                <module>code-insights-spi</module>
                <module>code-insights</module>
                <module>comment-likes-api</module>
                <module>comment-likes</module>
                <module>contributing-guidelines</module>
                <module>crowd-sso</module>
                <module>default-reviewers</module>
                <module>default-tasks</module>
                <module>embcwd-admin-spi-impl</module>
                <module>emoticons-api</module>
                <module>emoticons-spi</module>
                <module>emoticons</module>
                <module>filestore-s3</module>
                <module>frontend-support</module>
                <module>frontend</module>
                <module>git-lfs</module>
                <module>git-rest</module>
                <module>gpg-api</module>
                <module>gpg</module>
                <module>importer</module>
                <module>jira-api</module>
                <module>jira-commit-checker</module>
                <module>jira-development-integration</module>
                <module>jira</module>
                <module>mesh-support</module>
                <module>mirroring-common</module>
                <module>mirroring-mirror</module>
                <module>mirroring-upstream</module>
                <module>nav-links</module>
                <module>notification</module>
                <module>plugin-extender</module>
                <module>plugin-information-provider</module>
                <module>policies</module>
                <module>pull-request-cleanup</module>
                <module>ref-restriction-api</module>
                <module>ref-restriction-spi</module>
                <module>ref-restriction</module>
                <module>repository-ref-sync-api</module>
                <module>repository-ref-sync</module>
                <module>repository-shortcuts</module>
                <module>rest-ui</module>
                <module>rest-v2</module>
                <module>rest-v2-api</module>
                <module>rest-v2-model</module>
                <module>rest-v2-spi</module>
                <module>rest</module>
                <module>sal</module>
                <module>search-api</module>
                <module>search</module>
                <module>sourcetree</module>
                <module>ssh-api</module>
                <module>ssh</module>
                <module>suggest-reviewers</module>
                <module>suggest-reviewers-api</module>
                <module>suggest-reviewers-spi</module>
                <module>tag</module>
                <module>upm-accessor</module>
                <module>velocity-helper</module>
                <module>webhooks-api</module>
                <module>webhooks</module>
                <module>xcode</module>
                <module>bundled-plugins</module>
            </modules>
        </profile>
        <!-- To activate this profile, use -Dapi-compat. Otherwise, it will include all the modules rather than just
             the ones that we want to check. Alternatively you can use -Papi-compat,\!normal-build to achieve the same
             thing -->
        <profile>
            <id>api-compat</id>
            <activation>
                <property>
                    <name>api-compat</name>
                </property>
            </activation>
            <modules>
                <module>ao-common</module>
                <module>branch-api</module>
                <module>comment-likes-api</module>
                <module>code-insights-api</module>
                <module>code-insights-spi</module>
                <module>crowd-sso</module>
                <module>emoticons-api</module>
                <module>emoticons-spi</module>
                <module>gpg-api</module>
                <module>jira-api</module>
                <module>ref-restriction-api</module>
                <module>ref-restriction-spi</module>
                <module>repository-ref-sync-api</module>
                <module>rest-v2-api</module>
                <module>rest-v2-spi</module>
                <module>search-api</module>
                <module>ssh-api</module>
                <module>suggest-reviewers-api</module>
                <module>suggest-reviewers-spi</module>
                <module>webhooks-api</module>
            </modules>
        </profile>
        <!-- This profile supports executing DAO tests for plugins against a real database by providing database-specific
             configuration for all plugins when the real-database profile is activated.

             By default, all of the ActiveObjects tests use an in-memory H2 database to run. During development,
             this is likely to be sufficient. However, to ensure our bundled plugins run correctly on all of our
             supported databases, it is beneficial to run our tests against them. Running the tests will verify that:
             - Our usage of ActiveObjects is consistent cross database
             - ActiveObjects schema creation works

             net.java.ao.test.jdbc.DatabaseUpdater is used to populate data for these tests.

             For real database testing within core, please look at dao-impl/pom.xml

             Unfortunately, Maven only allows a single property when configuring activation. However, correct execution
             of this profile requires that the following properties _all_ be defined:
             - jdbc.password
             - jdbc.url
             - jdbc.user
             The presence of jdbc.url activates the profile, so you do not need to use -Preal-database. For example, to
             run the unit tests against Postgres, you could run the following from the dao-impl directory:
             > mvn clean install -o -Djdbc.url=jdbc:postgresql://localhost:5432/bitbucket \
             >     -Djdbc.user=bitbucket -Djdbc.password=someCoolPassword
             For simplicity, you should probably avoid exotic characters in your password and other properties; it has
             not been tested how they might affect Surefire's execution.

             This profile should be safe for use by developers if they wish to perform testing against a specific
             database, perhaps in response to a failed build. -->
        <profile>
            <id>real-database</id>
            <activation>
                <property>
                    <name>jdbc.url</name>
                </property>
            </activation>
            <properties>
                <failIfNoTests>false</failIfNoTests>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <groups>com.atlassian.bitbucket.ao.AbstractAoDaoTest</groups>
                            <systemProperties>
                                <!--
                                The application uses READ_COMMITTED isolation level on every database when it runs.
                                Using READ_COMMITTED for AO tests means we are testing the same isolation used at
                                runtime.

                                Additionally, this is required for running tests against Oracle databases (>=12c R2).
                                The AO default transaction isolation level SERIALIZABLE causes some AO tests to fail
                                with "ORA-08177: can't serialize access for this transaction".
                                -->
                                <ao.transaction.isolation.level>TRANSACTION_READ_COMMITTED</ao.transaction.isolation.level>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <!-- required so that we can target classes extending AbstractAoDaoTest -->
                <dependency>
                    <groupId>com.atlassian.bitbucket.server</groupId>
                    <artifactId>bitbucket-test-util</artifactId>
                    <scope>test</scope>
                </dependency>
                <!-- The drivers below are test scope for executing the AO tests against all supported DBs -->
                <!-- Do NOT change the scope, as these jars should not be part of the plugin -->
                <dependency>
                    <groupId>com.microsoft.sqlserver</groupId>
                    <artifactId>mssql-jdbc</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>com.oracle.database.jdbc</groupId>
                    <artifactId>ojdbc11</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.hsqldb</groupId>
                    <artifactId>hsqldb</artifactId>
                    <classifier>jdk8</classifier>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>release</id>
        </profile>
    </profiles>
</project>
