<?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.mostlyoriginal.artemis-odb</groupId>
        <artifactId>contrib-parent</artifactId>
        <version>2.5.0</version>
    </parent>

    <properties>
        <graftt.version>0.3.0</graftt.version>
        <graftt.agent>${project.build.directory}/agent.jar</graftt.agent>
        <graftt.transplants>
            ${project.basedir}/../contrib-plugin-lifecycle-transplants/target/classes/
        </graftt.transplants>
    </properties>

    <artifactId>contrib-plugin-debug</artifactId>
    <packaging>jar</packaging>
    <description>
        Can log entity lifecycle events like create, delete.
        Can also log errors (accessing/deleting already deleted entities) and report a stacktrace to the cause.
    </description>

    <dependencies>
        <dependency>
            <groupId>net.onedaybeard.artemis</groupId>
            <artifactId>artemis-odb</artifactId>
        </dependency>
        <dependency>
            <groupId>net.mostlyoriginal.artemis-odb</groupId>
            <artifactId>contrib-plugin-lifecycle-listener</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>download-graftt-agent-and-transplants</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>net.onedaybeard.graftt</groupId>
                                    <artifactId>agent</artifactId>
                                    <version>${graftt.version}</version>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <destFileName>agent.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <argLine>-javaagent:${graftt.agent}=cp=${graftt.transplants}</argLine>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
