<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (C) 2023 - 2025, Ashley Scopes.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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.github.ascopes</groupId>
  <artifactId>protobuf-maven-plugin-parent</artifactId>
  <version>2.10.3</version>

  <name>Protobuf Maven Plugin Parent</name>
  <description>Parent POM for the Protobuf Maven Plugin.</description>
  <packaging>pom</packaging>

  <modules>
    <module>protobuf-maven-plugin</module>
    <!-- Integration tests within the protobuf-maven-plugin module will also be derived
         from this parent POM, but are not explicitly listed as modules directly. -->
  </modules>

  <inceptionYear>2023</inceptionYear>

  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>https://raw.githubusercontent.com/ascopes/protobuf-maven-plugin/main/LICENSE.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>ascopes</id>
      <name>Ashley Scopes</name>
      <email>73482956+ascopes@users.noreply.github.com</email>
      <url>https://github.com/ascopes</url>
      <organization>Ashley Scopes</organization>
      <organizationUrl>https://github.com/ascopes</organizationUrl>
      <roles>
        <role>Developer</role>
      </roles>
      <timezone>Europe/London</timezone>
    </developer>
  </developers>

  <contributors />

  <distributionManagement>
    <repository>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <site>
      <id>github-pages</id>
      <name>github-pages</name>
      <url>https://ascopes.github.io/protobuf-maven-plugin</url>
    </site>
  </distributionManagement>

  <issueManagement>
    <system>GitHub Issues</system>
    <url>https://github.com/ascopes/protobuf-maven-plugin/issues</url>
  </issueManagement>

  <organization>
    <name>Ashley Scopes (GitHub)</name>
    <url>https://github.com/ascopes</url>
  </organization>

  <url>https://github.com/ascopes/protobuf-maven-plugin</url>

  <scm>
    <url>https://github.com/ascopes/protobuf-maven-plugin</url>
    <connection>scm:git:https://github.com/ascopes/protobuf-maven-plugin</connection>
    <developerConnection>scm:git:https://github.com/ascopes/protobuf-maven-plugin
    </developerConnection>
    <tag>v2.10.3</tag>
  </scm>

  <properties>
    <!-- Dependencies -->
    <assertj.version>3.27.3</assertj.version>
    <immutables.version>2.10.1</immutables.version>
    <jackson-bom.version>2.18.2</jackson-bom.version>
    <javax-annotation.version>1.3.2</javax-annotation.version>
    <jspecify.version>1.0.0</jspecify.version>
    <junit.version>5.11.4</junit.version>
    <maven-core.version>3.9.9</maven-core.version>
    <maven-plugin-annotations.version>3.15.1</maven-plugin-annotations.version>
    <maven-plugin-api.version>3.9.9</maven-plugin-api.version>
    <maven-resolver-api.version>2.0.5</maven-resolver-api.version>
    <memoryfilesystem.version>2.8.1</memoryfilesystem.version>
    <mockito.version>5.15.2</mockito.version>
    <slf4j.version>2.0.16</slf4j.version>
    <wiremock.version>3.10.0</wiremock.version>

    <!-- Plugins -->
    <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
    <license-maven-plugin.version>4.6</license-maven-plugin.version>
    <maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
    <maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
    <maven-clean-plugin.version>3.4.0</maven-clean-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
    <maven-dependency-plugin.version>3.8.1</maven-dependency-plugin.version>
    <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
    <maven-install-plugin.version>3.1.3</maven-install-plugin.version>
    <maven-invoker-plugin.version>3.9.0</maven-invoker-plugin.version>
    <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
    <maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
    <maven-jxr-plugin.version>3.6.0</maven-jxr-plugin.version>
    <maven-plugin-plugin.version>3.15.1</maven-plugin-plugin.version>
    <maven-plugin-report-plugin.version>3.15.1</maven-plugin-report-plugin.version>
    <maven-project-info-reports-plugin.version>3.8.0</maven-project-info-reports-plugin.version>
    <maven-release-plugin.version>3.1.1</maven-release-plugin.version>
    <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
    <maven-site-plugin.version>4.0.0-M16</maven-site-plugin.version>
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
    <sisu-maven-plugin.version>0.3.5</sisu-maven-plugin.version>

    <!-- Plugin dependencies -->
    <checkstyle.version>10.21.2</checkstyle.version>
    <maven-surefire-junit5-tree-reporter.version>1.4.0</maven-surefire-junit5-tree-reporter.version>

    <!--
        - Force bytebuddy experimental support for some exotic platforms.
        - Enable trace logs for our code for diagnostics.
        - Enable the loading of dynamic agents to remove warnings about ByteBuddy loading
          itself at runtime which now are raised as of Java 22.
    -->
    <argLine>
      -Xshare:off
      -Dnet.bytebuddy.experimental=true
      -Dorg.slf4j.simpleLogger.log.io.github.ascopes=TRACE
      -XX:+EnableDynamicAgentLoading
    </argLine>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.fasterxml.jackson</groupId>
        <artifactId>jackson-bom</artifactId>
        <version>${jackson-bom.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>com.github.marschall</groupId>
        <artifactId>memoryfilesystem</artifactId>
        <version>${memoryfilesystem.version}</version>
      </dependency>

      <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>${javax-annotation.version}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>${maven-plugin-api.version}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven.plugin-tools</groupId>
        <artifactId>maven-plugin-annotations</artifactId>
        <version>${maven-plugin-annotations.version}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven.resolver</groupId>
        <artifactId>maven-resolver-api</artifactId>
        <version>${maven-resolver-api.version}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-core</artifactId>
        <version>${maven-core.version}</version>
        <scope>provided</scope>
      </dependency>

      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>${assertj.version}</version>
      </dependency>

      <dependency>
        <groupId>org.immutables</groupId>
        <artifactId>value</artifactId>
        <version>${immutables.version}</version>
      </dependency>

      <dependency>
        <groupId>org.jspecify</groupId>
        <artifactId>jspecify</artifactId>
        <version>${jspecify.version}</version>
      </dependency>

      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-bom</artifactId>
        <version>${mockito.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-bom</artifactId>
        <version>${slf4j.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.wiremock</groupId>
        <artifactId>wiremock</artifactId>
        <version>${wiremock.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <!-- Plugins to run on all subprojects implicitly. -->
    <plugins>
      <plugin>
        <!-- This is an aggregate so only needs to be applied once. -->
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <inherited>false</inherited>
      </plugin>

      <plugin>
        <!-- This has no option for aggregation but derived projects must specify the
            relativePath attribute so that locations of the checkstyle config file resolve
            correctly from the parent in ITs -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
      </plugin>
    </plugins>

    <!-- Management for optional plugins. -->
    <pluginManagement>
      <plugins>
        <plugin>
          <!-- Enforces our license header and allows adding it automatically to code. -->
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${license-maven-plugin.version}</version>

          <configuration>
            <!-- Useful flags: https://mycila.carbou.me/license-maven-plugin/ -->
            <aggregate>true</aggregate>
            <licenseSets>
              <licenseSet>
                <header>.mvn/license/license-header.txt</header>
                <includes>
                  <include>**/src/**/*.groovy</include>
                  <include>**/src/**/*.java</include>
                  <include>**/src/**/*.kt</include>
                  <include>**/src/**/*.properties</include>
                  <include>**/src/**/*.proto</include>
                  <include>**/src/**/*.scala</include>
                  <include>**/*.xml</include>
                </includes>
                <excludes>
                  <exclude>.mvn/checkstyle/checkstyle.xml</exclude>
                </excludes>
              </licenseSet>
            </licenseSets>
            <mapping>
              <java>SLASHSTAR_STYLE</java>
            </mapping>
            <properties>
              <currentYear>2025</currentYear>
              <inceptionYear>${project.inceptionYear}</inceptionYear>
            </properties>
            <strictCheck>true</strictCheck>
          </configuration>

          <executions>
            <execution>
              <id>validate-license-headers</id>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <!-- Used for integration testing to create ZIP archives. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>${maven-assembly-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven-clean-plugin.version}</version>
        </plugin>

        <plugin>
          <!-- Used for Mockito agent support in JDK21+. We have to know the JAR path of the dependency. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>${maven-dependency-plugin.version}</version>
        </plugin>

        <plugin>
          <!-- Checking style of code matches the Google code style. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>${maven-checkstyle-plugin.version}</version>

          <configuration>
            <configLocation>.mvn/checkstyle/checkstyle.xml</configLocation>
            <consoleOutput>true</consoleOutput>
            <failsOnError>true</failsOnError>
            <includeResources>true</includeResources>
            <sourceDirectories>${project.basedir}/src</sourceDirectories>
            <suppressionsLocation>.mvn/checkstyle/suppressions.xml</suppressionsLocation>
            <violationSeverity>info</violationSeverity>
          </configuration>

          <executions>
            <execution>
              <id>check-code-style</id>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>

          <dependencies>
            <dependency>
              <!-- Force the usage of checkstyle v10 rather than v8.28 -->
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${checkstyle.version}</version>
            </dependency>
          </dependencies>
        </plugin>

        <plugin>
          <!-- Java compiler config. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>

          <configuration>
            <compilerArgs>
              <compilerArg>-Xlint:all,-classfile,-processing,-requires-automatic,-serial</compilerArg>
            </compilerArgs>
            <failOnWarning>true</failOnWarning>
            <proc>full</proc>
            <showDeprecation>true</showDeprecation>
            <release>11</release>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven-install-plugin.version}</version>
        </plugin>

        <plugin>
          <!-- Runs integration tests. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-invoker-plugin</artifactId>
          <version>${maven-invoker-plugin.version}</version>
        </plugin>

        <plugin>
          <!-- Add additional entries to the JAR's MANIFEST.MF. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>

          <configuration>
            <archive>
              <index>true</index>
              <manifest>
                <addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                <addExtensions>true</addExtensions>
              </manifest>
              <manifestEntries>
                <Sealed>true</Sealed>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>

        <plugin>
          <!-- Generate plugin descriptors. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>${maven-plugin-plugin.version}</version>
        </plugin>

        <plugin>
          <!-- Create site info pages. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>${maven-project-info-reports-plugin.version}</version>
        </plugin>


        <plugin>
          <!-- Deployments and version incrementing. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>${maven-release-plugin.version}</version>
          <configuration>
            <!-- Don't test when making the tag, as we've already tested
                 by this point. -->
            <arguments>-Dmaven.test.skip -Dinvoker.skip</arguments>
            <goals>deploy</goals>
            <releaseProfiles>gpg</releaseProfiles>
            <preparationGoals>clean verify</preparationGoals>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
        </plugin>

        <plugin>
          <!-- Generate the plugin site. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>${maven-site-plugin.version}</version>

          <configuration>
            <generateSitemap>true</generateSitemap>
            <!-- Fixes links pointing to the wrong place. -->
            <relativizeSiteLinks>false</relativizeSiteLinks>
            <!-- Strict validation. -->
            <validate>true</validate>
          </configuration>
        </plugin>

        <plugin>
          <!-- Bundles project sources into an additional JAR for release. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
        </plugin>

        <plugin>
          <!-- Unit testing. -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>

          <configuration>
            <consoleOutputReporter>
              <disable>true</disable>
            </consoleOutputReporter>
            <!--
              This block is needed to show @DisplayName and @ParameterizedTest
              in reports with the provided names.
            -->
            <statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
              <disable>false</disable>
              <version>3.0</version>
              <usePhrasedFileName>false</usePhrasedFileName>
              <usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
              <usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
              <usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
            </statelessTestsetReporter>
            <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
              <disable>false</disable>
              <printStacktraceOnError>true</printStacktraceOnError>
              <printStacktraceOnFailure>true</printStacktraceOnFailure>
              <usePhrasedFileName>false</usePhrasedFileName>
              <usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
              <usePhrasedClassNameInTestCaseSummary>true</usePhrasedClassNameInTestCaseSummary>
            </statelessTestsetInfoReporter>
          </configuration>

          <dependencies>
            <dependency>
              <groupId>me.fabriciorby</groupId>
              <artifactId>maven-surefire-junit5-tree-reporter</artifactId>
              <version>${maven-surefire-junit5-tree-reporter.version}</version>
            </dependency>
          </dependencies>
        </plugin>

        <plugin>
          <!-- Generates JSR-330 CDI configuration data to enable using dependency injection. -->
          <groupId>org.eclipse.sisu</groupId>
          <artifactId>sisu-maven-plugin</artifactId>
          <version>${sisu-maven-plugin.version}</version>
          <executions>
            <execution>
              <id>generate-index</id>
              <goals>
                <goal>main-index</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <!-- Code coverage. -->
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>gpg</id>
      <build>
        <plugins>
          <plugin>
            <!-- GPG signing of build artifacts, required by Maven
                Central. We only enable this via a profile so that
                forks do not have to register GPG keys to be able
                to build. -->
            <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>
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
