<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ QQQ - Low-code Application Framework for Engineers.
  ~ Copyright (C) 2021-2022.  Kingsrook, LLC
  ~ 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
  ~ contact@kingsrook.com
  ~ https://github.com/Kingsrook/
  ~
  ~ This program is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU Affero General Public License as
  ~ published by the Free Software Foundation, either version 3 of the
  ~ License, or (at your option) any later version.
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU Affero General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Affero General Public License
  ~ along with this program.  If not, see <https://www.gnu.org/licenses/>.
  -->
<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>
  <groupId>com.kingsrook.qqq</groupId>
  <artifactId>qqq-parent-project</artifactId>
  <version>0.27.7</version>
  <packaging>pom</packaging>
  <name>QQQ - Low-code Application Framework</name>
  <description>QQQ is a low-code application framework for engineers, providing backend modules, middleware, and tooling.</description>
  <url>https://github.com/Kingsrook/qqq</url>
  <licenses>
    <license>
      <name>GNU Affero General Public License v3.0</name>
      <url>https://www.gnu.org/licenses/agpl-3.0-standalone.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>kingsrook</id>
      <name>Kingsrook, LLC</name>
      <email>pub@qrun.io</email>
      <organization>Kingsrook, LLC</organization>
      <organizationUrl>https://qrun.io</organizationUrl>
    </developer>
  </developers>
  <modules>
    <module>qqq-bom</module>
    <module>qqq-backend-core</module>
    <module>qqq-backend-module-api</module>
    <module>qqq-backend-module-filesystem</module>
    <module>qqq-backend-module-rdbms</module>
    <module>qqq-backend-module-sqlite</module>
    <module>qqq-backend-module-mongodb</module>
    <module>qqq-language-support-javascript</module>
    <module>qqq-openapi</module>
    <module>qqq-middleware-picocli</module>
    <module>qqq-middleware-javalin</module>
    <module>qqq-middleware-lambda</module>
    <module>qqq-middleware-slack</module>
    <module>qqq-middleware-api</module>
    <module>qqq-utility-lambdas</module>
  </modules>
  <scm>
    <connection>scm:git:https://github.com/Kingsrook/qqq.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/Kingsrook/qqq.git</developerConnection>
    <url>https://github.com/Kingsrook/qqq</url>
  </scm>
  <properties>
    <maven.compiler.release>17</maven.compiler.release>
    <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
    <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
    <coverage.haltOnFailure>true</coverage.haltOnFailure>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <coverage.classCoveredRatioMinimum>0.95</coverage.classCoveredRatioMinimum>
    <testOutputToFile>true</testOutputToFile>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <revision>0.27.7</revision>
    <plugin.shade.phase>none</plugin.shade.phase>
    <coverage.instructionCoveredRatioMinimum>0.80</coverage.instructionCoveredRatioMinimum>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.1.2</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.23.0</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.23.0</version>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.8.1</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>5.8.1</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.23.1</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <build>
    <resources>
      <resource>
        <filtering>false</filtering>
        <directory>src/main/java</directory>
      </resource>
      <resource>
        <filtering>false</filtering>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <compilerArgument>-Xlint:unchecked</compilerArgument>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M5</version>
        <configuration>
          <argLine>@{jaCoCoArgLine}</argLine>
          <redirectTestOutputToFile>${testOutputToFile}</redirectTestOutputToFile>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.1.2</version>
        <executions>
          <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <configLocation>checkstyle/config.xml</configLocation>
              <headerLocation>checkstyle/license.txt</headerLocation>
              <encoding>UTF-8</encoding>
              <consoleOutput>true</consoleOutput>
              <failsOnError>false</failsOnError>
              <failOnViolation>true</failOnViolation>
              <violationSeverity>warning</violationSeverity>
              <excludes>**/target/generated-sources/*.*</excludes>
              <includeTestSourceDirectory>true</includeTestSourceDirectory>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>10.16.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <id>flatten</id>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
          <execution>
            <id>flatten.clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <updatePomFile>true</updatePomFile>
          <flattenMode>resolveCiFriendliesOnly</flattenMode>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
        <version>2.16.2</version>
        <configuration>
          <generateBackupPoms>false</generateBackupPoms>
          <allowSnapshots>true</allowSnapshots>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.amashchenko.maven.plugin</groupId>
        <artifactId>gitflow-maven-plugin</artifactId>
        <version>1.18.0</version>
        <configuration>
          <gitFlowConfig>
            <productionBranch>main</productionBranch>
            <developmentBranch>dev</developmentBranch>
            <versionTagPrefix>version-</versionTagPrefix>
            <releaseBranchPrefix>rel/</releaseBranchPrefix>
          </gitFlowConfig>
          <skipFeatureVersion>true</skipFeatureVersion>
          <postReleaseGoals>install</postReleaseGoals>
          <commitDevelopmentVersionAtStart>true</commitDevelopmentVersionAtStart>
          <versionDigitToIncrement>1</versionDigitToIncrement>
          <versionProperty>revision</versionProperty>
          <skipUpdateVersion>true</skipUpdateVersion>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>test-coverage-summary</id>
            <phase>verify</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>sh</executable>
              <arguments>
                <argument>-c</argument>
                <argument>if [ ! -e target/site/jacoco/index.html ]; then
   echo "No jacoco coverage report here.";
   exit;
fi

echo
echo "Jacoco coverage summary report for module: ${project.artifactId}"
echo "   See also target/site/jacoco/index.html"
echo "   and https://www.jacoco.org/jacoco/trunk/doc/counters.html"
echo "------------------------------------------------------------"

# Parse Jacoco HTML coverage summary
if [ -f target/site/jacoco/index.html ]; then
   echo -e "Instructions Missed\nInstruction Coverage\nBranches Missed\nBranch Coverage\nComplexity Missed\nComplexity Hit\nLines Missed\nLines Hit\nMethods Missed\nMethods Hit\nClasses Missed\nClasses Hit\n" > /tmp/$$.headers
   sed 's/&lt;\/\w\+>/&amp;\n/g' target/site/jacoco/index.html | grep -A 12 '&lt;tfoot>' | grep '&lt;td' | sed 's/&lt;td class="\w\+\d*">\([^&lt;]*\)&lt;\/td>/\1/' | grep -v Total > /tmp/$$.values
   paste /tmp/$$.headers /tmp/$$.values | tail +2 | awk -v FS='\t' '{printf("%-20s %s\n",$1,$2)}'
   rm /tmp/$$.headers /tmp/$$.values
else
   echo "Jacoco coverage summary was not found.";
fi
echo "-----------------------------"
echo

echo "Untested classes, per Jacoco for module: ${project.artifactId}"
echo "-----------------------------"
# Parse Jacoco XML reports directly to find classes with 0% coverage
sed 's/&lt;classs .*\?>/&amp;\n/g;s/&lt;\/class>/&amp;\n/g' target/site/jacoco/jacoco.xml | grep -v 'counter type="CLASS" missed="0"' | sed 's/>.*//;s/.*\///;s/".*//'
echo "-----------------------------"
echo</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.8</version>
        <executions>
          <execution>
            <id>pre-unit-test</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <propertyName>jaCoCoArgLine</propertyName>
            </configuration>
          </execution>
          <execution>
            <id>unit-test-check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <haltOnFailure>${coverage.haltOnFailure}</haltOnFailure>
              <rules>
                <rule>
                  <element>BUNDLE</element>
                  <limits>
                    <limit>
                      <counter>INSTRUCTION</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.instructionCoveredRatioMinimum}</minimum>
                    </limit>
                    <limit>
                      <counter>CLASS</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.classCoveredRatioMinimum}</minimum>
                    </limit>
                  </limits>
                </rule>
              </rules>
            </configuration>
          </execution>
          <execution>
            <id>post-unit-test</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <version>0.8.0</version>
        <extensions>true</extensions>
        <configuration>
          <publishingServerId>central</publishingServerId>
          <autoPublish>true</autoPublish>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <plugins>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.6.2</version>
        <reportSets>
          <reportSet>
            <id>aggregate</id>
            <reports>
              <report>aggregate</report>
            </reports>
            <inherited>false</inherited>
          </reportSet>
          <reportSet>
            <reports>
              <report>javadoc</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
  <profiles>
    <profile>
      <id>buildShadedJar</id>
      <properties>
        <plugin.shade.phase>package</plugin.shade.phase>
      </properties>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.3.0</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.6.2</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <failOnError>false</failOnError>
                  <doclint>none</doclint>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <failOnError>false</failOnError>
              <doclint>none</doclint>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.4</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <keyname>68A49476754103988EA3ED924B88CBB3D6DCB237</keyname>
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <keyname>68A49476754103988EA3ED924B88CBB3D6DCB237</keyname>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.8.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>true</autoPublish>
              <waitUntil>uploaded</waitUntil>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>withSample</id>
      <modules>
        <module>qqq-sample-project</module>
      </modules>
    </profile>
  </profiles>
</project>
