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

  <artifactId>openrtb-core</artifactId>
  <packaging>jar</packaging>
  <name>Google OpenRTB Core</name>

  <parent>
    <groupId>com.google.openrtb</groupId>
    <artifactId>openrtb-parent</artifactId>
    <version>2.0.2</version>
  </parent>

  <dependencies>
    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <version>${injectVersion}</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>${findBugsJsr305Version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>${protobufVersion}</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guavaVersion}</version>
    </dependency>
    <dependency>
      <groupId>io.dropwizard.metrics</groupId>
      <artifactId>metrics-core</artifactId>
      <version>${metricsVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4jVersion}</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junitVersion}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <version>${truthVersion}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-jdk14</artifactId>
      <version>${slf4jVersion}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/protobuf</directory>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>default</id>
            <phase>generate-sources</phase>
            <goals><goal>add-source</goal></goals>
            <configuration>
              <sources>
                <source>${protobufGenerated}</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>test</id>
            <phase>generate-test-sources</phase>
            <goals><goal>add-test-source</goal></goals>
            <configuration>
              <sources>
                <source>${testProtobufGenerated}</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <configuration>
          <format>xml</format>
          <format>html</format>
          <instrumentation>
            <excludes>
              <exclude>com/google/openrtb/OpenRtb.class</exclude>
              <exclude>com/google/openrtb/OpenRtb$*.class</exclude>
              <exclude>com/google/openrtb/OpenRtbNative.class</exclude>
              <exclude>com/google/openrtb/OpenRtbNative$*.class</exclude>
              <exclude>com/google/openrtb/json/CharSequenceReader.class</exclude>
            </excludes>
          </instrumentation>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>full</id>
      <activation>
        <property>
          <name>!m2e.version</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>compile-protoc</id>
                <phase>generate-sources</phase>
                <configuration>
                  <target>
                    <mkdir dir="${protobufGenerated}" />
                    <path id="proto.path">
                      <fileset dir="${protobufSource}">
                        <include name="**/*.proto" />
                      </fileset>
                    </path>
                    <pathconvert pathsep=" " property="proto.files" refid="proto.path" />
                    <exec executable="protoc" failonerror="true">
                      <arg value="--java_out=${protobufGenerated}" />
                      <arg value="-I${protobufSource}" />
                      <arg line="${proto.files}" />
                    </exec>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
              <execution>
                <id>compile-protoc-test</id>
                <phase>generate-test-sources</phase>
                <configuration>
                  <target>
                    <mkdir dir="${testProtobufGenerated}" />
                    <path id="proto.path">
                      <fileset dir="${testProtobufSource}">
                        <include name="**/*.proto" />
                      </fileset>
                    </path>
                    <pathconvert pathsep=" " property="proto.files" refid="proto.path" />
                    <exec executable="protoc" failonerror="true">
                      <arg value="--java_out=${testProtobufGenerated}" />
                      <arg value="-I${protobufSource}" />
                      <arg value="-I${testProtobufSource}" />
                      <arg line="${proto.files}" />
                    </exec>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
