<?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>com.mulesoft.runtime.ang</groupId>
        <artifactId>mule-ang-introspection-service-parent</artifactId>
        <version>1.0.0</version>
    </parent>

    <artifactId>mule-ang-introspection-service-bechmark</artifactId>

    <name>Mule ANG introspection Service - Performance Bechmark</name>
    <description>Mule App introspector bechmark</description>
    
    <properties>
        <jmh.version>1.34</jmh.version>

        <formatterConfigPath>../formatter.xml</formatterConfigPath>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>properties</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>3.3.3</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
                <configuration>
                    <processors>
                        <processor>org.openjdk.jmh.generators.BenchmarkProcessor</processor>
                    </processors>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-Djmh.ignoreLock=true</argLine>
                    <systemPropertyVariables>
                        <contiperf.active>false</contiperf.active>
                        <enablePerformanceTests>false</enablePerformanceTests>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    <profiles>
        <profile>
            <id>performance</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>run-benchmarks</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <classpathScope>test</classpathScope>
                                    <executable>java</executable>
                                    <workingDirectory>${basedir}/target</workingDirectory>
                                    <arguments>
                                        <!-- Set system properties with locations of the sample apps -->
                                        <argument>-DschedulersSampleApp=${com.mulesoft.runtime.ang:schedulers-sample:jar:mule-application}</argument>
                                        <argument>-DschedulersWithPropertiesSampleApp=${com.mulesoft.runtime.ang:schedulers-with-properties-sample:jar:mule-application}</argument>
        
                                        <argument>-classpath</argument>
                                        <classpath/>
        
                                        <mainClass>org.openjdk.jmh.Main</mainClass>
                                        <!--Run only a certain class-->
                                        <argument>${jmh.benchmark}</argument>
                                        <!--Create json report-->
                                        <argument>-rf</argument>
                                        <argument>json</argument>
                                        <!--Number of Iterations-->
                                        <argument>-i</argument>
                                        <argument>10</argument>
                                        <!--Number of Warmup Iterations-->
                                        <argument>-wi</argument>
                                        <argument>10</argument>
                                        <!--Number of forks-->
                                        <argument>-f</argument>
                                        <argument>1</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>com.mulesoft.runtime.ang</groupId>
            <artifactId>mule-ang-introspection-service-introspector</artifactId>
            <version>${project.version}</version>
        </dependency>
    
        <dependency>
            <groupId>com.mulesoft.runtime.ang</groupId>
            <artifactId>mule-ang-introspection-service-introspector</artifactId>
            <version>${project.version}</version>
            <classifier>tests</classifier>
        </dependency>

        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>${jmh.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <version>${jmh.version}</version>
            <scope>provided</scope>
        </dependency>
        
        <dependency>
            <groupId>com.mulesoft.runtime.ang</groupId>
            <artifactId>schedulers-sample</artifactId>
            <version>${project.version}</version>
            <classifier>mule-application</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.runtime.ang</groupId>
            <artifactId>schedulers-with-properties-sample</artifactId>
            <version>${project.version}</version>
            <classifier>mule-application</classifier>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
