<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (C) 2010 FuseSource, Corp. All rights reserved.
    http://fusesource.com

    The software in this package is published under the terms of the AGPL license
    a copy of which has been included with this distribution in the license.txt file.

-->
<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.fusesource.fmc</groupId>
    <artifactId>fmc-project</artifactId>
    <version>0.9.8-beta</version>
    <relativePath>..</relativePath>
  </parent>

  <artifactId>fmc-scala</artifactId>
  <packaging>pom</packaging>

  <name>${project.artifactId}</name>
  <description>Holds the common Maven settings for Scala based modules.</description>
  
 <dependencies>

    <!-- Scala Support: this needs to be copied into every scala project -->
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <scope>compile</scope>
      <version>${scala-version}</version>
    </dependency>

  </dependencies>
  
  <build>
  
    <defaultGoal>install</defaultGoal>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/scala</testSourceDirectory>

    <resources>
      <resource>
        <directory>target/schema</directory>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*</include>
        </includes>
        <filtering>true</filtering>
      </resource>
    </resources>
      
    <plugins>

      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <version>${scala-plugin-version}</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <args>
                <arg>-deprecation</arg>
                <arg>-P:continuations:enable</arg>
              </args>
              <compilerPlugins>
                <compilerPlugin>
                  <groupId>org.scala-lang.plugins</groupId>
                  <artifactId>continuations</artifactId>
                  <version>${scala-version}</version>
                </compilerPlugin>
                <compilerPlugin>
                  <groupId>org.fusesource.jvmassert</groupId>
                  <artifactId>jvmassert</artifactId>
                  <version>1.1</version>
                </compilerPlugin>
              </compilerPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <jvmArgs>
            <jvmArg>-Xmx1024m</jvmArg>
            <jvmArg>-Xss8m</jvmArg>
          </jvmArgs>
          <scalaVersion>${scala-version}</scalaVersion>
        </configuration>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>

        <configuration>
          <!-- we must turn off the use of system class loader so our tests can find stuff - otherwise ScalaSupport compiler can't find stuff -->
          <useSystemClassLoader>false</useSystemClassLoader>
          <!--forkMode>pertest</forkMode-->
          <childDelegation>false</childDelegation>
          <useFile>true</useFile>
          <failIfNoTests>false</failIfNoTests>
        </configuration>
      </plugin>

    </plugins>
  </build>


  <profiles>

    <!-- helper for the IDEA scala integration, enable this profile in IDEA -->
    <profile>
      <id>idea</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>${scala-plugin-version}</version>
            <configuration>
              <args>
                <arg>-deprecation</arg>
                <arg>-P:continuations:enable</arg>
              </args>
              <compilerPlugins>
                <compilerPlugin>
                  <groupId>org.scala-lang.plugins</groupId>
                  <artifactId>continuations</artifactId>
                  <version>${scala-version}</version>
                </compilerPlugin>
                <compilerPlugin>
                  <groupId>org.fusesource.jvmassert</groupId>
                  <artifactId>jvmassert</artifactId>
                  <version>1.1</version>
                </compilerPlugin>
              </compilerPlugins>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    
    <profile>
      <id>release</id>
      <build>
        <plugins>
          
          <!-- Generate the Scala Docs so that they can be included in the javadoc artifact -->
          <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>${scala-plugin-version}</version>
            <executions>
              <execution>
                <id>doc</id>
                <phase>process-classes</phase>
                <goals>
                  <goal>doc</goal>
                </goals>
                <configuration>
                  <reportOutputDirectory>${project.build.directory}</reportOutputDirectory>
                  <outputDirectory>apidocs</outputDirectory>
                </configuration>                
              </execution>
            </executions>
          </plugin>

        </plugins> 
      </build>
    </profile>
  </profiles>
  
</project>
