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

    Copyright (c) 2022-present Sonatype, Inc. All rights reserved.
    "Sonatype" is a trademark of Sonatype, Inc.

-->
<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>ch.admin.bit.jeap</groupId>
  <artifactId>jeap-central-publishing-maven-plugin</artifactId>
  <version>0.7.0.1</version>
  <packaging>maven-plugin</packaging>

  <name>jEAP Central Publishing Maven Plugin</name>

  <description>
    This project is a maven plugin for publishing components in Maven Central, for more details
    on its usage see https://central.sonatype.org/publish/publish-portal-maven.
    This plugin has been forked from Sonatype's central-publishing-maven-plugin. The only change is the creation
    of the HTTP client, which has been patched to respect HTTP proxy system properties.
  </description>

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

  <url>https://github.com/jeap-admin-ch/jeap-central-publishing-maven-plugin</url>

  <scm>
    <url>https://github.com/jeap-admin-ch/jeap-central-publishing-maven-plugin</url>
    <connection>scm:git:git://github.com/jeap-admin-ch/jeap-central-publishing-maven-plugin.git</connection>
    <developerConnection>scm:git:ssh://github.com:jeap-admin-ch/jeap-central-publishing-maven-plugin.git
    </developerConnection>
  </scm>
  <developers>
    <developer>
      <name>BIT</name>
      <email>jeap-community@bit.admin.ch</email>
      <organization>Federal Office of Information Technology, Systems and Telecommunication FOITT</organization>
      <organizationUrl>https://www.bit.admin.ch/</organizationUrl>
    </developer>
  </developers>
  
  <parent>
    <groupId>org.sonatype.buildsupport</groupId>
    <artifactId>buildsupport</artifactId>
    <version>54</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <org.codehaus.mojo-license-maven-plugin.version>2.4.0</org.codehaus.mojo-license-maven-plugin.version>
    <jeap-license-template.version>1.0.2</jeap-license-template.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>3.9.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>3.8.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-invoker-plugin</artifactId>
      <version>3.5.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-compat</artifactId>
      <version>3.9.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>3.5.1</version>
    </dependency>
    <dependency>
      <groupId>com.github.package-url</groupId>
      <artifactId>packageurl-java</artifactId>
      <version>1.4.1</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>32.1.0-jre</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.15.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.12.0</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
      <version>2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mock-server</groupId>
      <artifactId>mockserver-client-java</artifactId>
      <version>5.15.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.16.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents.client5</groupId>
      <artifactId>httpclient5</artifactId>
      <version>5.3.1</version>
      <exclusions>
        <exclusion>
          <artifactId>commons-logging</artifactId>
          <groupId>commons-logging</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.mock-server</groupId>
        <artifactId>mockserver-client-java</artifactId>
        <exclusions>
          <exclusion>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-invoker-plugin</artifactId>
          <version>3.5.1</version>
          <configuration>
            <writeJunitReport>true</writeJunitReport>
            <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
            <pomIncludes>
              <pomInclude>*/pom.xml</pomInclude>
            </pomIncludes>
            <preBuildHookScript>setup</preBuildHookScript>
            <postBuildHookScript>verify</postBuildHookScript>
            <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
            <settingsFile>src/it/settings.xml</settingsFile>
            <properties>
              <centralBaseUrl>http://localhost:${mockcentral.port}</centralBaseUrl>
              <centralSnapshotsUrl>http://localhost:${mockcentral.port}/snapshots/</centralSnapshotsUrl>
            </properties>
            <goals>
              <goal>deploy</goal>
            </goals>
          </configuration>
          <executions>
            <execution>
              <id>integration-test</id>
              <goals>
                <goal>install</goal>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.plexus</groupId>
          <artifactId>plexus-component-metadata</artifactId>
          <version>2.1.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>3.8.2</version>
          <configuration>
            <goalPrefix>central-publishing</goalPrefix>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>3.4.0</version>
          <configuration>
            <portNames>
              <portName>mockcentral.port</portName>
            </portNames>
          </configuration>
          <executions>
            <execution>
              <id>reserve-network-port</id>
              <goals>
                <goal>reserve-network-port</goal>
              </goals>
              <phase>pre-integration-test</phase>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>0.43.0</version>
          <configuration>
            <logDate>ISO8601</logDate>
            <verbose>false</verbose>
            <!-- set to true for logging requests -->
            <showLogs>false</showLogs>
            <images>
              <image>
                <alias>mockcentral</alias>
                <name>mockserver/mockserver:5.15.0</name>
                <run>
                  <namingStrategy>alias</namingStrategy>
                  <ports>
                    <port>${mockcentral.port}:1080</port>
                  </ports>
                  <wait>
                    <http>
                      <url>http://localhost:${mockcentral.port}</url>
                      <!-- 404 means that the mockserver is running, just not accepting the request -->
                      <status>404</status>
                    </http>
                    <time>10000</time>
                  </wait>
                </run>
              </image>
            </images>
          </configuration>
          <executions>
            <execution>
              <id>start</id>
              <goals>
                <goal>start</goal>
              </goals>
              <phase>pre-integration-test</phase>
            </execution>
            <execution>
              <id>stop</id>
              <goals>
                <goal>stop</goal>
              </goals>
              <phase>post-integration-test</phase>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>3.1.0</version>
          <executions>
            <execution>
              <id>mockserver-config</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>java</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <mainClass>org.sonatype.central.publisher.plugin.mockserver.MockserverConfiguration</mainClass>
            <cleanupDaemonThreads>false</cleanupDaemonThreads>
            <arguments>
              <argument>${mockcentral.port}</argument>
            </arguments>
            <classpathScope>test</classpathScope>
            <stopUnresponsiveDaemonThreads>true</stopUnresponsiveDaemonThreads>
            <daemonThreadJoinTimeout>5000</daemonThreadJoinTimeout>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.sonatype.clm</groupId>
        <artifactId>clm-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>index</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-component-metadata</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>generate-metadata</goal>
              <goal>generate-test-metadata</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>descriptor</goal>
              <goal>helpmojo</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${org.codehaus.mojo-license-maven-plugin.version}</version>
        <dependencies>
          <dependency>
            <groupId>ch.admin.bit.jeap</groupId>
            <artifactId>jeap-license-template</artifactId>
            <version>${jeap-license-template.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>add-third-party</id>
            <phase>package</phase>
            <goals>
              <goal>add-third-party</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.basedir}</outputDirectory>
              <thirdPartyFilename>THIRD-PARTY-LICENSES.md</thirdPartyFilename>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <fileTemplate>/ch/admin/bit/jeap/third-party.md.ftl</fileTemplate>
          <useMissingFile>true</useMissingFile>
          <useRepositoryMissingFiles>false</useRepositoryMissingFiles>
          <failOnMissing>true</failOnMissing>
          <acceptPomPackaging>true</acceptPomPackaging>
          <deployMissingFile>false</deployMissingFile>
          <licenseMerges>
            <!-- Avoid line breaks in the licenseMerge tags! -->
            <licenseMerge>Apache License Version 2.0|Apache License, Version 2.0|The Apache Software License, Version 2.0|Apache Public License 2.0|Apache 2|Apache-2.0|Apache 2.0|Apache 2.0 License|Apache License 2.0|Apache Software License, version 2.0||The Apache License, Version 2.0|Apache License, version 2.0</licenseMerge>
            <licenseMerge>MIT License|MIT license|The MIT License|MIT|The MIT License (MIT)|MIT-0</licenseMerge>
            <licenseMerge>Mozilla Public License, Version 2.0|MPL 2.0</licenseMerge>
            <licenseMerge>GNU General Public License, version 2 (GPL2), with the classpath exception|GPL2 w/ CPE</licenseMerge>
            <licenseMerge>Eclipse Public License, Version 1.0|Eclipse Public License 1.0|Eclipse Public License - v 1.0|EPL 1.0</licenseMerge>
            <licenseMerge>Eclipse Public License v2.0|Eclipse Public License v. 2.0|Eclipse Public License - v 2.0|EPL 2.0</licenseMerge>
            <licenseMerge>Eclipse Distribution License - v 1.0|Eclipse Distribution License v. 1.0|Eclipse Distribution License (New BSD License)|EDL 1.0</licenseMerge>
            <licenseMerge>Common Development and Distribution License (CDDL) v1.0|COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</licenseMerge>
            <licenseMerge>BSD 2-Clause License|BSD-2-Clause</licenseMerge>
            <licenseMerge>BSD License 3|BSD-3-Clause</licenseMerge>
            <licenseMerge>Public Domain|Public Domain, per Creative Commons CC0</licenseMerge>
          </licenseMerges>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <!-- IT profile for running ALL ITs, will spin up docker container of mockserver, configured to respond as though
         it was central, as well as using a random port for the exposed port from the docker container -->
    <profile>
      <id>run-its</id>
      <build>
        <plugins>
          <!-- don't forget that plugin ordering is very important
               - get free port # (build-helper-maven-plugin)
               - startup mockserver docker container (docker-maven-plugin)
               - execute the java class to configure mockserver (exec-maven-pluign)
               - and finally run the ITs (maven-invoker-plugin) -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- IT profile for running only ITs that require the docker container to be running, will spin up docker container
         of mockserver, configured to respond as though it was central, as well as using a random port for the exposed
         port from the docker container -->
    <profile>
      <id>run-publish-its</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
          </plugin>
          <!-- don't forget that plugin ordering is very important
               - get free port # (build-helper-maven-plugin)
               - startup mockserver docker container (docker-maven-plugin)
               - execute the java class to configure mockserver (exec-maven-pluign)
               - and finally run the ITs (maven-invoker-plugin) -->
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <configuration>
              <pomIncludes>
                <pomInclude>publish*/pom.xml</pomInclude>
              </pomIncludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- IT profile for running only ITs that do NOT require the docker container to be running -->
    <profile>
      <id>run-bundle-its</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <configuration>
              <pomIncludes>
                <pomInclude>bundle*/pom.xml</pomInclude>
              </pomIncludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>jeap-maven-central-publish</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <!-- included to disable inherited nexus-staging-maven-plugin execution -->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.13</version>
            <extensions>true</extensions>
            <configuration>
              <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.5.0</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.2.1</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-gpg-plugin</artifactId>
            <version>1.5</version>
            <configuration>
              <gpgArguments>
                <!-- Note: These arguments are required for gpgp 2.1+ -->
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <!-- use our own just built version -->
            <groupId>${project.groupId}</groupId>
            <artifactId>${project.artifactId}</artifactId>
            <version>${project.version}</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <phase>deploy</phase>
                <goals>
                  <goal>publish</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>false</autoPublish>
              <skipPublishing>false</skipPublishing>
              <waitPollingInterval>15</waitPollingInterval>
              <!--
              <waitUntil>validated</waitUntil> <!- - published | uploaded | validated - ->
              -->
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <distributionManagement>
    <repository>
      <id>${releaseRepositoryId}</id>
      <name>${releaseRepositoryName}</name>
      <url>${releaseRepositoryUrl}</url>
    </repository>
    <snapshotRepository>
      <id>${snapshotRepositoryId}</id>
      <name>${snapshotRepositoryName}</name>
      <!--suppress UnresolvedMavenProperty -->
      <url>${snapshotRepositoryUrl}</url>
    </snapshotRepository>
  </distributionManagement>

</project>
