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

<!--
  ~ Copyright 2024-2025 gematik GmbH
  ~
  ~ 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.
  ~
  ~ *******
  ~
  ~ For additional notes and disclaimer from gematik and in case of changes by gematik find details in the "Readme" file.
  -->

<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">
  <parent>
    <artifactId>ncpeh-simulation-api-parent</artifactId>
    <groupId>de.gematik.api</groupId>
    <version>2.0.2</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>ncpeh-simulation-td-api</artifactId>
  <name>NCPeH Simulation Test Driver API</name>
  <description>API definition for the trigger interface of the NCPeH simulation</description>

  <properties>
    <api.config.dir>${project.build.directory}/config</api.config.dir>
    <api.config.filename>api_configuration.yaml</api.config.filename>
    <jar.excluded.source>de/gematik/ncpeh/build/**</jar.excluded.source>
    <javadoc.excluded.packages>de.gematik.ncpeh.build</javadoc.excluded.packages>
    <yaml.directory>${project.build.directory}/generated-sources/resources/openapi</yaml.directory>
    <yaml.filename>NCPeH_TriggerIF</yaml.filename>
    <yaml.zip.path>${project.build.directory}/${project.artifactId}-yaml.zip</yaml.zip.path>
  </properties>

  <dependencies>
    <dependency>
      <groupId>jakarta.ws.rs</groupId>
      <artifactId>jakarta.ws.rs-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-annotations-jakarta</artifactId>
    </dependency>
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-models-jakarta</artifactId>
    </dependency>
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-integration-jakarta</artifactId>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
    </dependency>

    <!-- Test -->

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <filtering>true</filtering>
        <targetPath>${api.config.dir}</targetPath>
        <directory>${project.basedir}</directory>
        <includes>
          <include>${api.config.filename}</include>
        </includes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>${jar.excluded.source}</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <excludePackageNames>${javadoc.excluded.packages}</excludePackageNames>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.spotify.fmt</groupId>
        <artifactId>fmt-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>process-classes</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}</outputDirectory>
              <resources>
                <resource>
                  <directory>${yaml.directory}</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-maven-plugin-jakarta</artifactId>
        <configuration>
          <configurationFilePath>${api.config.dir}/${api.config.filename}</configurationFilePath>
          <outputFileName>${yaml.filename}</outputFileName>
          <outputPath>${yaml.directory}</outputPath>
          <outputFormat>YAML</outputFormat>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>create-archive</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <zip destfile="${yaml.zip.path}" basedir="${yaml.directory}"/>
                <attachartifact file="${yaml.zip.path}" classifier="yaml" type="zip"/>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <!-- Exclude the Swagger-related class from the generated JAR -->
          <excludes>
            <exclude>${jar.excluded.source}</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>