<?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.1.1-rc1</version>
    </parent>

    <artifactId>stash-scm-git</artifactId>
    <packaging>atlassian-plugin</packaging>
    <name>Atlassian Stash Git SCM</name>
    <description>Provides support for the Git SCM</description>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>*.xml</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <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>
                        <Atlassian-Plugin-Key>${project.groupId}.${project.artifactId}</Atlassian-Plugin-Key>
                        <Bundle-SymbolicName>com.atlassian.stash.internal.scm.git</Bundle-SymbolicName>
                        <Import-Package>
                            com.atlassian.stash*,
                            com.atlassian.stash.help,
                            com.atlassian.stash.plugin.util,
                            com.atlassian.stash.throttle,
                            com.atlassian.stash.web.conditions,
                            com.atlassian.event.api,
                            com.atlassian.event.config,
                            com.atlassian.fugue,
                            com.atlassian.plugin,
                            com.atlassian.plugin.servlet,
                            com.atlassian.sal.api.lifecycle,
                            com.atlassian.sal.api.message,
                            com.atlassian.sal.api.pluginsettings,
                            com.atlassian.sal.api.transaction,
                            com.atlassian.sal.api.upgrade,
                            com.atlassian.sal.core.upgrade,
                            com.atlassian.soy.renderer,
                            com.atlassian.support.tools.spi,
                            com.atlassian.util.concurrent,
                            com.atlassian.util.profiling,
                            com.atlassian.utils.process,
                            com.google.common.base,
                            com.google.common.collect,
                            com.google.common.io,
                            javax.annotation,
                            javax.servlet;version="${servlet.api.osgi.version}",
                            javax.servlet.http;version="${servlet.api.osgi.version}",
                            org.apache.commons.collections;version="${commons.collections.libversion}",
                            org.apache.commons.io;version="${commons.io.libversion}",
                            org.apache.commons.io.input;version="${commons.io.libversion}",
                            org.apache.commons.lang;version="${commons.lang.libversion}",
                            org.slf4j;version="${slf4j.libversion}",
                            org.springframework.beans.factory;version="${spring.osgi.libversion}",
                            org.springframework.core;version="${spring.osgi.libversion}",
                            org.springframework.core.io;version="${spring.osgi.libversion}",
                        </Import-Package>
                        <Private-Package>
                            com.atlassian.stash.internal.scm.git*
                        </Private-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <attach>false</attach>
                            <descriptors>
                                <descriptor>src/main/assembly/scripts.xml</descriptor>
                            </descriptors>
                            <finalName>scripts</finalName>
                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeArtifactIds>git</excludeArtifactIds>
                            <excludeTransitive>true</excludeTransitive>
                            <includeScope>test</includeScope>
                            <includeTypes>zip</includeTypes>
                            <outputDirectory>${project.build.testOutputDirectory}/git</outputDirectory>
                            <stripVersion>true</stripVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <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-model</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-platform</artifactId>
            <scope>test</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-binary</artifactId>
        </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-scm-git-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-service-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-service-impl</artifactId>
            <scope>test</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.stash</groupId>
            <artifactId>stash-web-common</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.cache</groupId>
            <artifactId>atlassian-cache-memory</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>comment-drift</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>default-repository</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>mailmap</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>subrepositories</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>diff-tree</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>merge</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>garbage</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.stash.git</groupId>
            <artifactId>pull-requests</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.event</groupId>
            <artifactId>atlassian-event</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-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-core</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>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>commons-collections</groupId>
            <artifactId>commons-collections</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>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.stash</groupId>
            <artifactId>stash-branch-utils</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.scala.plugins</groupId>
            <artifactId>scala-${scala.version.base}-provider-plugin</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>de.schlichtherle.truezip</groupId>
            <artifactId>truezip-file</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>de.schlichtherle.truezip</groupId>
            <artifactId>truezip-driver-zip</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-text-patterns</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <!-- DO NOT USE THIS PROFILE UNDER ANY OS BUT WINDOWS.
             - The git packages contain Windows binaries and will not run on Linux or MacOS
             - Unpacking uses the exec-maven-plugin to run "7za", which is a Windows binary
             - There are probably other issues lurking as well

             This profile exists to support git version matrix testing on BEAC, but it may also be used by developers
             who run Windows. -->
        <profile>
            <id>git-windows</id>
            <activation>
                <property>
                    <name>msysgit.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <!-- Copy the msysgit distribution into the target directory. This is expected to be a
                                 "PortableGit" distribution packed using 7-zip compression. -->
                            <execution>
                                <id>copy-git</id>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <excludeTransitive>true</excludeTransitive>
                                    <includeArtifactIds>git</includeArtifactIds>
                                    <includeScope>test</includeScope>
                                    <includeTypes>${git.artifact.type}</includeTypes>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </configuration>
                            </execution>
                            <!-- Copy the 7za binary into the target directory. It will be used to unzip the
                                 "PortableGit" distribution copied above. -->
                            <execution>
                                <id>copy-7za</id>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <excludeTransitive>true</excludeTransitive>
                                    <includeArtifactIds>7za</includeArtifactIds>
                                    <includeScope>test</includeScope>
                                    <includeTypes>exe</includeTypes>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <stripVersion>true</stripVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Run 7za to unpack the "PortableGit" distribution into ${git.root}. As 7za is a Windows
                         executable, this will only work on Windows. -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unzip-git</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>
                                        <argument>x</argument>
                                        <argument>-o${git.root}</argument>
                                        <argument>${project.build.directory}/git-${msysgit.version}-${git.artifact.classifier}.${git.artifact.type}</argument>
                                    </arguments>
                                    <executable>${project.build.directory}/7za</executable>
                                    <outputFile>NUL</outputFile>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.stash.git</groupId>
                    <artifactId>git</artifactId>
                    <version>${msysgit.version}</version>
                    <classifier>${git.artifact.classifier}</classifier>
                    <type>${git.artifact.type}</type>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.7zip</groupId>
                    <artifactId>7za</artifactId>
                    <type>exe</type>
                    <version>9.20</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <properties>
                <git.artifact.classifier>windows</git.artifact.classifier>
                <git.artifact.type>7z</git.artifact.type>
                <git.root>${project.build.directory}/git-${msysgit.version}</git.root>
                <!-- Note that msysgit "PortableGit" does not have a /usr directory, so this is just /bin -->
                <git.bin>${git.root}/bin</git.bin>
                <!-- Pass the git.root and git.bin properties to the forked Java process used by Surefire to
                     execute the unit tests. This will trigger setup in LibraryAwareExternalProcessFactory,
                     to enable using the "PortableGit" distribution instead of the installed git. -->
                <surefire.git>-Dgit.root=${git.root} -Dplugin.stash-scm-git.path.executable=${git.bin}/git.exe</surefire.git>
                <surefire.argLine>${surefire.commonArgLine} ${surefire.git}</surefire.argLine>
            </properties>
        </profile>
    </profiles>
</project>
