<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>org.terracotta.forge</groupId>
    <artifactId>forge-parent</artifactId>
    <version>1.0.14</version>
  </parent>

  <groupId>org.terracotta.forge</groupId>
  <artifactId>tim-system-tests-parent</artifactId>
  <version>1.2.2</version>
  <packaging>pom</packaging>

  <name>TIM System Tests Parent</name>
  <description>Parent POM for TIM system tests</description>

  <scm>
    <connection>scm:svn:http://svn.terracotta.org/svn/forge/projects/tim-system-tests-parent/tags/release-1.2.2</connection>
    <developerConnection>scm:svn:https://svn.terracotta.org/repo/forge/projects/tim-system-tests-parent/tags/release-1.2.2</developerConnection>
    <url>http://svn.terracotta.org/svn/forge/projects/tim-system-tests-parent/tags/release-1.2.2</url>
  </scm>

  <profiles>
    <profile>
      <id>container-tests-windows</id>
      <activation>
        <os><family>windows</family></os>
      </activation>
      <properties>
        <localMavenRepository>C:\DOCUME~1\${env.USERNAME}\.m2\repository</localMavenRepository>
      </properties>
    </profile>

    <profile>
      <id>system-tests</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.terracotta.maven.plugins</groupId>
            <artifactId>tc-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
 
    <profile>
      <id>container-tests</id>
      <activation>
        <property>
          <name>appserver</name>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>org.terracotta.plugin</groupId>
            <artifactId>maven-appserver-plugin</artifactId>
            <version>${maven-appserver-plugin.version}</version>
            <executions>
              <execution>
                <id>install-appserver</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>setup</goal>
                </goals>
                <configuration>
				  <url>
				    <param>http://download.terracotta.org/appservers</param>
					<param>http://kong.terracotta.lan/resources/appservers</param>
				  </url>
                  <testPropertiesFile>${tc.tests.configuration.properties.file}</testPropertiesFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <properties>
    <forgeTags>Parent POM</forgeTags>
    <tc.tests.configuration.properties.file>${project.build.testOutputDirectory}/tc.tests.properties</tc.tests.configuration.properties.file>

    <!--
         Unfortunately, this silly localMavenRepository property is necessary
         because we have to treat it specially on Windows and set it to
         C:\DOCUME~1\${env.USERNAME}\.m2\repository to avoid spaces in the path
         (see the container-tests-windows profile definition).
    -->
    <localMavenRepository>${user.home}/.m2/repository</localMavenRepository>

    <surefire.version>2.4.3</surefire.version>
    <tc.version>2.7.2</tc.version>
    <tc-maven-plugin.version>1.2.2</tc-maven-plugin.version>
    <cargo-maven2-plugin.version>1.0-alpha-5</cargo-maven2-plugin.version>
    <tc.linked-child-process.version>1.0.2</tc.linked-child-process.version>
    <tc.tim-util.version>1.0.5</tc.tim-util.version>
	<maven-appserver-plugin.version>1.0.0</maven-appserver-plugin.version>
	
    <tc.config>tc-config.xml</tc.config>
    <tc.base-dir>${project.build.directory}</tc.base-dir>
    <com.tc.l1.modules.repositories>${localMavenRepository}</com.tc.l1.modules.repositories>
    <tc.dso.globalmode>false</tc.dso.globalmode>

    <tc.tests.configuration.transparent-tests.mode>normal</tc.tests.configuration.transparent-tests.mode>

    <tc.tests.info.bootjars.normal>${project.build.directory}/dso-boot.jar</tc.tests.info.bootjars.normal>
    <tc.tests.info.property-files>${tc.tests.configuration.properties.file}</tc.tests.info.property-files>
    <tc.tests.info.temp-root>${project.build.directory}/temp</tc.tests.info.temp-root>
    <tc.tests.info.data-root>${project.build.directory}/data</tc.tests.info.data-root>
    <tc.tests.info.linked-child-process-classpath>${localMavenRepository}/org/terracotta/linked-child-process/${tc.linked-child-process.version}/linked-child-process-${tc.linked-child-process.version}.jar</tc.tests.info.linked-child-process-classpath>
    <tc.tests.info.session.classpath>${localMavenRepository}/org/terracotta/tc-session/${tc.version}/tc-session-${tc.version}.jar</tc.tests.info.session.classpath>
    <tc.tests.info.junit-test-timeout-inseconds>900</tc.tests.info.junit-test-timeout-inseconds>
    <tc.tests.info.l2.startup.mode>internal</tc.tests.info.l2.startup.mode>
    <tc.bootclasspath>${tc.tests.info.bootjars.normal}</tc.bootclasspath>
    <surefire.argLine>-Xbootclasspath/p:${tc.bootclasspath} -Xms64m -Xmx128m -Dtc.base-dir=${tc.base-dir} -Dtc.config=${tc.config} -Dtc.dso.globalmode=${tc.dso.globalmode} -Dtc.tests.info.property-files=${tc.tests.info.property-files} -Dcom.tc.l1.modules.repositories=${localMavenRepository}</surefire.argLine>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>terracotta-api</artifactId>
        <version>${tc.version}</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>terracotta</artifactId>
        <version>${tc.version}</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>tcconfig</artifactId>
        <version>${tc.version}</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>tcconfig1</artifactId>
        <version>1.0</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>tcconfig2</artifactId>
        <version>2.0</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>tc-session</artifactId>
        <version>${tc.version}</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>tc-l1-reconnect-properties</artifactId>
        <version>${tc.version}</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>tc.test-compile</artifactId>
        <version>${tc.version}</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta.modules</groupId>
        <artifactId>tim-util</artifactId>
        <version>${tc.tim-util.version}</version>
      </dependency>
      <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>linked-child-process</artifactId>
        <version>${tc.linked-child-process.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>terracotta</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>tc.test-compile</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>tc-session</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>tcconfig</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>tcconfig1</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>tcconfig2</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta.modules</groupId>
      <artifactId>tim-util</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>linked-child-process</artifactId>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      <resource>
        <directory>src/main/unfiltered-resources</directory>
        <filtering>false</filtering>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
      </testResource>
      <testResource>
        <directory>src/test/unfiltered-resources</directory>
        <filtering>false</filtering>
      </testResource>
    </testResources>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.cargo</groupId>
          <artifactId>cargo-maven2-plugin</artifactId>
          <version>${cargo-maven2-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo.groovy</groupId>
          <artifactId>groovy-maven-plugin</artifactId>
          <executions>
            <execution>
              <phase>generate-test-resources</phase>
              <goals>
                <goal>execute</goal>
              </goals>
              <configuration>
                <source>
                   <![CDATA[
                   import org.apache.maven.project.interpolation.RegexBasedModelInterpolator
                   import org.apache.maven.project.MavenProject

                   Properties interpolatedProperties() {
                     def interpolator = new RegexBasedModelInterpolator()
                     def interpolatedProject = new MavenProject(
                         interpolator.interpolate(project.model, [:]))
                     return interpolatedProject.properties
                   }

                   Properties outputProperties = new Properties()
                   interpolatedProperties().each { key, value ->
                     if (key =~ /^tc\.tests\./) {
                       outputProperties.setProperty(key, value)
                     }
                   }

                   String propertiesFileName = project.properties.getProperty(
                       "tc.tests.configuration.properties.file")
                   File propertiesFile = new File(propertiesFileName)
                   assert !propertiesFile.isDirectory()
                   propertiesFile.parentFile.mkdirs()
                   def outputStream = new FileOutputStream(propertiesFile)
                   try {
                     outputProperties.store(outputStream, "")
                   }
                   finally {
                     outputStream.close()
                   }
                  ]]>
                </source>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <executions>
            <execution>
              <phase>process-test-resources</phase>
              <goals>
                <goal>testResources</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>testCompile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${surefire.version}</version>
          <executions>
            <execution>
              <phase>integration-test</phase>
              <goals>
                <goal>test</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <forkMode>always</forkMode>
            <forkedProcessTimeoutInSeconds>${tc.tests.info.junit-test-timeout-inseconds}</forkedProcessTimeoutInSeconds>
            <useSystemClassLoader>true</useSystemClassLoader>
            <argLine>${surefire.argLine}</argLine>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.terracotta.maven.plugins</groupId>
          <artifactId>tc-maven-plugin</artifactId>
          <version>${tc-maven-plugin.version}</version>
          <executions>
            <execution>
              <id>bootjar</id>
              <phase>generate-test-resources</phase>
              <goals>
                <goal>bootjar</goal>
              </goals>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>org.terracotta</groupId>
              <artifactId>terracotta</artifactId>
              <version>${tc.version}</version>
            </dependency>
            <dependency>
              <groupId>org.terracotta</groupId>
              <artifactId>tcconfig</artifactId>
              <version>${tc.version}</version>
            </dependency>
            <dependency>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <version>${cargo-maven2-plugin.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <overwriteBootjar>true</overwriteBootjar>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <id>build-full-classpath</id>
              <phase>compile</phase>
              <goals>
                <goal>build-classpath</goal>
              </goals>
              <configuration>
                <outputFile>${project.build.directory}/classpath.txt</outputFile>
              </configuration>
            </execution>
            <execution>
              <id>build-compile-classpath</id>
              <phase>compile</phase>
              <goals>
                <goal>build-classpath</goal>
              </goals>
              <configuration>
                <includeScope>compile</includeScope>
                <outputFile>${project.build.directory}/compile-classpath.txt</outputFile>
              </configuration>
            </execution>
            <execution>
              <id>build-test-classpath</id>
              <phase>compile</phase>
              <goals>
                <goal>build-classpath</goal>
              </goals>
              <configuration>
                <includeScope>test</includeScope>
                <outputFile>${project.build.directory}/test-classpath.txt</outputFile>
              </configuration>
            </execution>
            <execution>
              <id>build-runtime-classpath</id>
              <phase>compile</phase>
              <goals>
                <goal>build-classpath</goal>
              </goals>
              <configuration>
                <includeScope>runtime</includeScope>
                <outputFile>${project.build.directory}/runtime-classpath.txt</outputFile>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo.groovy</groupId>
        <artifactId>groovy-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
      <id>terracotta-repository</id>
      <url>http://www.terracotta.org/download/reflector/maven2</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>terracotta-repository</id>
      <url>http://www.terracotta.org/download/reflector/maven2</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <distributionManagement>
    <site>
      <id>forge-site</id>
      <name>Project Sites Server</name>
      <url>scpexe://orgstage/export1/forge/projects/</url>
    </site>
  </distributionManagement>
</project>