<?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.stash</groupId>
        <artifactId>stash-plugins-parent</artifactId>
        <version>3.11.0</version>
    </parent>

    <artifactId>stash-ssh</artifactId>
    <packaging>atlassian-plugin</packaging>
    <name>Atlassian Stash SSH Plugin</name>
    <description>SSH support for Stash</description>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-stash-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Atlassian-Plugin-Key>com.atlassian.stash.ssh-plugin</Atlassian-Plugin-Key>
                        <Export-Package>com.atlassian.stash.ssh.api</Export-Package>
                        <Private-Package>com.atlassian.stash.internal*</Private-Package>
                        <!--required because of https://issues.apache.org/jira/browse/IO-350-->
                        <Import-Package>
                            com.atlassian.stash*,
                            com.atlassian.activeobjects.*,
                            com.atlassian.cache*,
                            com.atlassian.event*,
                            com.atlassian.johnson*,
                            com.atlassian.plugin*,
                            com.atlassian.sal.api*,
                            com.atlassian.soy.renderer,
                            com.atlassian.support.tools.spi*,
                            com.atlassian.util.concurrent,
                            com.atlassian.webresource.api*,
                            com.google.common.*,
                            javax.annotation,
                            javax.annotation.concurrent,
                            javax.crypto*,
                            javax.security*,
                            javax.servlet*;version="${servlet.api.osgi.version}",
                            javax.validation*,
                            javax.ws.rs*,
                            net.java.ao*,
                            org.apache.commons.codec*,
                            org.apache.commons.io*;version="${commons.io.libversion}",
                            org.apache.commons.lang;version="${commons.lang.libversion}",
                            org.bouncycastle*,
                            org.codehaus.jackson*,
                            org.hibernate.validator.constraints,
                            org.slf4j;version="${slf4j.libversion}",
                            org.springframework*;version="${spring.osgi.libversion}",
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.lesscss</groupId>
                <artifactId>lesscss-maven-plugin</artifactId>
                <configuration>
                    <webstatic>../../webapp/default/src/main/webapp</webstatic>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.sf.alchim</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <!-- bundled dependencies:
          Mina SSHD + Mina Core + BouncyCastle -->

        <dependency>
            <groupId>org.apache.sshd</groupId>
            <artifactId>sshd-core</artifactId>
        </dependency>
        <!-- Marked as an optional dependency in sshd-core -->
        <dependency>
            <groupId>org.apache.mina</groupId>
            <artifactId>mina-core</artifactId>
        </dependency>

        <!-- WARNING: There is a check for BC on startup that is affected by changing the scope of these dependencies -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpg-jdk15on</artifactId>
            <version>${bouncycastle.libversion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk15on</artifactId>
            <version>${bouncycastle.libversion}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Stash API/SPI -->

        <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-plugin-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-scm-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-service-api</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aop</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context-support</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-expression</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-jdbc</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-tx</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
            </exclusions>
        </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>

        <!-- Spring (2.5, provided by the plugin system) -->

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.osgi.libversion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.osgi.libversion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.osgi.libversion}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Atlassian's (ActiveObjects, SAL, etc. provided by the plugin system) -->

        <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.cache</groupId>
            <artifactId>atlassian-cache-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.templaterenderer</groupId>
            <artifactId>atlassian-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.util.concurrent</groupId>
            <artifactId>atlassian-util-concurrent</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.utils</groupId>
            <artifactId>atlassian-processutils</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-core</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.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webfragment</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</groupId>
            <artifactId>atlassian-plugins-webresource-common</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.johnson</groupId>
            <artifactId>atlassian-johnson-core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.support</groupId>
            <artifactId>stp-spi</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- others (provided by the plugin system) -->

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

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</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>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-test-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>opensymphony</groupId>
            <artifactId>oscore</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>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <!-- Needed for javadoc generation (extract the doclava theme) -->
                        <artifactId>maven-dependency-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <!-- Needed for wadl generation -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                            <excludePackageNames>com.atlassian.stash.ssh.soy:com.atlassian.stash.ssh.utils:com.atlassian.stash.ssh.validation:com.atlassian.stash.internal.key:com.atlassian.stash.internal.ssh</excludePackageNames>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.sun.jersey.contribs</groupId>
                        <artifactId>maven-wadl-plugin</artifactId>
                        <configuration>
                            <wadlFile>${project.build.directory}/stash-ssh-rest.wadl</wadlFile>
                            <packagesResourceConfig>
                                <param>com.atlassian.stash.internal.ssh.rest</param>
                                <param>com.atlassian.stash.internal.key.ssh.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-ssh-rest.html ${project.basedir}/../${wadl-transform-xsl} ${project.build.directory}/stash-ssh-rest.wadl</commandlineArgs>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <release.javadoc.additional.params>${release.javadoc.common.plugin.params}</release.javadoc.additional.params>
            </properties>
        </profile>
    </profiles>
</project>
