<?xml version="1.0"?>
<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>org.yamcs</groupId>
  <artifactId>yamcs-prometheus</artifactId>
  <version>1.2.2</version>
  <packaging>jar</packaging>

  <name>Expose metrics to Prometheus</name>
  <url>https://yamcs.org</url>
  <description>
    Expose metrics to Prometheus
  </description>

  <licenses>
    <license>
      <name>GNU Affero General Public License (AGPL)</name>
      <url>https://www.gnu.org/licenses/agpl-3.0.html</url>
    </license>
  </licenses>

  <scm>
    <url>https://github.com/yamcs/yamcs-prometheus</url>
  </scm>

  <organization>
    <name>Space Applications Services</name>
    <url>https://www.spaceapplications.com</url>
  </organization>

  <developers>
    <developer>
      <id>yamcs.org</id>
      <name>Yamcs Team</name>
    </developer>
  </developers>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <yamcsVersion>5.7.12</yamcsVersion>
    <prometheusClientVersion>0.16.0</prometheusClientVersion>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>simpleclient_common</artifactId>
      <version>${prometheusClientVersion}</version>
    </dependency>
    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>simpleclient_dropwizard</artifactId>
      <version>${prometheusClientVersion}</version>
    </dependency>
    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>simpleclient_hotspot</artifactId>
      <version>${prometheusClientVersion}</version>
    </dependency>

    <dependency>
      <groupId>org.yamcs</groupId>
      <artifactId>yamcs-core</artifactId>
      <version>${yamcsVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.yamcs</groupId>
      <artifactId>yamcs-web</artifactId>
      <version>${yamcsVersion}</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>${project.build.directory}/generated-resources/protobuf</directory>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <!-- Sets the 'os.detected.classifier' maven property (needed to fetch native protoc) -->
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.7.1</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>detect</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!-- Generate Protobuf java sources -->
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.6.1</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <protocArtifact>com.google.protobuf:protoc:3.19.6:exe:${os.detected.classifier}</protocArtifact>
          <checkStaleness>true</checkStaleness>
          <writeDescriptorSet>true</writeDescriptorSet>
          <descriptorSetFileName>${project.artifactId}.protobin</descriptorSetFileName>
          <descriptorSetOutputDirectory>${project.build.directory}/generated-resources/protobuf</descriptorSetOutputDirectory>
          <includeDependenciesInDescriptorSet>false</includeDependenciesInDescriptorSet>
          <includeSourceInfoInDescriptorSet>true</includeSourceInfoInDescriptorSet>
          <protocPlugins>
            <protocPlugin>
              <id>yamcs</id>
              <groupId>org.yamcs</groupId>
              <artifactId>yamcs-protoc-plugin</artifactId>
              <version>5.3.1</version>
              <mainClass>org.yamcs.protoc.ServiceGenerator</mainClass>
            </protocPlugin>
          </protocPlugins>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <release>11</release>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>org.yamcs.prometheus</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <release>11</release>
          <author>false</author>
          <breakiterator>true</breakiterator>
          <links>
            <link>https://docs.yamcs.org/javadoc/yamcs/latest/</link>
            <link>https://prometheus.github.io/client_java/</link>
          </links>
          <additionalOptions>
            <additionalOption>-Xdoclint:none</additionalOption>
            <additionalOption>-Xdoclint:html</additionalOption>
            <additionalOption>-Xdoclint:reference</additionalOption>
            <!-- the 'syntax' group is too strict with @param and @throws -->
            <!-- additionalOption>-Xdoclint:syntax</additionalOption-->
          </additionalOptions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.2.1</version>
      </plugin>
      <plugin>
        <groupId>org.yamcs</groupId>
        <artifactId>yamcs-maven-plugin</artifactId>
        <version>1.2.9</version>
        <executions>
          <execution>
            <goals>
              <goal>detect</goal>
            </goals>
          </execution>
          <execution>
            <id>bundle-extension</id>
            <phase>package</phase>
            <goals>
              <goal>bundle</goal>
            </goals>
            <configuration>
              <includeDefaultWrappers>false</includeDefaultWrappers>
              <includeConfiguration>false</includeConfiguration>
              <formats>
                <format>tar.gz</format>
              </formats>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
      <id>sonatype-snapshots</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <keyname>yamcs@spaceapplications.com</keyname>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.13</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>false</autoReleaseAfterClose>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <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>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
