<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.bamboo</groupId>
    <artifactId>atlassian-bamboo-plugins2-parent</artifactId>
    <version>6.10.3</version>
  </parent>

  <groupId>com.atlassian.bamboo.plugins.stash</groupId>
  <artifactId>atlassian-bamboo-plugin-stash</artifactId>
  <packaging>atlassian-plugin</packaging>

  <name>Atlassian Bamboo Stash Repository Plugin</name>
  <description>Stash Web Repository Viewer plugin for Bamboo</description>

  <properties>
    <bamboo.port>6990</bamboo.port>
    <bamboo.ajpPort>8009</bamboo.ajpPort>
    <stash.port>7990</stash.port>
    <stash-java-client.version>2.3.9</stash-java-client.version>
    <atlassian.plugin.key>com.atlassian.bamboo.plugins.stash.atlassian-bamboo-plugin-stash</atlassian.plugin.key>
    <data.directory>${project.basedir}/test-data</data.directory>
    <bitbucket.server.ajpPort>8010</bitbucket.server.ajpPort>
    <bitbucket.mirror.contextPath>/mirror</bitbucket.mirror.contextPath>
    <bitbucket.mirror.ajpPort>8011</bitbucket.mirror.ajpPort>
    <bitbucket.mirror.httpPort>7991</bitbucket.mirror.httpPort>
    <bitbucket.mirror.ssh.port>7998</bitbucket.mirror.ssh.port>
    <bitbucket.mirror.version>5.3.0</bitbucket.mirror.version>
    <bitbucket.upstream.contextPath>/bitbucket</bitbucket.upstream.contextPath>
    <bitbucket.upstream.ajpPort>${bitbucket.server.ajpPort}</bitbucket.upstream.ajpPort>
    <bitbucket.upstream.httpPort>7990</bitbucket.upstream.httpPort>
    <bitbucket.upstream.ssh.port>7999</bitbucket.upstream.ssh.port>
    <bitbucket.upstream.version>5.3.0</bitbucket.upstream.version>
    <bitbucketServerJvmArgs>-server</bitbucketServerJvmArgs>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.atlassian.plugin</groupId>
      <artifactId>atlassian-spring-scanner-annotation</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-web</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>bouncycastle</groupId>
          <artifactId>bcprov-jdk14</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.bouncycastle</groupId>
          <artifactId>bcprov-jdk15</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.bouncycastle</groupId>
          <artifactId>bcmail-jdk15</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.bouncycastle</groupId>
          <artifactId>bcprov-jdk16</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugins.rest</groupId>
      <artifactId>atlassian-rest-common</artifactId>
      <scope>provided</scope>
      <exclusions>
        <!-- this conflicts with org.ow2.asm:asm:jar:4.1 required by rest-assured in scope test -->
        <exclusion>
          <groupId>asm</groupId>
          <artifactId>asm</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo.plugins</groupId>
      <artifactId>atlassian-bamboo-plugin-git</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.stash</groupId>
      <artifactId>stash-java-client-api</artifactId>
      <version>${stash-java-client.version}</version>
      <exclusions>
        <exclusion>
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>jsr305</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.atlassian.stash</groupId>
      <artifactId>stash-java-client-applinks</artifactId>
      <version>${stash-java-client.version}</version>
      <exclusions>
        <exclusion>
          <groupId>com.atlassian.applinks</groupId>
          <artifactId>applinks-plugin</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugins</groupId>
      <artifactId>atlassian-remote-event-common-plugin</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.stash.plugins</groupId>
      <artifactId>stash-remote-event-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.applinks</groupId>
      <artifactId>applinks-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugins</groupId>
      <artifactId>atlassian-nav-links-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo.triggers</groupId>
      <artifactId>atlassian-bamboo-triggers</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.event</groupId>
      <artifactId>atlassian-event</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugins</groupId>
      <artifactId>atlassian-plugins-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.sal</groupId>
      <artifactId>sal-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.atlassian.util.concurrent</groupId>
      <artifactId>atlassian-util-concurrent</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <scope>provided</scope>
    </dependency>


    <!-- Test dependencies -->
    <dependency>
      <groupId>com.atlassian.applinks</groupId>
      <artifactId>applinks-func-test-rest-common</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.applinks</groupId>
      <artifactId>applinks-pageobjects</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-test-utils</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo.plugins</groupId>
      <artifactId>atlassian-bamboo-plugin-test-utils</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-pageobjects</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bitbucket.server</groupId>
      <artifactId>bitbucket-it-common</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bitbucket.server</groupId>
      <artifactId>bitbucket-page-objects</artifactId>
      <scope>test</scope>
    </dependency>
    <!--stash test utils requirement-->
    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>rest-assured</artifactId>
      <version>2.9.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>pl.pragmatists</groupId>
      <artifactId>JUnitParams</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.atlassian.plugin</groupId>
        <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>amps-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
            <!--
            Bundle-SymbolicName must match Atlassian-Plugin-Key until com.atlassian.bamboo.serialization.PluginResolver
            will be smarter
            -->
            <Bundle-SymbolicName>${atlassian.plugin.key}</Bundle-SymbolicName>
            <Spring-Context>*</Spring-Context>
            <Export-Package>
              com.atlassian.bamboo.plugins.stash.api,
              com.atlassian.bamboo.plugins.stash.analytics
            </Export-Package>
            <Import-Package>
              *;resolution:=optional
            </Import-Package>
          </instructions>

          <products>
            <!-- Bamboo -->
            <product>
              <id>bamboo</id>
              <instanceId>bamboo</instanceId>
              <version>${atlassian.product.version}</version>
              <httpPort>${bamboo.port}</httpPort>
              <output>${project.build.directory}/bamboo.log</output>
              <productDataPath>${data.directory}/amps/bamboo-plugin-stash/bamboo-test-resources-h2.zip</productDataPath>
              <containerId>${amps.containerId}</containerId>
              <ajpPort>${bamboo.ajpPort}</ajpPort>
              <pluginArtifacts>
                <pluginArtifact>
                  <groupId>com.atlassian.bamboo.plugins</groupId>
                  <artifactId>atlassian-bamboo-plugin-test-utils</artifactId>
                </pluginArtifact>
                <pluginArtifact>
                  <groupId>com.atlassian.applinks</groupId>
                  <artifactId>applinks-tests</artifactId>
                  <version>${apl.version}</version>
                </pluginArtifact>
              </pluginArtifacts>
              <systemPropertyVariables>
                <acceptanceTestSettings /> <!-- make sure BuildUtils.isFunctionalTest returns true -->
                <atlassian.darkfeature.bamboo.experimental.rest.admin.enabled>true</atlassian.darkfeature.bamboo.experimental.rest.admin.enabled>
                <atlassian.darkfeature.bamboo.improved.admin.panel.nav>true</atlassian.darkfeature.bamboo.improved.admin.panel.nav>
                <atlassian.profile.activate>true</atlassian.profile.activate>
                <hide.ported.legacy.repositories>true</hide.ported.legacy.repositories>
              </systemPropertyVariables>
              <jvmArgs>${bambooServerJvmArgs}</jvmArgs>
              <jvmDebugPort>5005</jvmDebugPort>
            </product>
            <!--Bamboo instance which use poling mode for branches/PR detection-->
            <product>
              <id>bamboo</id>
              <instanceId>bamboo-polling</instanceId>
              <version>${atlassian.product.version}</version>
              <httpPort>${bamboo.port}</httpPort>
              <output>${project.build.directory}/bamboo.log</output>
              <productDataPath>${data.directory}/amps/bamboo-plugin-stash/bamboo-test-resources-h2.zip</productDataPath>
              <containerId>${amps.containerId}</containerId>
              <ajpPort>${bamboo.ajpPort}</ajpPort>
              <pluginArtifacts>
                <pluginArtifact>
                  <groupId>com.atlassian.bamboo.plugins</groupId>
                  <artifactId>atlassian-bamboo-plugin-test-utils</artifactId>
                </pluginArtifact>
              </pluginArtifacts>
              <systemPropertyVariables>
                <atlassian.darkfeature.bamboo.experimental.rest.admin.enabled>true</atlassian.darkfeature.bamboo.experimental.rest.admin.enabled>
                <atlassian.darkfeature.bamboo.improved.admin.panel.nav>true</atlassian.darkfeature.bamboo.improved.admin.panel.nav>
                <atlassian.profile.activate>true</atlassian.profile.activate>
                <hide.ported.legacy.repositories>true</hide.ported.legacy.repositories>
                <hide.ported.legacy.repositories>true</hide.ported.legacy.repositories>
                <bamboo.stash.enforce.polling.branches>true</bamboo.stash.enforce.polling.branches>
                <!--skip BBS events handling and depend on polling mode only-->
                <bamboo.stash.enforce.pullrequest.polling.only>true</bamboo.stash.enforce.pullrequest.polling.only>
                <!--pull request cache TTL, default value is 60 seconds which makes test too slow-->
                <bamboo.pull.request.cache.ttl.seconds>5</bamboo.pull.request.cache.ttl.seconds>
                <bamboo.pull.request.polling.interval.seconds>20</bamboo.pull.request.polling.interval.seconds>
              </systemPropertyVariables>
              <jvmArgs>${bambooServerJvmArgs}</jvmArgs>
              <jvmDebugPort>5005</jvmDebugPort>
            </product>
            <!-- Bitbucket Server -->
            <product>
              <id>bitbucket</id>
              <instanceId>bitbucket</instanceId>
              <version>${bitbucket.server.version}</version>
              <productDataVersion>${bitbucket.server.version}</productDataVersion>
              <httpPort>${stash.port}</httpPort>
              <output>${project.build.directory}/bitbucket.log</output>
              <installPlugin>false</installPlugin>
              <ajpPort>${bitbucket.server.ajpPort}</ajpPort>
              <containerId>${amps.containerId}</containerId>
              <pluginArtifacts>
                <pluginArtifact>
                  <groupId>com.atlassian.applinks</groupId>
                  <artifactId>applinks-tests</artifactId>
                  <!--${apl.version} 5.2.6 doesn't supported by Bitbucket 4.1.0-->
                  <version>${apl.version}</version>
                </pluginArtifact>
              </pluginArtifacts>
              <systemPropertyVariables>
                <file.encoding>UTF-8</file.encoding>
                <atlassian.dev.mode>false</atlassian.dev.mode>
                <!-- Setting the test mode to true means that the right URL is passed into stash and the test does not rely on an external API -->
                <atlassian.test.mode>true</atlassian.test.mode>
                <!--Controls whether users with mismatching time zones are shown an alert prompting them to change their user time zone.-->
                <feature.user.time.zone.onboarding>false</feature.user.time.zone.onboarding>
                <!--Disables the display of the ref restriction splash screen so that func tests do not need to deal with this additional state-->
                <plugin.ref-restriction.feature.splash>false</plugin.ref-restriction.feature.splash>
                <!--Controls whether upgrading users (Stash -> Bitbucket) are redirected to an upgrade onboarding page after their first login.-->
                <feature.upgrade.onboarding.page>false</feature.upgrade.onboarding.page>
                <!--Controls whether new users are redirected to a getting started page after their first login.-->
                <feature.getting.started.page>false</feature.getting.started.page>
              </systemPropertyVariables>
              <jvmArgs>${bitbucketServerJvmArgs}</jvmArgs>
              <jvmDebugPort>5015</jvmDebugPort>
            </product>
            <product>
              <id>bitbucket</id>
              <instanceId>bitbucket-mirror</instanceId>
              <version>${bitbucket.mirror.version}</version>
              <contextPath>${bitbucket.mirror.contextPath}</contextPath>
              <productDataPath>${data.directory}/amps/bamboo-plugin-stash/bitbucket-mirror-home.zip</productDataPath>
              <httpPort>${bitbucket.mirror.httpPort}</httpPort>
              <ajpPort>${bitbucket.mirror.ajpPort}</ajpPort>
              <containerId>${amps.containerId}</containerId>
              <jvmDebugPort>5035</jvmDebugPort>
              <systemPropertyVariables>
                <file.encoding>UTF-8</file.encoding>
                <!-- pin the mirror's SSH server to port 7998 so it doesn't interfere with the upstream -->
                <plugin.ssh.port>${bitbucket.mirror.ssh.port}</plugin.ssh.port>
                <stash.test.smtp.port>9998</stash.test.smtp.port>
              </systemPropertyVariables>
            </product>
            <product>
              <id>bitbucket</id>
              <instanceId>bitbucket-upstream</instanceId>
              <version>${bitbucket.upstream.version}</version>
              <contextPath>${bitbucket.upstream.contextPath}</contextPath>
              <jvmDebugPort>5025</jvmDebugPort>
              <productDataPath>${data.directory}/amps/bamboo-plugin-stash/bitbucket-upstream-home.zip</productDataPath>
              <httpPort>${bitbucket.upstream.httpPort}</httpPort>
              <ajpPort>${bitbucket.upstream.ajpPort}</ajpPort>
              <containerId>${amps.containerId}</containerId>
              <systemPropertyVariables>
                <file.encoding>UTF-8</file.encoding>
                <stash.test.smtp.port>9990</stash.test.smtp.port>
                <plugin.connect.http.request.timeout>20</plugin.connect.http.request.timeout>
                <plugin.connect.http.connection.timeout>10</plugin.connect.http.connection.timeout>
                <plugin.connect.http.socket.timeout>10</plugin.connect.http.socket.timeout>
              </systemPropertyVariables>
            </product>

          </products>

          <systemPropertyVariables>
            <acceptance.test.data.directory>${data.directory}</acceptance.test.data.directory>
            <webdriver.firefox.logfile>${project.build.directory}/webdriverTmp/firefox.log</webdriver.firefox.logfile>
          </systemPropertyVariables>

          <testGroups>
            <!-- TODO: properly split Bitbucket Server integration tests into suites -->
            <!-- (current split only aims to speed up the tests so that each suite is executed under ~30 mins) -->
            <testGroup>
              <id>stash-integration-tests-part-1</id>
              <productIds>
                <productId>bamboo</productId>
                <productId>bitbucket</productId>
              </productIds>
              <includes>
                <include>it/com/atlassian/bamboo/plugins/stash/StashIntegrationTestPart1Harness.java</include>
              </includes>
            </testGroup>
            <testGroup>
              <id>stash-integration-tests-part-2</id>
              <productIds>
                <productId>bamboo</productId>
                <productId>bitbucket</productId>
              </productIds>
              <includes>
                <include>it/com/atlassian/bamboo/plugins/stash/StashIntegrationTestPart2Harness.java</include>
              </includes>
            </testGroup>
            <testGroup>
              <id>stash-integration-polling-mode</id>
              <productIds>
                <productId>bamboo-polling</productId>
                <productId>bitbucket</productId>
              </productIds>
              <includes>
                <include>it/com/atlassian/bamboo/plugins/stash/BitbucketServerPollingModeTestSuite.java</include>
              </includes>
            </testGroup>
            <testGroup>
              <id>bitbucket-mirror-integration-tests</id>
              <productIds>
                <productId>bamboo</productId>
                <productId>bitbucket-mirror</productId>
                <productId>bitbucket-upstream</productId>
              </productIds>
              <includes>
                <include>it/com/atlassian/bamboo/plugins/stash/StashIntegrationTestPart3MirrorsHarness.java</include>
              </includes>
            </testGroup>
            <testGroup>
              <id>stash-integration-tests-rss-part-1</id>
              <productIds>
                <productId>bamboo</productId>
                <productId>bitbucket</productId>
              </productIds>
              <includes>
                <include>it/com/atlassian/bamboo/plugins/stash/StashIntegrationTestRssPartOneHarness.java</include>
              </includes>
            </testGroup>
            <testGroup>
              <id>stash-integration-tests-rss-part-2</id>
              <productIds>
                <productId>bamboo</productId>
                <productId>bitbucket</productId>
              </productIds>
              <includes>
                <include>it/com/atlassian/bamboo/plugins/stash/StashIntegrationTestRssPartTwoHarness.java</include>
              </includes>
            </testGroup>
          </testGroups>
        </configuration>
      </plugin>

      <!-- This is to control dependencies that go into META-INF/lib with stash-java-client -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-bamboo-plugin-stash-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedDependencies>
                  <excludes>
                    <exclude>*:*:*:*:compile</exclude>
                  </excludes>
                  <includes>
                    <include>com.atlassian.stash:stash-java-client-api:${stash-java-client.version}</include>
                    <include>com.atlassian.stash:stash-java-client-applinks:${stash-java-client.version}</include>
                    <include>com.atlassian.stash:stash-java-client-core:${stash-java-client.version}</include>
                  </includes>
                </bannedDependencies>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
      <pluginManagement>
          <plugins>
              <plugin>
                  <groupId>com.atlassian.maven.plugins</groupId>
                  <artifactId>amps-dispatcher-maven-plugin</artifactId>
                  <version>${amps.version}</version>
              </plugin>
          </plugins>
      </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>release-profile</id>
      <properties>
        <skipTests>true</skipTests>
      </properties>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skip>true</skip>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>pluginDebugging</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>amps-maven-plugin</artifactId>
            <configuration>
              <systemPropertyVariables>
                <atlassian.disable.caches>true</atlassian.disable.caches>
                <atlassian.profile.activate>true</atlassian.profile.activate>
                <atlassian.webresource.disable.minification>true</atlassian.webresource.disable.minification>
                <bamboo.context.batching.disable>true</bamboo.context.batching.disable>
                <plugin.webresource.batching.off>true</plugin.webresource.batching.off>
              </systemPropertyVariables>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <argLine>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5025</argLine>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
