<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (C) 2006-2022 Talend Inc. - www.talend.com
   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.talend.sdk.component</groupId>
    <artifactId>component-runtime</artifactId>
    <version>1.44.2</version>
  </parent>

  <artifactId>images</artifactId>
  <packaging>pom</packaging>

  <name>Component Runtime :: Images</name>

  <modules>
    <module>component-server-image</module>
    <module>component-starter-server-image</module>
    <module>component-server-vault-proxy-image</module>
    <module>remote-engine-customizer-image</module>
  </modules>

  <properties>
    <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
    <exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
    <dockerfile-maven-plugin.version>1.4.13</dockerfile-maven-plugin.version>
    <!-- -->
    <talend.server.image.registry/>
    <baseImageDir>/opt/talend</baseImageDir>
    <!-- ensure to use an image lib with glic -->
    <baseImage>tacokit/java8:8u212</baseImage>
    <!-- TSBI -->
    <docker.registryHost>artifactory.datapwn.com</docker.registryHost>
    <docker.tsbiPath>/tlnd-docker-prod/talend/common/tsbi</docker.tsbiPath>
    <docker.tsbiVersionRelease>2.9.27</docker.tsbiVersionRelease>
    <docker.tsbiVersionDate>20220331162145</docker.tsbiVersionDate>
    <docker.tsbiVersion>${docker.tsbiVersionRelease}-${docker.tsbiVersionDate}</docker.tsbiVersion>
    <disable.dockerBuild>false</disable.dockerBuild>
    <disable.tsbiLayerspector>false</disable.tsbiLayerspector>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.google.cloud.tools</groupId>
          <artifactId>jib-maven-plugin</artifactId>
          <version>${jib.version}</version>
        </plugin>
        <plugin>
          <groupId>com.spotify</groupId>
          <artifactId>dockerfile-maven-plugin</artifactId>
          <version>${dockerfile-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${build-helper-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>parse-version</id>
            <goals>
              <goal>parse-version</goal>
            </goals>
            <phase>initialize</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>dev-tsbi</id>
      <build>
        <plugins>
          <!-- layerspector to generate TSBI layers -->
          <!-- Local mode: use "mvn -P dev-tsbi ..." command line -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>${exec-maven-plugin.version}</version>
            <configuration>
              <executable>docker</executable>
              <arguments>
                <argument>run</argument>
                <argument>--rm</argument>
                <argument>-v</argument>
                <argument>${PWD}:/product</argument>
                <argument>-v</argument>
                <argument>${HOME}/.m2/settings.xml:/root/.m2/settings.xml</argument>
                <argument>-v</argument>
                <argument>${HOME}/.m2/repository:/root/.m2/repository</argument>
                <argument>-v</argument>
                <argument>/tmp/layerspector/logs:/opt/talend/logs</argument>
                <argument>${docker.registryHost}${docker.tsbiPath}/tools/layerspector:${docker.tsbiVersionRelease}-java-${docker.tsbiVersionDate}</argument>
                <argument>-t</argument>
                <argument>maven</argument>
                <argument>-f</argument>
                <argument>java</argument>
                <argument>-p</argument>
                <argument>${tsbi.product}</argument>
                <argument>-s</argument>
                <argument>${tsbi.service}</argument>
                <argument>--single-project</argument>
              </arguments>
              <skip>${disable.tsbiLayerspector}</skip>
            </configuration>
            <executions>
              <execution>
                <id>layerspector-local</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>ci-tsbi</id>
      <build>
        <plugins>
          <!-- layerspector in CI mode to generate TSBI layers -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>${exec-maven-plugin.version}</version>
            <configuration>
              <executable>/opt/talend/scripts/prepare_layers.sh</executable>
              <arguments>
                <argument>-t</argument>
                <argument>maven</argument>
                <argument>-f</argument>
                <argument>java</argument>
                <argument>-p</argument>
                <argument>${tsbi.product}</argument>
                <argument>-s</argument>
                <argument>${tsbi.service}</argument>
                <argument>--single-project</argument>
              </arguments>
              <skip>${disable.tsbiLayerspector}</skip>
            </configuration>
            <executions>
              <execution>
                <id>layerspector-ci</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
