<?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>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>7</version>
  </parent>

  <groupId>org.grouplens</groupId>
  <artifactId>grouplens-oss-parent</artifactId>
  <version>1</version>
  <packaging>pom</packaging>
  <name>GroupLens OSS Parent</name>
  <description>
    Parent module for GroupLens projects published via Sonatype OSS project hosting.
  </description>
  <url>${web.url}/grouplens-oss-parent</url>

  <organization>
    <name>GroupLens Research</name>
    <url>http://www.grouplens.org</url>
  </organization>

  <distributionManagement>
    <site>
      <id>grouplens.org</id>
      <url>${web.url.pub}/grouplens-oss-parent</url>
    </site>
  </distributionManagement>

  <properties>
    <web.url.pub>file:///srv/www/gl-common</web.url.pub>
    <web.url>http://dev.grouplens.org/gl-common/</web.url>
  </properties>

  <profiles>
    <!-- This profile from http://elehack.net/writings/programming/maven-target-in-tmpfs -->
    <profile>
      <id>external-build-dir</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <property>
          <name>external.build.root</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.alexecollins.maven.plugin</groupId>
            <artifactId>script-maven-plugin</artifactId>
            <version>1.0.0</version>
            <executions>
              <execution>
                <id>prep-work-tree</id>
                <goals><goal>execute</goal></goals>
                <phase>initialize</phase>
                <configuration>
                  <script>
                    import java.nio.file.*
                    def dir = "${external.build.root}/${project.groupId}:${project.artifactId}"
                    println "using Maven dir ${dir}"
                    def dirPath = Paths.get(dir)
                    if (!Files.exists(dirPath)) {
                    Files.createDirectories(dirPath)
                    }
                    def target = Paths.get("${project.build.directory}")
                    if (!Files.exists(target)) {
                    Files.createSymbolicLink(target, dirPath)
                    }</script>
                </configuration>
              </execution>
              <execution>
                <id>drop-symlink</id>
                <goals><goal>execute</goal></goals>
                <phase>clean</phase>
                <configuration>
                  <script>
                    import java.nio.file.*
                    def target = Paths.get("${project.build.directory}")
                    if (Files.isSymbolicLink(target)) {
                    Files.delete(target)
                    }
                  </script>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy</artifactId>
                <version>1.8.6</version>
              </dependency>
            </dependencies>
            <configuration>
              <language>groovy</language>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
    
</project>
