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

    Copyright (C) 2023 - 2024, 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.0.2</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://github.com/ascopes/protobuf-maven-plugin/blob/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.0.2</tag>
  </scm>

  <properties>
    <!-- Dependencies -->
    <assertj.version>3.25.3</assertj.version>
    <immutables.version>2.10.1</immutables.version>
    <jspecify.version>0.3.0</jspecify.version>
    <junit.version>5.10.2</junit.version>
    <kotlin.version>1.9.23</kotlin.version>
    <maven-core.version>3.9.6</maven-core.version>
    <maven-plugin-annotations.version>3.13.0</maven-plugin-annotations.version>
    <maven-plugin-api.version>3.9.6</maven-plugin-api.version>
    <maven-resolver-api.version>1.9.20</maven-resolver-api.version>
    <memoryfilesystem.version>2.8.0</memoryfilesystem.version>
    <mockito.version>5.11.0</mockito.version>
    <slf4j.version>2.0.13</slf4j.version>

    <!-- Plugins -->
    <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
    <license-maven-plugin.version>4.3</license-maven-plugin.version>
    <maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
    <maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
    <maven-gpg-plugin.version>3.2.1</maven-gpg-plugin.version>
    <maven-install-plugin.version>3.1.2</maven-install-plugin.version>
    <maven-invoker-plugin.version>3.6.1</maven-invoker-plugin.version>
    <maven-jar-plugin.version>3.4.1</maven-jar-plugin.version>
    <maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
    <maven-jxr-plugin.version>3.3.2</maven-jxr-plugin.version>
    <maven-plugin-plugin.version>3.13.0</maven-plugin-plugin.version>
    <maven-plugin-report-plugin.version>3.13.0</maven-plugin-report-plugin.version>
    <maven-project-info-reports-plugin.version>3.5.0</maven-project-info-reports-plugin.version>
    <maven-release-plugin.version>3.0.1</maven-release-plugin.version>
    <maven-site-plugin.version>4.0.0-M13</maven-site-plugin.version>
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
    <sisu-maven-plugin.version>0.3.5</sisu-maven-plugin.version>

    <!-- Plugin dependencies -->
    <checkstyle.version>10.16.0</checkstyle.version>
    <maven-surefire-junit5-tree-reporter.version>1.2.1</maven-surefire-junit5-tree-reporter.version>

    <!-- Other stuff -->
    <argLine>
      -Xshare:off
      -Dnet.bytebuddy.experimental=true
      -Dorg.slf4j.simpleLogger.log.io.github.ascopes=TRACE
    </argLine>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.github.marschall</groupId>
        <artifactId>memoryfilesystem</artifactId>
        <version>${memoryfilesystem.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>
        <!-- Used for integration tests that invoke the Kotlin compiler only. -->
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-bom</artifactId>
        <version>${kotlin.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </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>
    </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>**/*.xml</include>
                </includes>
                <excludes>
                  <exclude>.mvn/checkstyle/checkstyle.xml</exclude>
                </excludes>
              </licenseSet>
            </licenseSets>
            <mapping>
              <java>SLASHSTAR_STYLE</java>
            </mapping>
            <properties>
              <currentYear>2024</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>
          <!-- 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,-serial</compilerArg>
            </compilerArgs>
            <failOnWarning>true</failOnWarning>
            <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>

          <executions>
            <execution>
              <id>integration-test</id>
              <phase>integration-test</phase>
              <goals>
                <goal>install</goal>
                <goal>run</goal>
              </goals>

              <configuration>
                <addTestClassPath>true</addTestClassPath>
                <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                <failIfNoProjects>true</failIfNoProjects>
                <!-- Warning: placing this inside the cloneProjectsTo path triggers a resolution bug in the plugin -->
                <localRepositoryPath>${project.basedir}/target/it-repo</localRepositoryPath>
                <postBuildHookScript>test</postBuildHookScript>
                <settingsFile>src/it/settings.xml</settingsFile>
                <showErrors>true</showErrors>
                <showVersion>true</showVersion>
                <streamLogs>true</streamLogs>
                <streamLogsOnFailures>true</streamLogsOnFailures>
                <writeJunitReport>true</writeJunitReport>
              </configuration>
            </execution>
          </executions>
        </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>
            <goals>deploy</goals>
            <releaseProfiles>gpg</releaseProfiles>
          </configuration>
        </plugin>

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

        <plugin>
          <!-- Used in integration tests only. -->
          <groupId>org.jetbrains.kotlin</groupId>
          <artifactId>kotlin-maven-plugin</artifactId>
          <version>${kotlin.version}</version>

          <executions>
            <execution>
              <id>compile</id>
              <goals>
                <goal>compile</goal>
              </goals>
            </execution>

            <execution>
              <id>test-compile</id>
              <goals>
                <goal>test-compile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <!-- Compile src/main/site and generate the goals site pages. -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-invoker-plugin</artifactId>
        <version>${maven-invoker-plugin.version}</version>
      </plugin>

      <plugin>
        <!-- Generate source documentation listings. -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven-javadoc-plugin.version}</version>
        <configuration>
          <doclint>all,-missing</doclint>
        </configuration>
      </plugin>

      <plugin>
        <!-- Used to generate source code cross-references with other reporting plugins. -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>${maven-jxr-plugin.version}</version>
      </plugin>

      <plugin>
        <!-- Compile src/main/site and generate the goals site pages. -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-report-plugin</artifactId>
        <version>${maven-plugin-report-plugin.version}</version>
      </plugin>

      <plugin>
        <!-- Report unit test results. -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
      </plugin>

      <plugin>
        <!-- Report coverage. -->
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <!-- select non-aggregate reports only -->
              <report>report-aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>

  <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>

    <profile>
      <id>invoker-debug</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-invoker-plugin</artifactId>
              <version>${maven-invoker-plugin.version}</version>
              <configuration>
                <invokerPropertiesFile>invoker-debug.properties</invokerPropertiesFile>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>
</project>
