<?xml version="1.0" encoding="UTF-8"?>
<!--

  Copyright (C) 2022 eXo Platform SAS

   This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <gnu.org/licenses>.

-->
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>plf-public-distributions</artifactId>
    <groupId>org.exoplatform.platform.distributions</groupId>
    <version>7.1.2</version>
  </parent>
  <artifactId>plf-community-edition-service</artifactId>
  <packaging>jar</packaging>
  <name>eXo PLF:: Platform - Community Edition Information</name>

  <dependencies>
    <dependency>
      <groupId>io.meeds.kernel</groupId>
      <artifactId>exo.kernel.container</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.meeds.commons</groupId>
      <artifactId>commons-component-product</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.ecms</groupId>
      <artifactId>ecms-core-services</artifactId>
      <version>${addon.exo.ecms.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.meeds.distribution</groupId>
      <artifactId>plf-configuration</artifactId>
      <version>${io.meeds.distribution.version}</version>
      <scope>provided</scope>
    </dependency>
    <!--swagger-->
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-annotations-jakarta</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>plf-community-edition-service</finalName>
    <resources>
      <!-- Filtered resources -->
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*.properties</include>
        </includes>
        <excludes>
          <exclude>**/enterprise-configuration.properties</exclude>
        </excludes>
      </resource>
      <resource>
        <!-- Not filtered resources -->
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <excludes>
          <exclude>**/*.properties</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <!-- We want to use only the syntax @*@ to not be in conflict with the ${*} syntax used in kernel config file -->
          <useDefaultDelimiters>false</useDefaultDelimiters>
          <delimiters>
            <delimiter>@</delimiter>
          </delimiters>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.meeds.distribution</groupId>
                  <artifactId>plf-configuration</artifactId>
                  <type>jar</type>
                  <outputDirectory>${project.build.directory}/alternateDestination</outputDirectory>
                  <excludes>META-INF/</excludes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>concat-files</id>
            <phase>prepare-package</phase>
            <configuration>
              <target>
                <concat destfile="${project.build.directory}/classes/conf/platform/configuration.properties">
                  <fileset file="${project.build.directory}/alternateDestination/conf/platform/configuration.properties" />
                  <fileset file="${project.basedir}/src/main/resources/platform-community-configuration.properties" />
                </concat>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <execution>
            <id>copy-resources</id>
            <phase>prepare-package</phase>
            <configuration>
              <target>
                <copy todir="${project.build.directory}/classes/">
                  <fileset dir="${project.build.directory}/alternateDestination/">
                    <exclude name="${project.build.directory}/alternateDestination/conf/platform/configuration.properties" />
                  </fileset>
                </copy>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
