<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.avides.springboot.springtainer</groupId>
  <artifactId>springtainer-common</artifactId>
  <version>2.0.0</version>

  <name>springtainer-common</name>
  <description>Common utils for springtainer</description>
  <url>https://github.com/springtainer/springtainer-common</url>
  <organization>
    <name>AVIDES Media AG</name>
    <url>https://www.avides.com</url>
  </organization>
  <licenses>
    <license>
      <name>MIT License</name>
      <url>http://www.opensource.org/licenses/mit-license.php</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Julian Eggers</name>
      <email>eggers.julian@gmail.com</email>
    </developer>
    <developer>
      <name>Martin Schumacher</name>
      <email>mail@martin-schumacher.com</email>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/springtainer/springtainer-common</url>
    <connection>scm:git:https://github.com/springtainer/springtainer-common.git</connection>
    <developerConnection>scm:git:https://github.com/springtainer/springtainer-common.git</developerConnection>
  </scm>

  <properties>
    <!-- Build -->
    <maven.build.timestamp.format>dd.MM.yyyy HH:mm</maven.build.timestamp.format>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>21</java.version>
    <maven-compiler-plugin.version>3.15.0</maven-compiler-plugin.version>
    <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
    <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
    <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
    <maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
    <maven-failsafe-plugin.version>3.5.6</maven-failsafe-plugin.version>
    <maven-enforcer-plugin.version>3.6.3</maven-enforcer-plugin.version>
    <maven-release-plugin.version>3.3.1</maven-release-plugin.version>
    <maven-scm-provider-gitexe.version>1.11.3</maven-scm-provider-gitexe.version>
    <exists-maven-plugin.version>0.15.2</exists-maven-plugin.version>
    <central-publishing-maven-plugin.version>0.11.0</central-publishing-maven-plugin.version>
    <!-- Common -->
    <spring-boot.version>3.5.16</spring-boot.version>
    <spring-cloud-starter-bootstrap.version>4.3.3</spring-cloud-starter-bootstrap.version>
    <!-- lombok must be pinned explicitly for the annotation-processor path; kept in sync with the Spring Boot BOM -->
    <lombok.version>1.18.46</lombok.version>
    <!-- Other -->
    <docker-java.version>3.7.1</docker-java.version>
    <duct-tape.version>1.0.8</duct-tape.version>
    <!-- Testing -->
    <jacoco.version>0.8.15</jacoco.version>
    <!-- Explicit so Sonar reads the combined UT+IT jacoco report instead of guessing via scanner-default path conventions. -->
    <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Respect Spring Boot's dependency management: all BOM-managed versions
           (spring-*, junit, mockito, byte-buddy, assertj, logback, slf4j, httpclient5, ...)
           are inherited from here instead of being pinned individually. -->
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- Common -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-autoconfigure</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>
    <!-- We only need "spring-cloud-context", but without this starter the property
        "spring.cloud.bootstrap.enabled" is set to false by default, so we would
        need to set it to true manually. -->
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-bootstrap</artifactId>
      <version>${spring-cloud-starter-bootstrap.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-commons</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework.security</groupId>
          <artifactId>spring-security-rsa</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>
  
    <!-- Other -->
    <dependency>
      <groupId>com.github.docker-java</groupId>
      <artifactId>docker-java</artifactId>
      <version>${docker-java.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpcore</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.github.docker-java</groupId>
          <artifactId>docker-java-transport-netty</artifactId>
        </exclusion>
        <exclusion>
          <!-- Unused fallback transport (we always supply ApacheDockerHttpClient); its javax.ws.rs/jersey-* tree would otherwise clash with Spring Boot's jakarta-only jersey-bom -->
          <groupId>com.github.docker-java</groupId>
          <artifactId>docker-java-transport-jersey</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <!-- Provides ApacheDockerHttpClient, so docker-java can be given an explicit DockerHttpClient instead of silently falling back to its legacy
           Jersey transport (which logs a "will be an error in future releases" warning on every container start/stop). -->
      <groupId>com.github.docker-java</groupId>
      <artifactId>docker-java-transport-httpclient5</artifactId>
      <version>${docker-java.version}</version>
    </dependency>
    <dependency>
      <!-- Version managed by the Spring Boot BOM (5.5.2), which also overrides docker-java-transport-httpclient5's transitive 5.5.1 across the tree. -->
      <groupId>org.apache.httpcomponents.client5</groupId>
      <artifactId>httpclient5</artifactId>
    </dependency>
    <dependency>
      <groupId>org.rnorth.duct-tape</groupId>
      <artifactId>duct-tape</artifactId>
      <version>${duct-tape.version}</version>
      <scope>compile</scope>
    </dependency>

    <!-- Testing -->
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.agent</artifactId>
      <classifier>runtime</classifier>
      <version>${jacoco.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy-agent</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- BUILD AND FILES -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <release>${java.version}</release>
          <parameters>true</parameters>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>${maven-source-plugin.version}</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven-javadoc-plugin.version}</version>
        <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>${maven-gpg-plugin.version}</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
            <configuration>
              <!-- Needed for non-interactive signing; gpg would otherwise try an interactive pinentry prompt and fail in headless build environments -->
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- TEST AND COVERAGE -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <argLine>-Duser.timezone=Europe/Berlin</argLine>
          <systemPropertyVariables>
            <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
            <jacoco-agent.append>true</jacoco-agent.append>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${maven-failsafe-plugin.version}</version>
        <configuration>
          <reportsDirectory>target/surefire-reports</reportsDirectory>
          <systemPropertyVariables>
            <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
            <jacoco-agent.append>true</jacoco-agent.append>
          </systemPropertyVariables>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${maven-enforcer-plugin.version}</version>
        <configuration>
          <rules>
            <dependencyConvergence />
          </rules>
          <fail>false</fail>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
          <execution>
            <id>default-instrument</id>
            <goals>
              <goal>instrument</goal>
            </goals>
          </execution>
          <execution>
            <id>default-restore-instrumented-classes</id>
            <goals>
              <goal>restore-instrumented-classes</goal>
            </goals>
          </execution>
          <!--
            default-restore-instrumented-classes above runs at its default phase (prepare-package) to keep the
            packaged jar free of instrumented bytecode. But that means classes are back to non-instrumented by the
            time integration-test runs (pre-integration-test/integration-test come after prepare-package/package in
            the lifecycle) - so without re-instrumenting here, Failsafe would silently record zero IT coverage.
          -->
          <execution>
            <id>pre-integration-test-instrument</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>instrument</goal>
            </goals>
          </execution>
          <execution>
            <id>post-integration-test-restore</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>restore-instrumented-classes</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>verify</phase>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
              <dataFile>target/jacoco.exec</dataFile>
              <outputDirectory>target/site/jacoco</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- DEPLOYMENT -->
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>${maven-release-plugin.version}</version>
        <configuration>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <useReleaseProfile>false</useReleaseProfile>
          <releaseProfiles>release</releaseProfiles>
          <goals>deploy</goals>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.scm</groupId>
            <artifactId>maven-scm-provider-gitexe</artifactId>
            <version>${maven-scm-provider-gitexe.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.honton.chas</groupId>
        <artifactId>exists-maven-plugin</artifactId>
        <version>${exists-maven-plugin.version}</version>
        <configuration>
          <property>skip-deploy-to-central</property>
          <repository>https://oss.sonatype.org/content/repositories/releases/</repository>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>remote</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <version>${central-publishing-maven-plugin.version}</version>
        <extensions>true</extensions>
        <configuration>
          <autoPublish>true</autoPublish>
          <waitUntil>published</waitUntil>
          <skipPublishing>${skip-deploy-to-central}</skipPublishing>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
