<?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>
  <groupId>\${groupId}</groupId>
  <artifactId>\${artifactId}</artifactId>
  <version>\${version}</version>
  <packaging>jar</packaging>
  <name>\${artifactId}</name>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>\${springbootVersion}</version>
  </parent>

  <properties>
    <version.org.kie>${kieVersion}</version.org.kie>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <narayana.version>5.9.0.Final</narayana.version>
    <fabric8.version>3.5.40</fabric8.version>
  </properties>

  <dependencies>
    KIE_SPRING_BOOT_STARTER_MARKER
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        REMOTE_DEBUG_MARKER
      </plugin>
    </plugins>
  </build>

  <profiles>  
    DB_PROFILES_MARKER        
    <profile>
      <id>docker</id>
      <activation>
        <property>
          <name>docker</name>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric8-maven-plugin</artifactId>
            <version>${fabric8.version}</version>
            <configuration>
              <verbose>false</verbose>
              <images>
                <image>
                  <name>apps/\${project.artifactId}:\${project.version}</name>
                  <build>
                    <from>fabric8/java-jboss-openjdk8-jdk</from>
                    <assembly>
                      <targetDir>/</targetDir>
                      <inline>
                        <files>
                          <file>
                            <source>\${project.build.directory}/\${project.build.finalName}.\${project.packaging}</source>
                            <outputDirectory>deployments</outputDirectory>
                            <destName>\${project.build.finalName}.\${project.packaging}</destName>
                          </file>
                          <file>
                            <source>\${project.artifactId}.xml</source>
                            <outputDirectory>deployments</outputDirectory>
                            <destName>\${project.artifactId}.xml</destName>
                          </file>
                        </files>
                        <fileSet>
                          <directory>src/main/docker</directory>
                          <outputDirectory>opt/jboss/.m2</outputDirectory>
                          <includes>
                            <include>settings.xml</include>
                          </includes>
                        </fileSet>
                        <fileSet>
                          <directory>../\${kjarArtifactId}/target/local-repository/maven</directory>
                          <outputDirectory>opt/jboss/.m2/repository</outputDirectory>        
                        </fileSet>
                      </inline>
                      <user>jboss:jboss:jboss</user>
                    </assembly>
                  </build>
                </image>
              </images>
            </configuration>
            <executions>
              <execution>
                <phase>install</phase>
                <goals>
                  <goal>resource</goal>
                  <goal>build</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>openshift</id>
      <activation>
        <property>
          <name>openshift</name>
        </property>
      </activation>

      <properties>
        <fabric8.mode>openshift</fabric8.mode>
        <fabric8.build.strategy>docker</fabric8.build.strategy>
      </properties>

      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric8-maven-plugin</artifactId>
            <version>${fabric8.version}</version>
            <configuration>
              <verbose>false</verbose>
              <images>
                <image>
                  <name>apps/\${project.artifactId}:\${project.version}</name>
                  <build>
                    <from>fabric8/java-jboss-openjdk8-jdk</from>
                    <assembly>
                      <targetDir>/</targetDir>
                      <inline>
                        <files>
                          <file>
                            <source>\${project.build.directory}/\${project.build.finalName}.\${project.packaging}</source>
                            <outputDirectory>deployments</outputDirectory>
                            <destName>\${project.build.finalName}.\${project.packaging}</destName>
                          </file>
                          <file>
                            <source>\${project.artifactId}.xml</source>
                            <outputDirectory>deployments</outputDirectory>
                            <destName>\${project.artifactId}.xml</destName>
                          </file>
                        </files>
                        <fileSet>
                          <directory>src/main/docker</directory>
                          <outputDirectory>opt/jboss/.m2</outputDirectory>
                          <includes>
                            <include>settings.xml</include>
                          </includes>
                        </fileSet>
                        <fileSet>
                          <directory>../\${kjarArtifactId}/target/local-repository/maven</directory>
                          <outputDirectory>opt/jboss/.m2/repository</outputDirectory>        
                        </fileSet>
                      </inline>
                      <user>jboss:jboss:jboss</user>
                    </assembly>
                    <ports>
                      <port>${appServerPort}</port>
                    </ports>
                  </build>
                </image>
              </images>
            </configuration>
            <executions>
              <execution>
                <phase>install</phase>
                <goals>
                  <goal>resource</goal>
                  <goal>build</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <repositories>    
    <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>https://repository.jboss.org/nexus/content/groups/public/</url>
      <layout>default</layout>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <updatePolicy>daily</updatePolicy>
      </snapshots>
    </repository>
  </repositories>
</project>
