<?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>bitbucket-distribution-parent</artifactId>
    <groupId>com.atlassian.bitbucket.server</groupId>
    <version>4.9.0-bervdev-13398-5</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>bitbucket-installer</artifactId>
  <name>Bitbucket Server - Installer</name>
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <finalName>bitbucket-installer</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-atlassian-keystore</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.atlassian.keystore</groupId>
                  <artifactId>atlassian-keystore</artifactId>
                  <outputDirectory>${keystore.location}</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <execution>
            <id>unpack-distribution</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeArtifactIds>bitbucket-distribution</includeArtifactIds>
              <outputDirectory>${project.build.directory}/standalone</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <artifactSet>
            <includes>
              <include>com.atlassian.bitbucket.server:bitbucket-api</include>
              <include>com.atlassian.bitbucket.server:bitbucket-git-binary</include>
              <include>com.atlassian.bitbucket.server:bitbucket-platform</include>
              <include>com.atlassian.bitbucket.server:bitbucket-scm-common</include>
              <include>com.atlassian.bitbucket.server:bitbucket-spi</include>
              <include>com.atlassian.utils:atlassian-processutils</include>
              <include>com.atlassian.inception:inception</include>
              <include>commons-io:commons-io</include>
              <include>commons-lang:commons-lang</include>
              <include>org.apache.commons:commons-lang3</include>
              <include>commons-logging:commons-logging</include>
              <include>com.atlassian.fugue:fugue</include>
              <include>com.google.guava:guava</include>
              <include>org.apache.httpcomponents:httpclient</include>
              <include>org.apache.httpcomponents:httpcore</include>
              <incldue>joda-time:joda-time</incldue>
              <include>org.slf4j:log4j-over-slf4j</include>
              <include>ch.qos.logback:logback-classic</include>
              <include>ch.qos.logback:logback-core</include>
              <include>org.slf4j:slf4j-api</include>
            </includes>
          </artifactSet>
          <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>replace</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <file>${project.build.resources[0].directory}/bitbucket-template.install4j</file>
          <outputFile>${project.build.outputDirectory}/bitbucket.install4j</outputFile>
          <replacements>
            <replacement>
              <token>macEnabled="(true|false)"</token>
              <value>macEnabled="${sign.installer}"</value>
            </replacement>
            <replacement>
              <token>windowsEnabled="(true|false)"</token>
              <value>windowsEnabled="${sign.installer}"</value>
            </replacement>
            <replacement>
              <token>&lt;archive location="./target/</token>
              <value>&lt;archive location="./</value>
            </replacement>
            <replacement>
              <token>&lt;resource location="./target/</token>
              <value>&lt;resource location="./</value>
            </replacement>
          </replacements>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.sonatype.install4j</groupId>
        <artifactId>install4j-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>compile-installers</id>
            <phase>package</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <home>${install4j.home}</home>
              <projectFile>${project.build.outputDirectory}/bitbucket.install4j</projectFile>
              <mediaTypes>${install4j.mediaTypes}</mediaTypes>
              <release>${project.version}</release>
              <winKeystorePassword>${windows.keystore.password}</winKeystorePassword>
              <macKeystorePassword>${mac.keystore.password}</macKeystorePassword>
              <variables>
                <app.compiler.classpath>${project.build.directory}/bitbucket-installer.jar</app.compiler.classpath>
                <app.distribution.path>${project.build.directory}/standalone/atlassian-bitbucket-${project.version}</app.distribution.path>
                <app.edition>Enterprise</app.edition>
                <app.edition_filename>enterprise</app.edition_filename>
                <app.shortName>${product.name}</app.shortName>
                <app.version>${project.version}</app.version>
                <docs.version>${docs.version}</docs.version>
                <keystore.home>${keystore.location}/keystore/secure</keystore.home>
                <output.directory>${project.build.directory}/media</output.directory>
              </variables>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>set-file-permissions</id>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <chmod />
              </tasks>
            </configuration>
          </execution>
          <execution>
            <id>install4j</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <move />
                <chmod />
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-installer</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/media/atlassian-bitbucket-${project.version}-windows-x64.exe</file>
                  <type>exe</type>
                  <classifier>x64</classifier>
                </artifact>
                <artifact>
                  <file>${project.build.directory}/media/atlassian-bitbucket-${project.version}-linux-x64.bin</file>
                  <type>bin</type>
                  <classifier>x64</classifier>
                </artifact>
                <artifact>
                  <file>${project.build.directory}/media/atlassian-bitbucket-${project.version}-macos.dmg</file>
                  <type>dmg</type>
                  <classifier>x64</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>com.install4j</groupId>
      <artifactId>i4jruntime</artifactId>
      <version>6.0.4</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bitbucket.server</groupId>
      <artifactId>bitbucket-distribution</artifactId>
      <version>4.9.0-bervdev-13398-5</version>
      <type>zip</type>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>elasticsearch</artifactId>
          <groupId>org.elasticsearch.distribution.zip</groupId>
        </exclusion>
        <exclusion>
          <artifactId>buckler-plugin</artifactId>
          <groupId>com.atlassian.elasticsearch</groupId>
        </exclusion>
        <exclusion>
          <artifactId>bitbucket-distribution-common</artifactId>
          <groupId>com.atlassian.bitbucket.server</groupId>
        </exclusion>
        <exclusion>
          <artifactId>bitbucket-distribution-licenses</artifactId>
          <groupId>com.atlassian.bitbucket.server</groupId>
        </exclusion>
        <exclusion>
          <artifactId>bitbucket-tomcat-bootstrap</artifactId>
          <groupId>com.atlassian.bitbucket.server</groupId>
        </exclusion>
        <exclusion>
          <artifactId>bitbucket-webapp</artifactId>
          <groupId>com.atlassian.bitbucket.server</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>hamcrest-core</artifactId>
          <groupId>org.hamcrest</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>1.10.19</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>objenesis</artifactId>
          <groupId>org.objenesis</groupId>
        </exclusion>
        <exclusion>
          <artifactId>hamcrest-core</artifactId>
          <groupId>org.hamcrest</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
  <properties>
    <install4j.mediaTypes>windows,unixInstaller,macosFolder</install4j.mediaTypes>
    <install4j.home>INSTALL4J_HOME</install4j.home>
    <sign.installer>true</sign.installer>
    <keystore.location>${project.build.directory}/atlassian-keystore</keystore.location>
    <product.name>Bitbucket</product.name>
  </properties>
</project>

