<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.projectdarkstar.server</groupId>
    <artifactId>sgs-server-parent</artifactId>
    <version>0.9.9</version>
  </parent>

  <artifactId>sgs-server</artifactId>
  <name>Project Darkstar Server</name>
  <packaging>jar</packaging>
  <url>http://www.projectdarkstar.com</url>
  <description>
    The sgs-server module is a standard jar package of sgs classes
    used exclusively by the server
  </description>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymock</artifactId>
    </dependency>
    <dependency>
      <groupId>com.projectdarkstar.client</groupId>
      <artifactId>sgs-client</artifactId>
    </dependency>

    <dependency>
      <groupId>com.projectdarkstar.server</groupId>
      <artifactId>sgs-server-api</artifactId>
    </dependency>
    <dependency>
      <groupId>com.projectdarkstar.server</groupId>
      <artifactId>sgs-shared</artifactId>
    </dependency>

    <dependency>
      <groupId>com.projectdarkstar.ext.berkeleydb</groupId>
      <artifactId>db</artifactId>
    </dependency>
    <dependency>
      <groupId>com.projectdarkstar.ext.berkeleydb</groupId>
      <artifactId>db-binaries</artifactId>
      <type>zip</type>
    </dependency>

    <dependency>
      <groupId>com.sleepycat</groupId>
      <artifactId>je</artifactId>
    </dependency>

    <dependency>
      <groupId>com.projectdarkstar.tools.test</groupId>
      <artifactId>sgs-test-ext</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>

      <!-- Customize the manifest for this particular jar
	   to include the the Kernel as the executable class
	   and the sgs jar files in the classpath -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
	      <addClasspath>false</addClasspath>
	      <mainClass>com.sun.sgs.impl.kernel.Kernel</mainClass>
            </manifest>
	    <manifestEntries>
	      <Class-Path>
		sgs-shared-${sgs-shared.version}.jar
		sgs-server-api-${sgs.version}.jar
	      </Class-Path>
	    </manifestEntries>
          </archive>
        </configuration>
      </plugin>


      <!-- Always attach a sources jar (with the assembly plugin)
	   Normally the maven-source-plugin should be used for this.
	   However, that plugin currently does not attach classifier
	   artifacts that are consumable by other modules in the reactor
	   (i.e. the javadoc module).  Using this as a workaround -->
      <plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-assembly-plugin</artifactId>
	<executions>
	  <execution>
	    <id>attach-sources</id>
	    <phase>package</phase>
	    <goals>
              <goal>attached</goal>
	    </goals>
	    <configuration>
	      <descriptors>
		<descriptor>src/main/assembly/sources.xml</descriptor>
              </descriptors>
	      <attach>true</attach>
	    </configuration>
	  </execution>
	</executions>
      </plugin>

      <!-- The berkeleydb binary package must be retrieved and unpacked
	   Before the test phase so that they are available during
	   runtime of the unit tests. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-bdb-binaries</id>
	    <phase>generate-test-resources</phase>
          </execution>
        </executions>
      </plugin>
      
      <!-- Create a clean test-output directory -->
      <plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-test-resources</phase>
            <configuration>
              <tasks>
		<delete dir="${test.output}"/>
		<mkdir dir="${test.output}"/>
              </tasks>
	    </configuration>
	    <goals>
	      <goal>run</goal>
	    </goals>
	  </execution>
	</executions>
      </plugin>

      <!-- Configure the surefire plugin (which runs the unit tests)
	   to feed the appropriate java.library.path which points to
	   the extracted berkeleydb binary folder for the appropriate
	   platform. -->
      <plugin>
	<groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
	  <systemProperties>
	    <property>
	      <name>java.library.path</name>
	      <value>${run.javapath}</value>
	    </property>
	    <property>
	      <name>java.util.logging.config.file</name>
	      <value>${run.logging}</value>
	    </property>
	    <property>
	      <name>
		com.sun.sgs.impl.service.data.store.db.environment.class
	      </name>
	      <value>${run.bdb.env}</value>
	    </property>
	    <property>
	      <name>
		com.sun.sgs.impl.service.data.store.db.bdb.cache.size
	      </name>
	      <value>${test.bdb.cache.size}</value>
	    </property>
	    <property>
	      <name>java.io.tmpdir</name>
	      <value>${test.output}</value>
	    </property>
	    <property>
	      <name>com.sun.sgs.txn.timeout</name>
	      <value>${com.sun.sgs.txn.timeout}</value>
	    </property>
	  </systemProperties>
	  <argLine>
	    ${test.jvm.args} -Djava.library.path=${run.javapath}
	  </argLine>
	  <reportsDirectory>${test.reports}</reportsDirectory>
        </configuration>
	<executions>
	  <execution>
	    <phase>integration-test</phase>
	    <goals>
	      <goal>test</goal>
	    </goals>
	    <configuration>
	      <argLine>
		${test.jvm.args} -Dtest.phase=long -Djava.library.path=${run.javapath}
	      </argLine>
	      <reportsDirectory>${itest.reports}</reportsDirectory>
	    </configuration>
	  </execution>
	</executions>
      </plugin>

      <!-- Activate the resource bundle plugin to include the license
	   file in the jar -->
      <plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-remote-resources-plugin</artifactId>
      </plugin>

    </plugins>

    <!-- Activate resource filtering so the sgs.version file
	 can get the correct version replaced -->
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
  </build>

  <reporting>
    <plugins>

      <!-- Configure findbugs to run during site lifecycle -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
	<configuration>
	  <effort>Max</effort>
	  <excludeFilterFile>
	    ${basedir}/src/main/etc/findbugs-exclude.xml
	  </excludeFilterFile>
	  <threshold>Low</threshold>
	  <xmlOutput>true</xmlOutput>
	  <findbugsXmlOutput>true</findbugsXmlOutput>
	  <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
	</configuration>
      </plugin>

    </plugins>
  </reporting>

  <properties>
    <!-- The directory to use as the temporary directory while running
	 tests, for storing database files, etc.  The directory is
	 removed and recreated for each test run. -->
    <test.output>target/test-output</test.output>
    <!-- The directory for storing tests results -->
    <test.reports>target/test-reports</test.reports>
    <!-- The directory for storing integration tests results -->
    <itest.reports>target/itest-reports</itest.reports>
    <run.logging>
      ${basedir}/src/test/properties/logging.properties
    </run.logging>
    <!-- The default transaction timeout -->
    <com.sun.sgs.txn.timeout>100</com.sun.sgs.txn.timeout>
  </properties>

</project>
