{%- import 'util.jinja.include' as util -%}
{%- import 'cloudevents.jinja.include' as cloudEvents -%}
{%- set messagegroups = root.messagegroups %}
{%- set package_name = project_name | lower | replace('-', '_') %}
{%- set uses_cloudevents = cloudEvents.usesCloudEvents(root) -%}
{%- set uses_avro = (root | exists("dataschemaformat", "Avro")) -%}
{%- macro dep(name) -%}{{ dependency('java', 'jdk21', name) }}{%- endmacro -%}
<!-- This code was auto-generated by xRegistry CLI -->
<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>{{ package_name }}</groupId>
    <artifactId>servicebus-consumer</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>{{ project_name }} Service Bus Consumer</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
    </properties>

    {%- if uses_cloudevents or uses_avro %}
    <!-- Jackson BOM to enforce consistent versions across all transitive dependencies -->
    <dependencyManagement>
        <dependencies>
            {{ dep('jackson-bom') }}
        </dependencies>
    </dependencyManagement>
    {%- endif %}

    <dependencies>
        <!-- Azure Service Bus SDK -->
        {{ dep('azure-messaging-servicebus') }}

        <!-- Azure Identity for authentication -->
        {{ dep('azure-identity') }}

        <!-- Data model classes -->
        {%- set package_parts = (data_project_name | lower).split('.') %}
        {%- if package_parts | length > 1 %}
        {%- set data_groupid = package_parts[:-1] | join('.') %}
        {%- set data_artifactid = package_parts[-1] %}
        {%- else %}
        {%- set data_groupid = package_parts[0] %}
        {%- set data_artifactid = package_parts[0] %}
        {%- endif %}
        <dependency>
            <groupId>{{ data_groupid }}</groupId>
            <artifactId>{{ data_artifactid }}</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        {%- if uses_cloudevents %}
        <!-- CloudEvents SDK -->
        {{ dep('cloudevents-core') }}
        {%- endif %}

        <!-- Logging -->
        {{ dep('log4j-core') }}
        {{ dep('log4j-slf4j-impl') }}

        <!-- Testing -->
        {{ dep('org.junit.jupiter:junit-jupiter-api') }}
        {{ dep('org.junit.jupiter:junit-jupiter-engine') }}

        <!-- Testcontainers -->
        {{ dep('org.testcontainers:testcontainers') }}
        {{ dep('org.testcontainers:junit-jupiter') }}
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <!-- Allow more time for testcontainers to start -->
                    <forkedProcessExitTimeoutInSeconds>300</forkedProcessExitTimeoutInSeconds>
                    <forkCount>1</forkCount>
                    <reuseForks>false</reuseForks>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
