<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2013 Cloudera Inc. 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>
  <parent>
    <groupId>org.kitesdk</groupId>
    <artifactId>kite-morphlines</artifactId>
    <version>0.17.0</version>
  </parent>
  <artifactId>kite-morphlines-protobuf</artifactId>

  <properties>
    <vers.protobuf>2.5.0</vers.protobuf>
  </properties>

  <dependencies>

    <dependency>
      <groupId>org.kitesdk</groupId>
      <artifactId>kite-morphlines-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.kitesdk</groupId>
      <artifactId>kite-morphlines-core</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency> <!-- see http://www.slf4j.org -->
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>${vers.protobuf}</version>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-test-env</id>
            <phase>process-test-resources</phase>
            <configuration>
              <target>
                <copy todir="${project.build.directory}/test-classes">
                  <fileset dir="${basedir}/../kite-morphlines-core/src/test/resources" />
                </copy>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/generated-test-sources</source>
              </sources>
              <jdkLevel>1.6</jdkLevel>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <profiles>
    <profile>
      <id>regenerateProtobufTestClass</id>
      <build>
        <pluginManagement>
          <plugins>

            <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <executions>
                <execution>
                  <id>generate-test-sources</id>
                  <phase>generate-test-sources</phase>
                  <configuration>
                    <target>
                      <mkdir dir="${basedir}/generated-test-sources" />
                      <exec executable="protoc">
                        <arg value="--java_out=${basedir}/generated-test-sources" />
                        <arg value="src/test/resources/test-protos/protos.proto" />
                      </exec>
                      <move file="${basedir}/generated-test-sources/org/kitesdk/morphline/protobuf/Protos.java" toFile="${basedir}/generated-test-sources/org/kitesdk/morphline/protobuf/Protos.tmp" />
                      <concat destfile="${basedir}/generated-test-sources/org/kitesdk/morphline/protobuf/Protos.java">
                        <fileset file="${basedir}/src/test/resources/license-header.txt" />
                        <fileset file="${basedir}/generated-test-sources/org/kitesdk/morphline/protobuf/Protos.tmp" />
                      </concat>
                      <delete file="${basedir}/generated-test-sources/org/kitesdk/morphline/protobuf/Protos.tmp" />
                    </target>
                  </configuration>
                  <goals>
                    <goal>run</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>

          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>
</project>