<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>stash-plugins-parent</artifactId>
        <groupId>com.atlassian.stash</groupId>
        <version>3.10.0</version>
    </parent>

    <artifactId>stash-scala-plugins-parent</artifactId>
    <packaging>pom</packaging>
    <name>Atlassian Stash Scala Plugins Parent</name>

    <modules>
        <module>branch-utils</module>
    </modules>

    <profiles>
        <profile>
            <!-- Even though the scala code won't be instrumented, we'll still need clover on the classpath -->
            <id>clover</id>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.clover</groupId>
                    <artifactId>clover</artifactId>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <scope>provided</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>

        <!-- We have to disable clover for Scala, but need the libs to run the tests against other Stash libs -->
        <dependency>
            <groupId>com.atlassian.clover</groupId>
            <artifactId>clover</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>maven-stash-plugin</artifactId>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>

        <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>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <!--
                10-20 seconds of savings in turning off the maven java compiler and instead using the scala invoked one
                -->
                <executions>
                    <execution><id>default-compile</id><phase>none</phase></execution>
                    <execution><id>compile</id><phase>none</phase></execution>
                    <execution><id>default-testCompile</id><phase>none</phase></execution>
                    <execution><id>unit-test-compile</id><phase>none</phase></execution>
                </executions>
            </plugin>
            <plugin>
                <!--
                   Plugin configuration copied from ServiceDesk's 2.0.2 pom

                   See http://davidb.github.io/scala-maven-plugin/index.html for full details for config options
                -->
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <args>
                        <!-- to avoid 'error: File name too long' in Linux/ecryptfs file system -->
                        <arg>-Xmax-classfile-name</arg>
                        <arg>143</arg>
                        <arg>-unchecked</arg>
                        <arg>-deprecation</arg>
                        <!--<arg>-explaintypes</arg>-->
                        <arg>-feature</arg>
                        <arg>-language:_</arg>
                        <arg>-target:jvm-1.7</arg>
                    </args>
                    <!--
                        we don't want the scala compiler to go into GC catalepsy,
                        it's slow enough as it is. running in-process causes classpath problems.

                        Taken from Soke POM scala config
                    -->
                    <jvmArgs>
                        <param>-server</param>
                        <!--grabbing memory up front saves us 2 seconds-->
                        <param>-Xms1024M</param>
                        <param>-Xmx1024M</param>
                        <param>-XX:+UseParallelOldGC</param>
                    </jvmArgs>

                    <!-- Seems to really increase compile speed.  A lot!!! -->
                    <recompileMode>incremental</recompileMode>
                    <useZincServer>true</useZincServer>
                    <javacArgs>
                        <javacArg>-source</javacArg>
                        <javacArg>${jdkLevel}</javacArg>
                        <javacArg>-target</javacArg>
                        <javacArg>${jdkLevel}</javacArg>
                        <javacArg>-Xlint:unchecked</javacArg>
                        <javacArg>-Xlint:deprecation</javacArg>
                    </javacArgs>
                </configuration>
            </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>
        </plugins>
    </build>
</project>
