<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>net.jakobarndt.bpmnbacklink</groupId>
        <artifactId>bpmn-backlink-parent</artifactId>
        <version>0.1.0</version>
    </parent>

    <artifactId>bpmn-backlink-maven-plugin</artifactId>
    <packaging>maven-plugin</packaging>

    <name>bpmn-backlink (maven-plugin)</name>
    <description>
        Maven plugin exposing the update and check goals that maintain @CalledFrom
        backlinks between BPMN service tasks and Java delegates.
    </description>

    <dependencies>
        <dependency>
            <groupId>net.jakobarndt.bpmnbacklink</groupId>
            <artifactId>bpmn-backlink-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <scope>provided</scope>
        </dependency>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <configuration>
                    <goalPrefix>bpmn-backlink</goalPrefix>
                </configuration>
                <executions>
                    <execution>
                        <id>default-descriptor</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>help-goal</id>
                        <goals>
                            <goal>helpmojo</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Real integration test: build this plugin, stage it into a local
                staging repository (invoker:install) and run the example projects
                under src/it as standalone Maven sub-builds (invoker:run). This
                exercises the plugin as an actual Maven goal, complementing the
                in-process unit test (BacklinkMojoTest).

                The example projects only reference artifacts that the reactor
                has already built and that invoker:install has staged into
                localRepositoryPath, so the integration test also works offline.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <projectsDirectory>src/it</projectsDirectory>
                    <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                    <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                    <!-- settingsFile is optional; only used if present. -->
                    <settingsFile>src/it/settings.xml</settingsFile>
                    <postBuildHookScript>verify</postBuildHookScript>
                    <streamLogs>true</streamLogs>
                    <showErrors>true</showErrors>
                    <!--
                        invoker:install stages the current reactor (this plugin
                        and bpmn-backlink-core). The example project also compiles
                        against the @CalledFrom annotation, which is not part of
                        this module's '-am' reactor, so stage it explicitly from
                        the local repository.
                    -->
                    <extraArtifacts>
                        <extraArtifact>net.jakobarndt.bpmnbacklink:bpmn-backlink-annotation:${project.version}</extraArtifact>
                    </extraArtifacts>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <!-- Stage this plugin (and its reactor deps) into the local staging repo. -->
                            <goal>install</goal>
                            <!-- Run the example projects against the staged plugin. -->
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
