<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.12</version>
  </parent>

  <groupId>org.terracotta.forge</groupId>
  <artifactId>tim-system-tests-parent</artifactId>
  <version>1.1.0</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.1.0</connection>
    <developerConnection>scm:svn:https://svn.terracotta.org/repo/forge/projects/tim-system-tests-parent/tags/release-1.1.0</developerConnection>
    <url>http://svn.terracotta.org/svn/forge/projects/tim-system-tests-parent/tags/release-1.1.0</url>
  </scm>

  <profiles>
    <profile>
      <id>container-tests-generic</id>
      <activation>
        <os><family>unix</family></os>
      </activation>
      <properties>
        <appserver.os>generic</appserver.os>
        <appserver.cache>${user.home}/.tc/cargo-appservers</appserver.cache>
      </properties>
    </profile>
    <profile>
      <id>container-tests-windows</id>
      <activation>
        <os><family>windows</family></os>
      </activation>
      <properties>
        <appserver.os>win32</appserver.os>
        <appserver.cache>C:/temp/cargo-appservers</appserver.cache>
        <localMavenRepository>C:\DOCUME~1\${user.name}\.m2\repository</localMavenRepository>
      </properties>
    </profile>
    <profile>
      <id>container-tests-mac</id>
      <activation>
        <os><family>mac</family></os>
      </activation>
      <properties>
        <appserver.os>osx</appserver.os>
      </properties>
    </profile>
    <profile>
      <id>container-tests-solaris</id>
      <activation>
        <os><name>solaris</name></os>
      </activation>
      <properties>
        <appserver.os>solaris</appserver.os>
      </properties>
    </profile>
    <profile>
      <id>container-tests-linux</id>
      <activation>
        <os><name>linux</name></os>
      </activation>
      <properties>
        <appserver.os>linux</appserver.os>
      </properties>
    </profile>
    <profile>
      <id>container-tests</id>
      <activation>
        <property>
          <name>appserver</name>
        </property>
      </activation>
      <properties>
        <tc.tests.configuration.appserver>${tc.tests.configuration.appserver.factory.name}-${tc.tests.configuration.appserver.major-version}.${tc.tests.configuration.appserver.minor-version}</tc.tests.configuration.appserver>
        <tc.tests.configuration.appserver.repository>http://kong.terracotta.lan/resources/appservers</tc.tests.configuration.appserver.repository>
        <tc.tests.configuration.appserver.home>${appserver.cache}/${tc.tests.configuration.appserver}/${tc.tests.configuration.appserver}</tc.tests.configuration.appserver.home>
        <tc.tests.info.appserver.home>${tc.tests.configuration.appserver.home}</tc.tests.info.appserver.home>
        <appserver.zipfile>${tc.tests.configuration.appserver}.zip</appserver.zipfile>
        <appserver.url>${tc.tests.configuration.appserver.repository}/${tc.tests.configuration.appserver.factory.name}/${appserver.os}/${appserver.zipfile}</appserver.url>
      </properties>

      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
            <executions>
              <execution>
                <id>install-appserver</id>
                <phase>pre-integration-test</phase>
                <configuration>
                  <container>
                    <containerId>${cargo.containerId}</containerId>
                    <zipUrlInstaller>
                      <url>${appserver.url}</url>
                      <installDir>${appserver.cache}</installDir>
                    </zipUrlInstaller>
                  </container>
                </configuration>
                <goals>
                  <goal>install</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>container-tests-tomcat-5.5</id>
      <activation>
        <property>
          <name>appserver</name>
          <value>tomcat-5.5</value>
        </property>
      </activation>
      <properties>
        <cargo.containerId>tomcat5x</cargo.containerId>
        <tc.tests.configuration.appserver.factory.name>tomcat</tc.tests.configuration.appserver.factory.name>
        <tc.tests.configuration.appserver.major-version>5</tc.tests.configuration.appserver.major-version>
        <tc.tests.configuration.appserver.minor-version>5.26</tc.tests.configuration.appserver.minor-version>
        <tc.tests.configuration.appserver.repository>http://download.terracotta.org/appservers</tc.tests.configuration.appserver.repository>
      </properties>
    </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\${user.name}\.m2\repository to avoid spaces in the path
         (see the container-tests-windows profile definition).
    -->
    <localMavenRepository>${user.home}/.m2/repository</localMavenRepository>

    <surefire.version>2.3</surefire.version>
    <tc.version>2.6.0</tc.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>

    <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} -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>

  <dependencies>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>terracotta</artifactId>
      <version>${tc.version}</version>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>tc-session</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>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>tc.test-compile</artifactId>
      <version>${tc.version}</version>
    </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.mojo.groovy</groupId>
          <artifactId>groovy-maven-plugin</artifactId>
          <executions>
            <execution>
              <phase>generate-test-resources</phase>
              <goals>
                <goal>execute</goal>
              </goals>
              <configuration>
                <source>
                  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 -&gt;
                    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>1.1.0</version>
          <executions>
            <execution>
              <id>bootjar</id>
              <phase>generate-test-resources</phase>
              <goals>
                <goal>bootjar</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <overwriteBootjar>true</overwriteBootjar>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
            <execution>
              <id>print-classpaths</id>
              <phase>compile</phase>
              <configuration>
                <tasks>
                  <property name="compile_classpath" refid="maven.compile.classpath" />
                  <property name="runtime_classpath" refid="maven.runtime.classpath" />
                  <property name="test_classpath" refid="maven.test.classpath" />
                  <property name="plugin_classpath" refid="maven.plugin.classpath" />

                  <echo message="compile classpath: ${compile_classpath}" />
                  <echo message="runtime classpath: ${runtime_classpath}" />
                  <echo message="test classpath: ${test_classpath}" />
                  <echo message="plugin classpath: ${plugin_classpath}" />
                </tasks>
              </configuration>
              <goals>
                <goal>run</goal>
              </goals>
            </execution>
          </executions>
        </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.terracotta.maven.plugins</groupId>
        <artifactId>tc-maven-plugin</artifactId>
      </plugin>
      <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-surefire-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>
