<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2010-2026. Axon Framework
  ~
  ~ 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.
  -->

<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>
    <parent>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-parent</artifactId>
        <version>5.4.1</version>
        <relativePath>../build/parent/pom.xml</relativePath>
    </parent>

    <artifactId>axon-migration</artifactId>

    <name>Axon Framework - Migration</name>
    <description>
        OpenRewrite recipes for migrating Axon Framework applications from 4.x to 5.x.
    </description>

    <properties>
        <!-- The AF4 recipe tests are skipped when either the standard `skipTests`
             flag or the dedicated `skipAf4RecipeTests` flag is true. Defaulting
             `skipAf4RecipeTests` to `${skipTests}` lets a plain `-DskipTests`
             (or the IDE "Skip Tests" toggle) skip them like any other module,
             while `-DskipAf4RecipeTests=true` remains available to skip *only*
             these tests (and the AF4 stub download), e.g. during release,
             without skipping the rest of the build. If `skipTests` is unset the
             expression stays unresolved and parses as `false`, so tests run. -->
        <skipAf4RecipeTests>${skipTests}</skipAf4RecipeTests>
        <!-- Upgrading org.openrewrite.recipe:rewrite-recipe-bom from 3.37.0 to 3.38.0 crosses the OpenRewrite
             Code Genome Project migration. The BOM itself remains available from Maven Central, but its newer managed
             OpenRewrite artifacts require resolution from the Code Genome Project.
             We need to adjust our maven configuration, see https://github.com/AxonIQ/AxonFramework/issues/4990 -->
        <rewrite-recipe-bom.version>3.37.0</rewrite-recipe-bom.version>
        <!-- Axon Framework 4.x version used to resolve types in recipe tests
             (the rename recipes match AF4 fully-qualified names, so the test
             parser needs the AF4 classpath to produce a typed LST). -->
        <axon4.version>4.13.2</axon4.version>
        <!-- Axoniq Framework 5 (commercial) target version, used for every
             `io.axoniq.framework` coordinate the recipes add or pin. The free
             Axon Framework 5 target is `${project.version}` (inherited from the
             root `5.4.1`). Axoniq Framework is released in lockstep with
             Axon Framework (its BOM imports the Axon Framework BOM of the same
             version), so this follows `${project.version}` rather than holding a
             literal that goes stale with every release. Mixing the two lines
             leaves a migrated project with two different Axon Framework versions
             on its classpath. -->
        <axoniq.version>${project.version}</axoniq.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.openrewrite.recipe</groupId>
                <artifactId>rewrite-recipe-bom</artifactId>
                <version>${rewrite-recipe-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.openrewrite</groupId>
            <artifactId>rewrite-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openrewrite</groupId>
            <artifactId>rewrite-kotlin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openrewrite</groupId>
            <artifactId>rewrite-maven</artifactId>
        </dependency>
        <!-- Pulls in `org.openrewrite.java.dependencies.UpgradeDependencyVersion`,
             the multi-build-tool (Maven + Gradle) entrypoint we compose in
             `UpgradeKotlin`. The artifact is on the runtime classpath via
             `rewrite-maven`, but composing it from Java sources needs it at
             compile scope. -->
        <dependency>
            <groupId>org.openrewrite.recipe</groupId>
            <artifactId>rewrite-java-dependencies</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openrewrite</groupId>
            <artifactId>rewrite-yaml</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openrewrite</groupId>
            <artifactId>rewrite-properties</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openrewrite.recipe</groupId>
            <artifactId>rewrite-migrate-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openrewrite.recipe</groupId>
            <artifactId>rewrite-spring</artifactId>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.openrewrite</groupId>
            <artifactId>rewrite-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--
                Axon Framework 4.x type stubs for recipe tests. The stubs share the
                org.axonframework groupId with reactor modules at a different version.
                Maven Release Plugin 3.x scans the raw POM model (before profile
                activation) for <dependency> elements, so profile-based hiding no
                longer works. Downloading via maven-dependency-plugin:copy puts the
                coordinates in a <configuration> block that the release plugin's
                version-consistency scanner does not inspect.

                Pass -DskipAf4RecipeTests to skip the download (and the tests that
                need these JARs) during release or when a fast build is desired.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-af4-stubs</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <skip>${skipAf4RecipeTests}</skip>
                            <outputDirectory>${project.build.directory}/af4-stubs</outputDirectory>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-messaging</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-configuration</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-modelling</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-eventsourcing</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-spring</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-test</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-micrometer</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.axonframework</groupId>
                                    <artifactId>axon-server-connector</artifactId>
                                    <version>${axon4.version}</version>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>${skipAf4RecipeTests}</skipTests>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-messaging-${axon4.version}.jar</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-configuration-${axon4.version}.jar</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-modelling-${axon4.version}.jar</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-eventsourcing-${axon4.version}.jar</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-spring-${axon4.version}.jar</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-test-${axon4.version}.jar</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-micrometer-${axon4.version}.jar</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/af4-stubs/axon-server-connector-${axon4.version}.jar</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <!-- Filter rewrite recipe YAMLs so they can interpolate ${project.version}
                 (the AF5 free target, derived from <revision>) and ${axoniq.version}
                 (the AF5 commercial target). -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>META-INF/rewrite/**</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>META-INF/rewrite/**</exclude>
                </excludes>
            </resource>
        </resources>
        <testResources>
            <!-- Filter `migration-versions.properties` so recipe tests can assert
                 against the same target versions the filtered recipe YAMLs inject
                 (keeping these values defined in exactly one place: the parent's
                 <revision> and the <axoniq.version> property above). -->
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>migration-versions.properties</include>
                </includes>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>migration-versions.properties</exclude>
                </excludes>
            </testResource>
        </testResources>
    </build>
</project>
