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

<!--
  Codehaus Cargo, copyright 2004-2011 Vincent Massol, 2012-2022 Ali Tokmen.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<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.codehaus.cargo</groupId>
    <artifactId>cargo-extensions-ant</artifactId>
    <version>1.9.11</version>
  </parent>
  <artifactId>cargo-samples-ant</artifactId>
  <name>Cargo Samples - Ant</name>
  <packaging>pom</packaging>
  <description>Cargo Samples for Ant</description>
  <modules>
    <module>ant1.10-test</module>
    <module>configurationFiles-xmlReplacements-test</module>
    <module>daemon-test</module>
    <module>datasource-test</module>
    <module>remote-test</module>
    <module>users-test</module>
  </modules>

  <dependencies>
    <dependency>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-sample-java</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <properties>
    <cargo-ant-tasks.directory>
      ${project.build.directory}/cargo-ant-tasks
    </cargo-ant-tasks.directory>
    <cargo-ant-buildfiles.directory>
      ${project.build.directory}/cargo-ant-buildfiles
    </cargo-ant-buildfiles.directory>
    <cargo-test-applications.directory>
      ${project.build.directory}/cargo-test-applications
    </cargo-test-applications.directory>
  </properties>

  <profiles>
    <profile>
      <id>run-its</id>
      <activation>
        <property>
          <name>skipTests</name>
          <value>!true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-ant-tasks</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <outputDirectory>${cargo-ant-tasks.directory}</outputDirectory>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.codehaus.cargo</groupId>
                      <artifactId>cargo-ant</artifactId>
                    </artifactItem>
                    <artifactItem>
                      <groupId>org.codehaus.cargo</groupId>
                      <artifactId>cargo-core-uberjar</artifactId>
                    </artifactItem>

                    <artifactItem>
                      <groupId>commons-discovery</groupId>
                      <artifactId>commons-discovery</artifactId>
                    </artifactItem>
                    <artifactItem>
                      <groupId>commons-logging</groupId>
                      <artifactId>commons-logging</artifactId>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!--
            Make sure tests always use randomly assigned and available ports
          -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>generate-port-numbers</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>reserve-network-port</goal>
                </goals>
                <configuration>
                  <portNames>
                    <portName>cargo.samples.servlet.port</portName>
                    <portName>cargo.samples.rmi.port</portName>
                    <portName>cargo.samples.tomcat.ajp.port</portName>
                  </portNames>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <id>surefire-it</id>
                <phase>integration-test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <skip>false</skip>
                  <systemProperties>
                    <property>
                      <name>http.port</name>
                      <value>${cargo.samples.servlet.port}</value>
                    </property>
                  </systemProperties>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/build.xml</include>
        </includes>
        <targetPath>${cargo-ant-buildfiles.directory}</targetPath>
      </testResource>
    </testResources>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <configuration>
            <escapeString>\</escapeString>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
