<?xml version="1.0" encoding="UTF-8"?>
<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>

  <parent>
    <groupId>io.prometheus</groupId>
    <artifactId>client_java</artifactId>
    <version>1.3.10</version>
  </parent>

  <artifactId>prometheus-metrics-exposition-formats-no-protobuf</artifactId>
  <packaging>bundle</packaging>

  <name>Prometheus Metrics Exposition Formats no protobuf</name>
  <description>
    Prometheus exposition formats without shaded Protobuf classes.
  </description>

  <properties>
    <automatic.module.name>io.prometheus.metrics.expositionformats.noprotobuf</automatic.module.name>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>prometheus-metrics-exposition-textformats</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>${protobuf-java.version}</version>
    </dependency>
  </dependencies>

  <profiles>
    <!-- just to make sure that default profile is only activated if no profiles are specified -->
    <profile>
      <id>javadoc</id>
    </profile>
    <profile>
      <id>release</id>
    </profile>
    <profile>
      <id>default</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <dependencies>
        <!-- GH pages and release task try to resolve this and fail -->
        <dependency>
          <groupId>io.prometheus</groupId>
          <artifactId>prometheus-metrics-exposition-textformats</artifactId>
          <version>${project.version}</version>
          <scope>test</scope>
          <type>test-jar</type>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>regex-property</id>
            <goals>
              <goal>regex-property</goal>
            </goals>
            <configuration>
              <name>protobuf-java.string-version</name>
              <value>${protobuf-java.version}</value>
              <regex>\.</regex>
              <replacement>_</replacement>
              <failIfNoMatch>true</failIfNoMatch>
            </configuration>
          </execution>
          <execution>
            <id>negate-prop</id>
            <phase>initialize</phase>
            <goals>
              <goal>bsh-property</goal>
            </goals>
            <configuration>
              <source>skip.protobuf.generation =
                !"true".equals(System.getenv("PROTO_GENERATION"));
              </source>
              <properties>
                <property>skip.protobuf.generation</property>
              </properties>
            </configuration>
          </execution>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/generated/</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>exec-maven-plugin</artifactId>
        <groupId>org.codehaus.mojo</groupId>
        <executions>
          <execution>
            <id>Generate Protobuf</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <skip>${skip.protobuf.generation}</skip>
              <executable>${project.basedir}/generate-protobuf.sh</executable>
              <arguments>
                <argument>${project.basedir}/src/main/generated</argument>
                <argument>${protobuf-java.string-version}</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <sourcepath>src/main/java;src/main/generated</sourcepath>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
