<?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">
  <parent>
    <artifactId>tf-build-tools</artifactId>
    <groupId>com.deliveredtechnologies</groupId>
    <version>0.2.1</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>tf-maven-starter</artifactId>
  <packaging>pom</packaging>
  <name>tf-maven-starter</name>
  <description>Terraform Maven Starter POM :: Simplifying the configuration of the Terraform Maven Plugin</description>
  <properties>
    <maven.deploy.skip>false</maven.deploy.skip>
    <maven.install.skip>false</maven.install.skip>
    <gpg.skip>false</gpg.skip>
    <skipNexusStagingDeployMojo>false</skipNexusStagingDeployMojo>
  </properties>
  <profiles>
    <profile>
      <id>dev</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <varFiles>${project.build.sourceDirectory}/../tf/tfvars/dev.tfvars</varFiles>
      </properties>
    </profile>
    <profile>
      <id>test</id>
      <properties>
        <varFiles>${project.build.sourceDirectory}/../tf/tfvars/test.tfvars</varFiles>
      </properties>
    </profile>
    <profile>
      <id>stage</id>
      <properties>
        <varFiles>${project.build.sourceDirectory}/../tf/tfvars/stage.tfvars</varFiles>
      </properties>
    </profile>
    <profile>
      <id>prod</id>
      <properties>
        <varFiles>${project.build.sourceDirectory}/../tf/tfvars/prod.tfvars</varFiles>
      </properties>
    </profile>
  </profiles>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <!-- disables default jar packaging: https://stackoverflow.com/questions/2188746/what-is-the-best-way-to-avoid-maven-jar -->
          <artifactId>maven-jar-plugin</artifactId>
          <executions>
            <execution>
              <id>default-jar</id>
              <phase>never</phase>
              <configuration>
                <finalName>unwanted</finalName>
                <classifier>unwanted</classifier>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>com.deliveredtechnologies</groupId>
          <artifactId>tf-maven-plugin</artifactId>
          <version>${project.parent.version}</version>
          <executions>
            <execution>
              <id>terraform-install</id>
              <phase>install</phase>
              <goals>
                <goal>deploy</goal>
              </goals>
            </execution>
            <execution>
              <id>terraform-plan</id>
              <phase>validate</phase>
              <goals>
                <goal>init</goal>
                <goal>plan</goal>
              </goals>
            </execution>
            <execution>
              <id>terraform-clean</id>
              <phase>clean</phase>
              <goals>
                <goal>clean</goal>
              </goals>
            </execution>
            <execution>
              <id>terraform-package</id>
              <phase>package</phase>
              <goals>
                <goal>package</goal>
              </goals>
            </execution>
            <execution>
              <id>terraform-deploy</id>
              <phase>deploy</phase>
              <goals>
                <goal>deploy</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>flatten-maven-plugin</artifactId>
          <version>1.1.0</version>
          <configuration>
          </configuration>
          <executions>
            <!-- enable flattening -->
            <execution>
              <id>flatten</id>
              <phase>process-resources</phase>
              <goals>
                <goal>flatten</goal>
              </goals>
            </execution>
            <!-- ensure proper cleanup -->
            <execution>
              <id>flatten.clean</id>
              <phase>clean</phase>
              <goals>
                <goal>clean</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
