<?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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>io.mateu</groupId>
  <artifactId>backend</artifactId>
  <version>3.0-alpha.370</version>
  <packaging>pom</packaging>

  <name>Backend</name>
  <description>parent project</description>

  <url>http://maven.apache.org</url>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <scm>
    <connection>scm:git:git@github.com:miguelperezcolom/mateu-security.git</connection>
    <developerConnection>scm:git:git@github.com:miguelperezcolom/mateu-security.git</developerConnection>
    <url>https://github.com/miguelperezcolom/mateu-security</url>
  </scm>

  <developers>
    <developer>
      <id>miguelperezcolom</id>
      <name>Miguel Pérez Colom</name>
      <email>miguelperezcolom@gmail.com</email>
      <url>https://github.com/miguelperezcolom/</url>
      <organization>Mateu.io</organization>
      <organizationUrl>http://mateu.io</organizationUrl>
    </developer>
  </developers>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <jacoco.min.coverage>0%</jacoco.min.coverage>
    <!-- Module-wide (BUNDLE) line-coverage floor; modules with real suites override it
         (backend/shared/core sets 70%). -->
    <jacoco.min.bundle.coverage>0%</jacoco.min.bundle.coverage>
  </properties>

  <modules>
    <module>shared</module>
    <module>webflux</module>
    <module>micronaut</module>
    <module>quarkus</module>
    <module>mvc</module>
    <module>helidon-mp</module>
    <module>mateu-bundle-maven-plugin</module>
  </modules>

  <dependencyManagement>
    <dependencies>
      <!--
        Pin Lombok ahead of the Spring Boot BOM. spring-boot-starter-parent 3.3.4 manages
        Lombok to 1.18.34, which crashes on newer JDKs (e.g. JDK 25:
        "com.sun.tools.javac.code.TypeTag :: UNKNOWN"). A directly declared managed dependency
        wins over one from an imported BOM, so this bumps every module — including the framework
        adapters that pick Lombok up transitively from the classpath rather than pinning it in
        their own annotationProcessorPaths. (Overriding the lombok.version property does NOT work
        here because spring-boot-starter-parent is imported as a BOM, not used as the parent.)
      -->
      <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.46</version>
      </dependency>
      <!--
        Pin smallrye-common-function ahead of the Quarkus BOM. Quarkus 3.38 pulls it at 2.14.0 via
        jboss-threads and at 2.19.0 via smallrye-common-io, which the maven-enforcer
        DependencyConvergence rule rejects. A directly declared managed dependency converges every
        path on 2.19.0.
      -->
      <dependency>
        <groupId>io.smallrye.common</groupId>
        <artifactId>smallrye-common-function</artifactId>
        <version>2.19.0</version>
      </dependency>
      <!--
        Pin hibernate-validator to the Spring Boot 4 line (9.1.2.Final) everywhere. Spring Boot 4.1.0
        brings jakarta-validation 3.x / hibernate-validator 9.x; core and webflux-core also declare it
        directly (bumped to 9.1.2 in their poms), and this managed pin converges the modules that
        pick it up transitively from the Boot BOM, keeping maven-enforcer DependencyConvergence happy.
      -->
      <dependency>
        <groupId>org.hibernate.validator</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>9.1.2.Final</version>
      </dependency>
      <!--
        Pin Apache Groovy to the line rest-assured expects (4.0.22). rest-assured 5.5.0 (test scope)
        pulls groovy/groovy-json/groovy-xml at 4.0.22, but the Spring Boot 4.1 BOM manages them up to
        5.0.6. rest-assured's Groovy-based HTTPBuilder is not compatible with Groovy 5 — plain GET
        requests blow up with a NullPointerException deep in the Groovy metaclass machinery
        (io.mateu.integrationtests.GetIndexIT). Groovy is a test-only transitive here (nothing in the
        backend uses it at runtime), so a directly managed pin back to 4.0.22 fixes the ITs with no
        runtime impact.
      -->
      <dependency>
        <groupId>org.apache.groovy</groupId>
        <artifactId>groovy</artifactId>
        <version>4.0.22</version>
      </dependency>
      <dependency>
        <groupId>org.apache.groovy</groupId>
        <artifactId>groovy-json</artifactId>
        <version>4.0.22</version>
      </dependency>
      <dependency>
        <groupId>org.apache.groovy</groupId>
        <artifactId>groovy-xml</artifactId>
        <version>4.0.22</version>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>4.1.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>annotations</artifactId>
      <version>3.0.1</version>
    </dependency>

  </dependencies>

  <build>
          <pluginManagement>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <version>3.5.6</version> </plugin>
              </plugins>
          </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.15.0</version>
        <configuration>
          <source>21</source>
          <target>21</target>

          <compilerArgs>
            <!--
            <arg>-verbose</arg>
            <arg>-Xlint:all,-options,-path</arg>
            -->
            <arg>-parameters</arg>
          </compilerArgs>

        </configuration>
        <executions>
          <!-- Replacing default-compile as it is treated specially by maven -->
          <execution>
            <id>default-compile</id>
            <phase>none</phase>
          </execution>
          <!-- Replacing default-testCompile as it is treated specially by maven -->
          <execution>
            <id>default-testCompile</id>
            <phase>none</phase>
          </execution>
          <execution>
            <id>java-compile</id>
            <phase>compile</phase>
            <goals> <goal>compile</goal> </goals>
          </execution>
          <execution>
            <id>java-test-compile</id>
            <phase>test-compile</phase>
            <goals> <goal>testCompile</goal> </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.6.3</version>
        <configuration>
          <rules>
            <bannedDependencies>
            </bannedDependencies>
            <dependencyConvergence/>
          </rules>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>enforce</goal>
            </goals>
          </execution>
        </executions>
      </plugin>







      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.6.1</version>
        <executions>
          <execution>
            <id>add_sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.4.0</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.12.0</version>
        <configuration>
          <sourcepath>src/main/java</sourcepath>
          <source>21</source>
          <doclint>none</doclint>
          <failOnError>false</failOnError>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>


      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>3.2.8</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
            <configuration>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <version>0.11.0</version>
        <extensions>true</extensions>
        <configuration>
          <publishingServerId>central</publishingServerId>
          <autoPublish>true</autoPublish>
          <!--
          <waitUntil>published</waitUntil>
          -->
        </configuration>
      </plugin>

