<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.limemojito.oss.standards</groupId>
    <artifactId>oss-maven-standards</artifactId>
    <version>18.0.300</version>
  </parent>
  <artifactId>java-development</artifactId>
  <version>18.0.300</version>
  <packaging>pom</packaging>
  <name>${project.artifactId}</name>
  <properties>
    <docker.unit.test>false</docker.unit.test>
    <maven.compiler.release.version>${java.version}</maven.compiler.release.version>
    <coverage.exclude.build.pattern.2>**.*Configuration</coverage.exclude.build.pattern.2>
    <coverage.exclude.build.pattern.3></coverage.exclude.build.pattern.3>
    <coverage.exclude.build.pattern.1>**.*Config</coverage.exclude.build.pattern.1>
    <coverage.exclude.build.pattern.4></coverage.exclude.build.pattern.4>
    <coverage.exclude.build.pattern.5></coverage.exclude.build.pattern.5>
    <coverage.exclude.pattern.3></coverage.exclude.pattern.3>
    <coverage.exclude.pattern.2></coverage.exclude.pattern.2>
    <coverage.exclude.pattern.1></coverage.exclude.pattern.1>
    <skipTests>false</skipTests>
    <coverage.exclude.pattern.5></coverage.exclude.pattern.5>
    <coverage.exclude.pattern.4></coverage.exclude.pattern.4>
    <docker.test.compose.file>${docker.test.compose.dir}/docker-compose.yml</docker.test.compose.file>
    <maven-checkstyle-plugin.configLocation>http://standards.limemojito.com/oss-checkstyle.xml</maven-checkstyle-plugin.configLocation>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <source.properties>${project.basedir}/target/source.properties</source.properties>
    <lime.fast-build>false</lime.fast-build>
    <docker.build.log.dir>${project.build.directory}/docker-logs</docker.build.log.dir>
    <coverage.line.ratio>0.95</coverage.line.ratio>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <docker.test.properties>${project.basedir}/target/docker.properties</docker.test.properties>
    <skipITs>false</skipITs>
    <docker.test.compose.dir>${project.basedir}/src/test/docker</docker.test.compose.dir>
    <lombok.outputDirectory>${project.build.directory}/generated-sources/delombok</lombok.outputDirectory>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.limemojito.oss.standards</groupId>
        <artifactId>library</artifactId>
        <version>18.0.300</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <resources>
      <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>properties-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>import-source-properties</id>
              <phase>initialize</phase>
              <goals>
                <goal>read-project-properties</goal>
              </goals>
              <configuration>
                <files>
                  <file>${source.properties}</file>
                </files>
              </configuration>
            </execution>
            <execution>
              <id>import-test-docker-properties</id>
              <phase>initialize</phase>
              <goals>
                <goal>read-project-properties</goal>
              </goals>
              <configuration>
                <files>
                  <file>${docker.test.properties}</file>
                </files>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
            <execution>
              <id>identify-source-properties</id>
              <phase>validate</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <target>
                  <condition else="false" property="source.skip">
                    <not>
                      <available file="${project.build.sourceDirectory}" type="dir" />
                    </not>
                  </condition>
                  <echo level="info">source.skip is ${source.skip}</echo>
                  <echo file="${source.properties}" message="source.skip=${source.skip}${line.separator}" append="false" />
                </target>
              </configuration>
            </execution>
            <execution>
              <id>identify-docker-compose</id>
              <phase>validate</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <target>
                  <condition else="false" property="docker.test.compose.skip">
                    <or>
                      <equals arg2="true" arg1="${lime.fast-build}" />
                      <not>
                        <available file="${docker.test.compose.file}" />
                      </not>
                    </or>
                  </condition>
                  <condition else="false" property="docker.unit.test.skip">
                    <or>
                      <equals arg2="true" arg1="${lime.fast-build}" />
                      <equals arg2="true" arg1="${skipTests}" />
                      <equals arg2="true" arg1="${docker.test.compose.skip}" />
                    </or>
                  </condition>
                  <condition else="false" property="docker.integration.test.skip">
                    <or>
                      <equals arg2="true" arg1="${lime.fast-build}" />
                      <equals arg2="true" arg1="${skipITs}" />
                      <equals arg2="true" arg1="${docker.test.compose.skip}" />
                    </or>
                  </condition>
                  <echo level="info">docker.test.compose.skip is ${docker.test.compose.skip},
                                        docker.unit.test.skip=${docker.unit.test.skip},
                                        docker.integration.test.skip=${docker.integration.test.skip}</echo>
                  <echo file="${docker.test.properties}" message="docker.test.compose.skip=${docker.test.compose.skip}${line.separator}" append="false" />
                  <echo file="${docker.test.properties}" message="docker.integration.test.skip=${docker.integration.test.skip}${line.separator}" append="true" />
                  <echo file="${docker.test.properties}" message="docker.unit.test.skip=${docker.unit.test.skip}${line.separator}" append="true" />
                </target>
              </configuration>
            </execution>
            <execution>
              <id>docker-up-unit-test</id>
              <phase>test-compile</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <skip>${docker.unit.test.skip}</skip>
                <target if="${docker.unit.test}">
                  <exec failifexecutionfails="true" failonerror="true" dir="${docker.test.compose.dir}" executable="docker">
                    <arg value="compose" />
                    <arg value="up" />
                    <arg value="--quiet-pull" />
                    <arg value="--wait" />
                    <arg value="--detach" />
                    <env value="${localstack.token}" key="LOCALSTACK_AUTH_TOKEN" />
                  </exec>
                </target>
              </configuration>
            </execution>
            <execution>
              <id>docker-up-integration-test</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <skip>${docker.integration.test.skip}</skip>
                <target unless="${docker.unit.test}">
                  <exec failifexecutionfails="true" failonerror="true" dir="${docker.test.compose.dir}" executable="docker">
                    <arg value="compose" />
                    <arg value="up" />
                    <arg value="--quiet-pull" />
                    <arg value="--wait" />
                    <arg value="--detach" />
                    <env value="${localstack.token}" key="LOCALSTACK_AUTH_TOKEN" />
                  </exec>
                </target>
              </configuration>
            </execution>
            <execution>
              <id>docker-save-logs</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <skip>${docker.test.compose.skip}</skip>
                <target xmlns:ac="antlib:net.sf.antcontrib">
                  <echo level="info" message="Saving Docker logs for all running containers" />
                  <exec outputProperty="docker.container.list.raw" failonerror="true" executable="docker">
                    <arg value="ps" />
                    <arg value="-aq" />
                  </exec>
                  <exec outputProperty="docker.container.list" failonerror="true" executable="/bin/bash">
                    <arg value="-c" />
                    <arg line="&quot;echo '${docker.container.list.raw}' | tr '\n' ' '&quot;" />
                  </exec>
                  <ac:if>
                    <not>
                      <equals arg2="${docker.container.list}" arg1="" />
                    </not>
                    <then>
                      <echo level="info" message="Docker container list: ${docker.container.list}" />
                      <echo level="info" message="Output docker logs to ${docker.build.log.dir}" />
                      <mkdir dir="${docker.build.log.dir}" />
                      <exec failonerror="true" dir="${docker.build.log.dir}" executable="/bin/bash">
                        <arg value="-c" />
                        <arg line="&quot;for container in ${docker.container.list}; do name=$(docker ps --format &quot;{{.Names}}&quot; --filter &quot;id=$container&quot;); docker logs ${container} > ${container}-$name.log; echo Wrote ${container}-$name.log; done&quot;" />
                      </exec>
                    </then>
                  </ac:if>
                </target>
              </configuration>
            </execution>
            <execution>
              <id>docker-down</id>
              <phase>install</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <skip>${docker.test.compose.skip}</skip>
                <target>
                  <exec failifexecutionfails="true" failonerror="true" dir="${docker.test.compose.dir}" executable="docker">
                    <arg value="compose" />
                    <arg value="down" />
                    <arg value="--remove-orphans" />
                    <arg value="--volumes" />
                    <env value="${localstack.token}" key="LOCALSTACK_AUTH_TOKEN" />
                  </exec>
                </target>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <executions>
            <execution>
              <id>validate</id>
              <phase>process-classes</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${checkstyle.version}</version>
              <exclusions>
                <exclusion>
                  <groupId>com.sun</groupId>
                  <artifactId>tools</artifactId>
                </exclusion>
              </exclusions>
            </dependency>
          </dependencies>
          <configuration>
            <configLocation>${maven-checkstyle-plugin.configLocation}</configLocation>
            <consoleOutput>true</consoleOutput>
            <failsOnError>true</failsOnError>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <release>${java.version}</release>
            <compilerArgs>
              <compilerArg>-Xlint:all</compilerArg>
              <compilerArg>-Xlint:-processing</compilerArg>
              <compilerArg>-Xlint:-serial</compilerArg>
              <compilerArg>-Werror</compilerArg>
            </compilerArgs>
            <showWarnings>true</showWarnings>
            <showDeprecation>true</showDeprecation>
            <failOnError>true</failOnError>
            <annotationProcessorPaths>
              <annotationProcessorPath>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
              </annotationProcessorPath>
            </annotationProcessorPaths>
            <parameters>true</parameters>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>properties</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <argLine>-XX:+EnableDynamicAgentLoading</argLine>
            <classesDirectory>${project.build.outputDirectory}</classesDirectory>
            <environmentVariables>
              <SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
            </environmentVariables>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <configuration>
            <archive>
              <manifest>
                <addDefaultEntries>true</addDefaultEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-javadoc-plugin</artifactId>
          <executions>
            <execution>
              <phase>prepare-package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
              <configuration>
                <sourcepath>${lombok.outputDirectory}:${project.build.sourceDirectory}</sourcepath>
                <doclint>-missing</doclint>
              </configuration>
            </execution>
          </executions>
          <configuration>
            <skip>${javadoc.skip}</skip>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <configuration>
            <propertiesEncoding>ISO-8859-1</propertiesEncoding>
            <nonFilteredFileExtensions>
              <nonFilteredFileExtension>bi5</nonFilteredFileExtension>
              <nonFilteredFileExtension>dll</nonFilteredFileExtension>
              <nonFilteredFileExtension>doc</nonFilteredFileExtension>
              <nonFilteredFileExtension>exe</nonFilteredFileExtension>
              <nonFilteredFileExtension>so</nonFilteredFileExtension>
              <nonFilteredFileExtension>xls</nonFilteredFileExtension>
              <nonFilteredFileExtension>zip</nonFilteredFileExtension>
            </nonFilteredFileExtensions>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <executions>
            <execution>
              <id>attach-sources</id>
              <phase>prepare-package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <skipSource>${source.skip}</skipSource>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
            <argLine>@{argLine} -XX:+EnableDynamicAgentLoading</argLine>
            <environmentVariables>
              <SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
            </environmentVariables>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>default-prepare-agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>default-report</id>
              <phase>prepare-package</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
            <execution>
              <id>default-check</id>
              <phase>package</phase>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <rules>
                  <rule implementation="org.jacoco.maven.RuleConfiguration">
                    <element>CLASS</element>
                    <excludes>
                      <exclude>*.config.*</exclude>
                      <exclude>*.Config</exclude>
                      <exclude>*.Configuration</exclude>
                      <exclude>*.?</exclude>
                      <exclude>${coverage.exclude.pattern.1}</exclude>
                      <exclude>${coverage.exclude.pattern.2}</exclude>
                      <exclude>${coverage.exclude.pattern.3}</exclude>
                      <exclude>${coverage.exclude.pattern.4}</exclude>
                      <exclude>${coverage.exclude.pattern.5}</exclude>
                      <exclude>${coverage.exclude.build.pattern.1}</exclude>
                      <exclude>${coverage.exclude.build.pattern.2}</exclude>
                      <exclude>${coverage.exclude.build.pattern.3}</exclude>
                      <exclude>${coverage.exclude.build.pattern.4}</exclude>
                      <exclude>${coverage.exclude.build.pattern.5}</exclude>
                    </excludes>
                    <limits>
                      <limit implementation="org.jacoco.report.check.Limit">
                        <counter>LINE</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>${coverage.line.ratio}</minimum>
                      </limit>
                    </limits>
                  </rule>
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-gpg-plugin</artifactId>
          <executions>
            <execution>
              <id>sign-artifacts</id>
              <phase>verify</phase>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <skip>${sign.skip}</skip>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-gpg-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>fast-build</id>
      <properties>
        <checkstyle.skip>true</checkstyle.skip>
        <javadoc.skip>true</javadoc.skip>
        <codenarc.skip>true</codenarc.skip>
        <source.skip>true</source.skip>
        <skipITs>true</skipITs>
        <lime.fast-build>true</lime.fast-build>
        <enforcer.skip>true</enforcer.skip>
        <skipTests>true</skipTests>
        <jacoco.skip>true</jacoco.skip>
        <sign.skip>true</sign.skip>
      </properties>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>verify</phase>
                <goals>
                  <goal>delombok</goal>
                </goals>
                <configuration>
                  <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
                  <outputDirectory>${lombok.outputDirectory}</outputDirectory>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
