
<!--

     Copyright 2005-2015 Red Hat, Inc.

     Red Hat licenses this file to you 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>io.fabric8.devops.apps</groupId>
    <artifactId>fabric8-devops</artifactId>
    <version>2.2.173</version>
  </parent>

  <artifactId>git-collector</artifactId>
  <packaging>jar</packaging>

  <name>Git Collector</name>
  <description>Collects events from git repositories from projects in OpenShift</description>

  <properties>
    <docker.from>docker.io/fabric8/java</docker.from>

    <docker.image>${fabric8.dockerUser}${project.artifactId}:${project.version}</docker.image>
    <docker.assemblyDescriptorRef>artifact-with-dependencies</docker.assemblyDescriptorRef>
    <docker.env.MAIN>org.jboss.weld.environment.se.StartMain</docker.env.MAIN>
    <docker.port.container.jolokia>8778</docker.port.container.jolokia>

    <fabric8.label.project>gitCollector</fabric8.label.project>
    <fabric8.label.provider>fabric8</fabric8.label.provider>

    <fabric8.serviceAccount>fabric8</fabric8.serviceAccount>
    <elasticsearch.host>http://elasticsearch.vagrant.f8</elasticsearch.host>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.fabric8</groupId>
        <artifactId>fabric8-project</artifactId>
        <version>${fabric8.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  

  <dependencies>
    <dependency>
      <groupId>io.fabric8.devops.apps</groupId>
      <artifactId>collector-utils</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jgit</groupId>
      <artifactId>org.eclipse.jgit</artifactId>
    </dependency>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>gitective-core</artifactId>
      <version>${gitective-version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.eclipse.jgit</groupId>
          <artifactId>org.eclipse.jgit</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jzlib</artifactId>
      <version>${jcraft-jzlib-version}</version>
    </dependency>

    <dependency>
      <groupId>org.jboss.weld.se</groupId>
      <artifactId>weld-se</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
    </dependency>


    <!-- testing -->
    <dependency>
    	<groupId>org.elasticsearch</groupId>
    	<artifactId>elasticsearch</artifactId>
    	<version>2.2.0</version>
      <scope>test</scope>
    </dependency>

    <!-- TODO no idea why the lucene dependencies are ancient for elasticsearch - lets override them! -->
    <dependency>
    	<groupId>org.apache.lucene</groupId>
    	<artifactId>lucene-core</artifactId>
    	<version>5.4.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>org.apache.lucene</groupId>
    	<artifactId>lucene-queryparser</artifactId>
    	<version>5.4.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>org.apache.lucene</groupId>
    	<artifactId>lucene-sandbox</artifactId>
    	<version>5.4.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>org.apache.lucene</groupId>
    	<artifactId>lucene-analyzers-common</artifactId>
    	<version>5.4.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.java.dev.jna</groupId>
      <artifactId>jna</artifactId>
      <version>4.1.0</version>
      <scope>test</scope>
    </dependency>


    <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>fabric8-arquillian</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-assertions</artifactId>
      <scope>test</scope>
    </dependency>

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

  <build>
    <finalName>${project.artifactId}</finalName>

    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>

    <plugins>
      <!-- Compiler plugin enforces Java 1.7 compatibility and activates annotation processors -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${version.compiler.plugin}</version>
        <configuration>
          <source>${maven.compiler.source}</source>
          <target>${maven.compiler.target}</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>${docker.maven.plugin.version}</version>
        <configuration>
          <images>
            <image>
              <name>${docker.image}</name>
              <build>
                <from>${docker.from}</from>
                <assembly>
                  <descriptorRef>${docker.assemblyDescriptorRef}</descriptorRef>
                </assembly>
                <env>
                  <MAIN>${docker.env.MAIN}</MAIN>
                  <SKIP_TLS_VERIFY>true</SKIP_TLS_VERIFY>
                </env>
                <ports>
                  <port>8778</port>
                </ports>
              </build>
            </image>
          </images>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
          <mainClass>${docker.env.MAIN}</mainClass>
          <includePluginDependencies>false</includePluginDependencies>

          <systemProperties>
            <systemProperty>
              <key>GIT_COLLECTOR_WORK_DIRECTORY</key>
              <value>${basedir}/target/gitCollectorWorkDir</value>
            </systemProperty>
            <systemProperty>
              <key>ELASTICSEARCH_HOST</key>
              <value>${elasticsearch.host}</value>
            </systemProperty>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>test</id>
      <properties>
        <skipTests>false</skipTests>
      </properties>
      <build>
        <defaultGoal>verify</defaultGoal>
      </build>
    </profile>

    <profile>
      <id>docker-build</id>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${docker.maven.plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>docker-push</id>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${docker.maven.plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                  <goal>push</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>jube</id>
      <activation>
        <property>
          <name>jube.plugin.enabled</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8.jube</groupId>
            <artifactId>jube-maven-plugin</artifactId>
            <version>${jube.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
