<?xml version="1.0" encoding="UTF-8"?>
<!--
/*********************************************************************
* Copyright (c) 2022 Kentyou and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.eclipse.sensinact.gateway.distribution</groupId>
    <artifactId>distribution</artifactId>
    <version>0.0.2-SNAPSHOT</version>
  </parent>
  <groupId>org.eclipse.sensinact.gateway.distribution.features</groupId>
  <artifactId>features</artifactId>
  <version>0.0.2-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>Eclipse sensiNact Features</name>
  <description>This project contains definitions of sensiNact features</description>
  <licenses>
    <license>
      <name>EPL 2.0</name>
      <url>http://www.eclipse.org/legal/epl-2.0</url>
      <distribution>repo</distribution>
      <comments>Except for 3rd party content and examples.</comments>
    </license>
  </licenses>
  <modules>
    <module>gogo-shell-feature</module>
    <module>core-feature</module>
    <module>jakarta-servlet-whiteboard-feature</module>
    <module>jakarta-rest-whiteboard-feature</module>
    <module>northbound-rest-feature</module>
    <module>northbound-websocket-feature</module>
    <module>northbound-ogc-sensorthings-feature</module>
    <module>northbound-ogc-sensorthings-mqtt-feature</module>
    <module>virtual-temperature-sensor-feature</module>
    <module>timescale-history-provider-feature</module>
    <module>northbound-oidc-authenticator-feature</module>
  </modules>
  <properties>
    <gateway.version>${project.version}</gateway.version>
    <launcher.version>${project.version}</launcher.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.eclipse.sensinact.gateway.distribution</groupId>
      <artifactId>test-utils</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <resources>
      <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>testCompile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <id>create-feature-repo</id>
              <phase>prepare-package</phase>
              <goals>
                <goal>copy-dependencies</goal>
              </goals>
              <configuration>
                <excludeTransitive>true</excludeTransitive>
                <includeScope>runtime</includeScope>
                <useRepositoryLayout>true</useRepositoryLayout>
                <outputDirectory>${project.build.directory}/repository</outputDirectory>
              </configuration>
            </execution>
            <execution>
              <id>copy-test-launcher</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>copy</goal>
              </goals>
              <configuration>
                <outputDirectory>${project.build.directory}/it</outputDirectory>
                <artifactItems>
                  <artifactItem>
                    <groupId>org.eclipse.sensinact.gateway.distribution</groupId>
                    <artifactId>launcher</artifactId>
                    <version>${launcher.version}</version>
                    <type>jar</type>
                    <classifier>export</classifier>
                    <destFileName>launcher.jar</destFileName>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
            <execution>
              <id>gather-test-features</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>copy</goal>
              </goals>
              <configuration>
                <outputDirectory>${project.build.directory}/it/features</outputDirectory>
                <skip>true</skip>
              </configuration>
            </execution>
            <execution>
              <id>create-test-repo</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>unpack</goal>
              </goals>
              <configuration>
                <outputDirectory>${project.build.directory}/it/repository</outputDirectory>
                <skip>true</skip>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
            <execution>
              <id>create-repository-zip</id>
              <phase>package</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <target>
                  <zip basedir="${project.build.directory}/repository" destfile="${project.build.directory}/repository.zip" />
                </target>
              </configuration>
            </execution>
            <execution>
              <id>copy-artifact-for-testing</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <target>
                  <unzip src="${project.build.directory}/repository.zip" dest="${project.build.directory}/it/repository/" />
                  <copy todir="${project.build.directory}/it/features/">
                    <fileset includes="*.json" dir="${project.build.directory}/generated/features/" />
                  </copy>
                </target>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>attach-artifacts</id>
              <phase>package</phase>
              <goals>
                <goal>attach-artifact</goal>
              </goals>
              <configuration>
                <artifacts>
                  <artifact>
                    <file>${project.build.directory}/repository.zip</file>
                    <type>zip</type>
                    <classifier>osgifeaturerepo</classifier>
                  </artifact>
                  <artifact>
                    <file>${project.build.directory}/generated/features/${project.artifactId}.json</file>
                    <type>json</type>
                    <classifier>osgifeature</classifier>
                  </artifact>
                </artifacts>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated/features/</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>