<?xml version="1.0" encoding="UTF-8"?>

<!--
  Codehaus Cargo, copyright 2004-2011 Vincent Massol, 2012-2025 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-samples-ant</artifactId>
    <version>1.10.24</version>
  </parent>
  <artifactId>cargo-sample-ant-remote-test</artifactId>
  <name>Cargo Samples - Ant - Remote container test</name>
  <packaging>jar</packaging>
  <description>Sample application that exercises the Cargo Ant tasks with a remote container</description>
  <!--
    TODO: It would have been so great to:
      1) Start the container using Ant
      2) Only run CargoTest + run an anti-SimpleTest
      3) Tell Ant to remotely deploy
      4) Only run SimpleTest
      5) Tell Ant to remotely undeploy
      6) Run the anti-SimpleTest
      7) Tell Ant to remotely redeploy
      8) Only run SimpleTest
      9) Stop the container using Ant
    But I do not know how to manage such a complexity with Maven 3.
    So what we currently do is:
      1) Start the container using Ant
      2) Tell Ant to remotely deploy
      3) Run CargoTest + SimpleTest
      4) Tell Ant to remotely undeploy
      5) Tell Ant to remotely redeploy
      6) Stop the container using Ant
    -->
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-test-deployables</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <skip>${skipTests}</skip>
              <stripVersion>true</stripVersion>
              <outputDirectory>${cargo-test-applications.directory}</outputDirectory>
              <artifactItems>
                <artifactItem>
                  <groupId>org.codehaus.cargo</groupId>
                  <artifactId>simple-war</artifactId>
                  <type>war</type>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>start-and-deploy</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <skip>${skipTests}</skip>
              <target>
                <!-- Avoid CARGO-827: Cannot build on Windows -->
                <replace file="${cargo-ant-buildfiles.directory}/build.xml">
                  <replacefilter token="extensions\\ant\\samples\\remote-test/../../../../" value="" />
                  <replacefilter token="\\" value="\" />
                  <replacefilter token="\:" value=":" />
                </replace>
                <ant antfile="${cargo-ant-buildfiles.directory}/build.xml">
                  <target name="start" />
                  <target name="deploy" />
                </ant>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>undeploy-redeploy-and-stop</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <skip>${skipTests}</skip>
              <target>
                <ant antfile="${cargo-ant-buildfiles.directory}/build.xml">
                  <target name="undeploy" />
                  <target name="redeploy" />
                  <target name="stop" />
                </ant>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
