<?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>
        <artifactId>stash-plugins-parent</artifactId>
        <groupId>com.atlassian.stash</groupId>
        <version>2.7.0-rc4</version>
    </parent>

    <artifactId>stash-repository-ref-sync</artifactId>
    <description>Adds support for ref synchronization between forks and their upstream repositories</description>
    <name>Atlassian Stash Repository Ref Synchronizer</name>
    <packaging>atlassian-plugin</packaging>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>*.xml</include>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>*.xml</exclude>
                    <exclude>**/*.xml</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-stash-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>
                            com.atlassian.stash.repository.sync,
                            com.atlassian.stash.repository.sync.conditions
                        </Export-Package>
                        <Import-Package>
                            com.atlassian.stash*,
                            com.atlassian.activeobjects.external,
                            com.atlassian.event.api,
                            com.atlassian.plugin.servlet*,
                            com.atlassian.plugin.web,
                            com.atlassian.plugins.rest*,
                            com.atlassian.sal.api*,
                            com.atlassian.soy.renderer,
                            com.atlassian.support.tools.spi,
                            com.atlassian.util.concurrent,
                            com.atlassian.util.profiling,
                            com.atlassian.utils.process,
                            com.google.common.*,
                            javax.annotation,
                            javax.servlet*;version="${servlet.api.osgi.version}",
                            javax.ws.rs*,
                            net.java.ao*,
                            org.apache.commons.lang;version="${commons.lang.libversion}",
                            org.codehaus.jackson*,
                            org.slf4j;version="${slf4j.libversion}",
                        </Import-Package>
                        <Private-Package>
                            com.atlassian.stash.internal.repository.sync*
                        </Private-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-ao-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-branch-permissions</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-rest-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-scm-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-scm-git-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-spi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-test-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-util</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.fugue</groupId>
            <artifactId>fugue</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-module</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.profiling</groupId>
            <artifactId>atlassian-profiling</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.support</groupId>
            <artifactId>stp-spi</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <!-- This profile supports executing the plugin DAO tests against a real database. Currently it is copied to
             each AO backed plugin as required.

             By default, all of the ActiveObjects tests use an in-memory HSQL database to run. During development, this is
             likely to be sufficient. However, to ensure Stash's bundled plugins runs 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 MySQL, you could run the following from the dao-impl directory:
             > mvn clean install -o -Djdbc.url=jdbc:mysql://localhost:3306/stash \
             >     -Djdbc.user=stash -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>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>maven-stash-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <systemPropertyVariables>
                                <jdbc.url>${jdbc.url}</jdbc.url>
                                <jdbc.user>${jdbc.user}</jdbc.user>
                                <jdbc.password>${jdbc.password}</jdbc.password>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/*Dao*Test*.java</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <!-- 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>sqljdbc</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc6</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <!-- Needed for wadl generation -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                            <excludePackageNames>com.atlassian.stash.internal</excludePackageNames>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.sun.jersey.contribs</groupId>
                        <artifactId>maven-wadl-plugin</artifactId>
                        <configuration>
                            <wadlFile>${project.build.directory}/stash-repository-ref-sync-rest.wadl</wadlFile>
                            <packagesResourceConfig>
                                <param>com.atlassian.stash.internal.repository.sync.rest</param>
                            </packagesResourceConfig>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>exec-xsltproc</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <executable>xsltproc</executable>
                                    <commandlineArgs>-o ${project.build.directory}/stash-repository-ref-sync-rest.html ${project.basedir}/../${wadl-transform-xsl} ${project.build.directory}/stash-repository-ref-sync-rest.wadl</commandlineArgs>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
