<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>multiverse-alpha</artifactId>
    <name>Alpha Multiverse STM engine</name>
    <description>
        Contains the main Multiverse STM Implementation: the Alpha Engine. The Alpha engine supports
        readonly and update transactions. It also supports the retry/or else mechanism.
    </description>
    <version>0.4</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.multiverse</groupId>
        <artifactId>multiverse</artifactId>
        <version>0.4</version>
    </parent>

    <properties>
        <multiverse.agentname>test-javaagent</multiverse.agentname>
        <multiverse.agentclass>org.multiverse.stms.alpha.instrumentation.MultiverseJavaAgent</multiverse.agentclass>
        <asm.version>3.2</asm.version>
    </properties>

    <build>
        <plugins>
            <!-- A plugin that creates alphaagent.jar so that the unit tests can be executed using the agent.
              This is done by creating a alphaagent.jar using the JAR plugin during the generate-test-resources phase. -->
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-javaagent</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <finalName>${multiverse.agentname}</finalName>
                            <archive>
                                <manifestEntries>
                                    <Premain-Class>${multiverse.agentclass}</Premain-Class>
                                </manifestEntries>
                            </archive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <groupId>org.apache.maven.plugins</groupId>
                <configuration>
                    <argLine>-javaagent:${project.build.directory}/${multiverse.agentname}.jar</argLine>
                </configuration>
            </plugin>

            <!-- plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Premain-Class>${multiverse.agentclass}</Premain-Class>
                        </manifestEntries>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>jar</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin -->

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifestEntries>
                            <Premain-Class>${multiverse.agentclass}</Premain-Class>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <!-- plugin that integrates the asm library in the alpha library-->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" />
                                <jarjar destfile="${build.directory}/${artifactId}-${version}.jar" update="true">
                                    <rule pattern="org.objectweb.asm.**" result="${groupId}.repackaged.@0" />
                                </jarjar>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.tonicsystems.jarjar</groupId>
                        <artifactId>jarjar</artifactId>
                        <version>1.0-rc8</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- Multiverse dependencies -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>multiverse-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>multiverse-benchy</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- we also want access to the jar containing the test code from the multiverse-core project -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>multiverse-core</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <!-- ASM dependencies -->
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>${asm.version}</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-tree</artifactId>
            <version>${asm.version}</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-analysis</artifactId>
            <version>${asm.version}</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-commons</artifactId>
            <version>${asm.version}</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-util</artifactId>
            <version>${asm.version}</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>stress</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>-javaagent:${project.build.directory}/${multiverse.agentname}.jar</argLine>
                            <includes>
                                <include>**/*LongTest.java</include>
                            </includes>
                            <argLine>-Xmx256m</argLine>
                            <forkMode>once</forkMode>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
