<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.quarkiverse.flow</groupId>
        <artifactId>quarkus-flow-core-parent</artifactId>
        <version>1.1.3</version>
    </parent>
    <artifactId>quarkus-flow-deployment</artifactId>
    <name>Quarkus Flow :: Core :: Deployment</name>

    <properties>
        <esbuild-maven-plugin.version>2.0.0</esbuild-maven-plugin.version>
        <react.version>19.3.0</react.version>
        <scheduler.version>0.28.0</scheduler.version>
        <openworkflowspec.diagram-editor.version>1.1.0</openworkflowspec.diagram-editor.version>
        <use-sync-external-store.version>1.7.0</use-sync-external-store.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-arc-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.flow</groupId>
            <artifactId>quarkus-flow</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.flow</groupId>
            <artifactId>quarkus-flow-dev</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-jackson-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-client-jackson-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.jackson-jq</groupId>
            <artifactId>quarkus-jackson-jq-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-proxy-registry</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-smallrye-fault-tolerance-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.flow</groupId>
            <artifactId>quarkus-flow-messaging-deployment</artifactId>
            <version>${project.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.github.zafarkhaja</groupId>
            <artifactId>java-semver</artifactId>
        </dependency>
        <dependency>
            <groupId>io.serverlessworkflow</groupId>
            <artifactId>serverlessworkflow-fluent-spec</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit-internal</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-vertx-http-deployment</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-jackson-deployment</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-devui-test-spi</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-micrometer-registry-prometheus</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.playwright</groupId>
            <artifactId>quarkus-playwright</artifactId>
            <version>${io.quarkiverse.playwright}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.smallrye</groupId>
            <artifactId>smallrye-fault-tolerance-standalone</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock</artifactId>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <!-- Do not copy the raw bundle source, esbuild will generate the compiled version -->
                    <exclude>dev-ui/bundle.js</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <configuration>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>io.quarkus</groupId>
                                    <artifactId>quarkus-extension-processor</artifactId>
                                    <version>${quarkus.version}</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <testExcludes>
                                <!--
                                    The docs/modules/ROOT/examples directory is added as an extra
                                    test source root (see build-helper-maven-plugin below) so that
                                    WorkflowDiagramEditorRoundTripTest can reference the canonical
                                    org.acme workflow classes directly — no copies needed.

                                    However, not every class in that directory can compile in the
                                    core/deployment module, which has no dependency on extension
                                    modules beyond what is already on its classpath.  The packages
                                    below are excluded from compilation for the following reasons:
                                -->
                                <!-- Requires generated Protobuf/gRPC stubs (quarkus-grpc) -->
                                <exclude>org/acme/grpc/**</exclude>
                                <!-- Requires quarkus-langchain4j-agentic and related AI dependencies -->
                                <exclude>org/acme/agentic/**</exclude>
                                <!-- Requires LangChain4j core + model dependencies -->
                                <exclude>org/acme/langchain4j/**</exclude>
                                <!-- TODO -->
                                <exclude>org/acme/bestpractices/**</exclude>
                                <!--
                                    test/** contains doc-level QuarkusTest classes (e.g.
                                    ConditionalWorkflowTest).  These use @QuarkusTest / WireMock
                                    fixtures that are only valid in their own module and must not
                                    be compiled or run here.
                                -->
                                <exclude>test/**</exclude>
                            </testExcludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Adds docs/modules/ROOT/examples as an extra test source directory so that
                 the canonical org.acme workflow classes from the documentation can be
                 referenced directly (live reference — no copy) in the Dev UI render tests.
                 Any breaking change to a doc workflow immediately fails the IT. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-docs-examples-test-sources</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>../../docs/modules/ROOT/examples</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>io.mvnpm</groupId>
                <artifactId>esbuild-maven-plugin</artifactId>
                <version>${esbuild-maven-plugin.version}</version>

                <executions>
                    <execution>
                        <id>esbuild</id>
                        <goals>
                            <goal>esbuild</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <sourceDirectory>src/main/resources/dev-ui</sourceDirectory>
                    <outputDirectory>target/classes/dev-ui</outputDirectory>
                    <entryPoint>bundle.js</entryPoint>
                </configuration>

                <dependencies>
                    <!-- OpenWorkflowSpec Diagram Editor (mvnpm) -->
                    <dependency>
                        <groupId>org.mvnpm.at.openworkflowspec</groupId>
                        <artifactId>diagram-editor</artifactId>
                        <version>${openworkflowspec.diagram-editor.version}</version>
                        <exclusions>
                            <!-- Required because @openworkflowspec/sdk is an npm dependency, not available on mvnpm as alpha version, but is already bundled in @openworkflowspec/diagram-editor's dist. -->
                            <exclusion>
                                <groupId>org.mvnpm.at.openworkflowspec</groupId>
                                <artifactId>sdk</artifactId>
                            </exclusion>
                            <!-- D3 is already bundled in @openworkflowspec/diagram-editor, avoid version conflicts for transitive D3 dependencies. -->
                            <exclusion>
                                <groupId>org.mvnpm</groupId>
                                <artifactId>d3-interpolate</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>

                    <!-- @openworkflowspec/diagram-editor peerDependency -->
                    <dependency>
                        <groupId>org.mvnpm</groupId>
                        <artifactId>react</artifactId>
                        <version>${react.version}</version>
                    </dependency>
                    <!-- @openworkflowspec/diagram-editor peerDependency -->
                    <dependency>
                        <groupId>org.mvnpm</groupId>
                        <artifactId>react-dom</artifactId>
                        <version>${react.version}</version>
                    </dependency>

                    <!-- Required by react-dom -->
                    <dependency>
                        <groupId>org.mvnpm</groupId>
                        <artifactId>scheduler</artifactId>
                        <version>${scheduler.version}</version>
                    </dependency>

                    <!-- Required because use-sync-external-store is kept external by @openworkflowspec/diagram-editor to avoid bundling it as CJS into the final Dev UI bundle. -->
                    <dependency>
                        <groupId>org.mvnpm</groupId>
                        <artifactId>use-sync-external-store</artifactId>
                        <version>${use-sync-external-store.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>