<!--
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.43.0</version>
        <configuration>
          <java>
            <removeUnusedImports/>
            <googleJavaFormat/>
          </java>
        </configuration>
      </plugin>
-->
      <plugin>
        <groupId>com.spotify.fmt</groupId>
        <artifactId>fmt-maven-plugin</artifactId>
        <version>2.29</version>
        <executions>
          <execution>
            <goals>
              <goal>format</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!--
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>4.8.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      -->

      <!--
      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <version>7.1.1</version>
        <configuration>
          <suppressionFiles>
            <suppressionFile>${project.basedir}/owasp-suppressions.xml</suppressionFile>
          </suppressionFiles>
          <failBuildOnCVSS>8</failBuildOnCVSS>
          <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
          <failOnError>true</failOnError>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      -->

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.15</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
          <execution>
            <id>check</id>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <!-- Excluded from coverage: thin wrappers over live HTTP that cannot run in-JVM.
               RemoteMenuHandler resolves federated menus against a REMOTE Mateu backend (the
               frontend performs the fetch in normal operation); DefaultMateuHttpClient is the
               java.net.http adapter behind it. Both are exercised by the e2e suites instead. -->
          <excludes>
            <exclude>io/mateu/core/infra/out/DefaultMateuHttpClient*</exclude>
            <exclude>io/mateu/core/application/runaction/RemoteMenuHandler*</exclude>
          </excludes>
          <rules>
            <rule>
              <element>PACKAGE</element>
              <limits>
                <limit>
                  <counter>LINE</counter>
                  <value>COVEREDRATIO</value>
                  <minimum>${jacoco.min.coverage}</minimum>
                </limit>
              </limits>
            </rule>
            <rule>
              <element>BUNDLE</element>
              <limits>
                <limit>
                  <counter>LINE</counter>
                  <value>COVEREDRATIO</value>
                  <minimum>${jacoco.min.bundle.coverage}</minimum>
                </limit>
              </limits>
            </rule>
          </rules>
        </configuration>
      </plugin>

    </plugins>
  </build>

</project>
