<?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">
    <parent>
        <artifactId>stash-plugins-parent</artifactId>
        <groupId>com.atlassian.stash</groupId>
        <version>3.2.0-m5</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>stash-branch-utils</artifactId>

    <organization>
        <name>Atlassian</name>
        <url>http://www.atlassian.com/</url>
    </organization>

    <name>Atlassian Stash Branch Utilities Plugin</name>
    <description>Workflows support in Stash. Branch categories, branch creation, checkout branch</description>
    <packaging>atlassian-plugin</packaging>

    <dependencies>

        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-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-util</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-ao-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-jira-integration</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-branch-permissions</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-doclet</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.annotations</groupId>
            <artifactId>atlassian-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.integration.jira</groupId>
            <artifactId>jira-integration-plugin</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.scala.plugins</groupId>
            <artifactId>scala-${scala.version.base}-provider-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.jsuereth</groupId>
            <artifactId>scala-arm_${scala.version.base}</artifactId>
            <version>1.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.scala-lang</groupId>
                    <artifactId>scala-library</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</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>org.specs2</groupId>
            <artifactId>specs2_${scala.version.base}</artifactId>
            <version>2.2.3</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.scala-lang</groupId>
                    <artifactId>scala-library</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-test-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- We have to disable clover for Scala, but need the libs to run the tests against other Stash libs -->
        <dependency>
            <groupId>com.cenqua.clover</groupId>
            <artifactId>clover</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-dev-summary-dao-test</artifactId>
            <version>${dev.summary.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <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>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/Test*.java</include>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-stash-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <products>
                        <product>
                            <id>stash</id>
                            <instanceId>stash</instanceId>
                            <version>${project.version}</version>
                            <dataVersion>${project.version}</dataVersion>
                        </product>
                    </products>
                    <instructions>
                        <Export-Package>
                            com.atlassian.stash.branch.*,
                            com.atlassian.stash.branch.automerge.*,
                            com.atlassian.stash.branch.model.*
                        </Export-Package>
                        <Import-Package>
                            scala.*;version="[2.10,2.11)",
                            *
                        </Import-Package>
                        <Private-Package>
                            com.atlassian.stash.internal.branch*
                        </Private-Package>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <!--
                    http://stackoverflow.com/questions/336144/building-a-scala-app-with-maven-that-has-java-source-mixed-in
                -->
                <executions>
                    <execution>
                        <id>compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <phase>compile</phase>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                        <phase>test-compile</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-clover2-plugin</artifactId>
                <configuration>
                    <!-- Scala doesn't work with clover :( -->
                    <skip>true</skip>
                </configuration>
            </plugin>
            <!--
                We just need a 'container' plugin that is already part of the DAO test matrix for this to build.
                Longer term we could/should have a single plugin that does this for all our plugins, which would
                simplify the plan template (and remove the magic profile duplication below)
            -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.atlassian.stash</groupId>
                                    <artifactId>stash-dev-summary-dao-test</artifactId>
                                    <version>${dev.summary.version}</version>
                                    <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <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.branch</excludePackageNames>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.sun.jersey.contribs</groupId>
                        <artifactId>maven-wadl-plugin</artifactId>
                        <configuration>
                            <wadlFile>${project.build.directory}/stash-branch-utils-rest.wadl</wadlFile>
                            <packagesResourceConfig>
                                <param>com.atlassian.stash.internal.branch.rest</param>
                                <param>com.atlassian.stash.internal.branch.model.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-branch-utils-rest.html ${project.basedir}/../${wadl-transform-xsl} ${project.build.directory}/stash-branch-utils-rest.wadl</commandlineArgs>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
