<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright The ClusterBench Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->
<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.jboss.test</groupId>
        <artifactId>clusterbench</artifactId>
        <version>13.0.0.Final</version>
    </parent>

    <artifactId>clusterbench-ee10-ear</artifactId>
    <version>13.0.0.Final</version>
    <packaging>ear</packaging>

    <name>ClusterBench: EE 10 - EAR</name>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>clusterbench-ee10-ejb</artifactId>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>clusterbench-ee10-web</artifactId>
            <classifier>default</classifier>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>clusterbench-ee10-web</artifactId>
            <classifier>passivating</classifier>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>clusterbench-ee10</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <configuration>
                    <version>8</version>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                    <modules>
                        <ejbModule>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>clusterbench-ee10-ejb</artifactId>
                            <bundleFileName>clusterbench-ee10-ejb.jar</bundleFileName>
                        </ejbModule>
                        <webModule>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>clusterbench-ee10-web</artifactId>
                            <classifier>default</classifier>
                            <contextRoot>/clusterbench</contextRoot>
                            <bundleFileName>clusterbench-ee10-web.war</bundleFileName>
                        </webModule>
                        <webModule>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>clusterbench-ee10-web</artifactId>
                            <classifier>passivating</classifier>
                            <contextRoot>/clusterbench-passivating</contextRoot>
                            <bundleFileName>clusterbench-ee10-web-passivating.war</bundleFileName>
                        </webModule>
                    </modules>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <feature-packs>
                                <feature-pack>
                                    <location>org.wildfly:wildfly-galleon-pack:${version.org.wildfly}</location>
                                </feature-pack>
                            </feature-packs>
                            <layers>
                                <layer>jsf</layer>
                                <layer>ejb</layer>
                                <layer>web-clustering</layer>
                            </layers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- OpenShift will run the following with extra properties: "mvn -e -Popenshift -DskipTests -B package" -->
            <!-- See https://github.com/wildfly/wildfly-charts/blob/main/charts/wildfly/README.md -->
            <id>openshift</id>
            <build>
                <directory>../target</directory>
                <finalName>ROOT</finalName>
                <plugins>
                    <plugin>
                        <groupId>org.wildfly.plugins</groupId>
                        <artifactId>wildfly-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>openshift-build</id>
                                <goals>
                                    <goal>package</goal>
                                </goals>
                                <configuration>
                                    <skip>false</skip>
                                    <feature-packs>
                                        <feature-pack>
                                            <location>org.wildfly:wildfly-galleon-pack:${version.org.wildfly}</location>
                                        </feature-pack>
                                        <feature-pack>
                                            <location>org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.org.wildfly.cloud-feature-pack}</location>
                                        </feature-pack>
                                    </feature-packs>
                                    <layers>
                                        <layer>cloud-server</layer>
                                        <layer>jsf</layer>
                                        <layer>ejb</layer>
                                        <layer>web-clustering</layer>
                                    </layers>
                                    <filename>ROOT.ear</filename>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- shortens name of bundled JARs and WARs -->
            <!-- mvn clean install -P short-names -->
            <id>short-names</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-ear-plugin</artifactId>
                        <configuration>
                            <version>8</version>
                            <defaultLibBundleDir>lib</defaultLibBundleDir>
                            <modules>
                                <ejbModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-ejb</artifactId>
                                    <bundleFileName>clusterbench-ejb.jar</bundleFileName>
                                </ejbModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>default</classifier>
                                    <contextRoot>/clusterbench</contextRoot>
                                    <bundleFileName>a.war</bundleFileName>
                                </webModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>passivating</classifier>
                                    <contextRoot>/clusterbench-passivating</contextRoot>
                                    <bundleFileName>b.war</bundleFileName>
                                </webModule>
                            </modules>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- mvn clean install -P shared-sessions -->
            <id>shared-sessions</id>
            <build>
                <finalName>clusterbench-ee10</finalName>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/${project.build.finalName}/META-INF</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/shared-sessions/META-INF</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-ear-plugin</artifactId>
                        <configuration>
                            <version>8</version>
                            <defaultLibBundleDir>lib</defaultLibBundleDir>
                            <modules>
                                <ejbModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-ejb</artifactId>
                                </ejbModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>default</classifier>
                                    <bundleFileName>clusterbench-ee10-web-default.war</bundleFileName>
                                    <contextRoot>/clusterbench</contextRoot>
                                </webModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>default</classifier>
                                    <bundleFileName>clusterbench-ee10-web-default-1.war</bundleFileName>
                                    <contextRoot>/clusterbench-shared-sessions-1</contextRoot>
                                </webModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>default</classifier>
                                    <bundleFileName>clusterbench-ee10-web-default-2.war</bundleFileName>
                                    <contextRoot>/clusterbench-shared-sessions-2</contextRoot>
                                </webModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>passivating</classifier>
                                    <contextRoot>/clusterbench-passivating</contextRoot>
                                </webModule>
                            </modules>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- mvn clean install -P sso-form -->
            <id>sso-form</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-ear-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>clusterbench-sso-1</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>generate-application-xml</goal>
                                    <goal>ear</goal>
                                </goals>
                                <configuration>
                                    <finalName>${project.build.finalName}-1</finalName>
                                    <workDirectory>${project.build.directory}/${project.build.finalName}-1</workDirectory>
                                    <generatedDescriptorLocation>${project.build.directory}/${project.build.finalName}-1-tmp</generatedDescriptorLocation>
                                    <version>8</version>
                                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                                    <modules>
                                        <ejbModule>
                                            <groupId>${project.groupId}</groupId>
                                            <artifactId>clusterbench-ee10-ejb</artifactId>
                                        </ejbModule>
                                        <webModule>
                                            <groupId>${project.groupId}</groupId>
                                            <artifactId>clusterbench-ee10-web</artifactId>
                                            <classifier>default</classifier>
                                            <contextRoot>/clusterbench-sso-1</contextRoot>
                                        </webModule>
                                        <webModule>
                                            <groupId>${project.groupId}</groupId>
                                            <artifactId>clusterbench-ee10-web</artifactId>
                                            <classifier>passivating</classifier>
                                            <contextRoot>/clusterbench-passivating1</contextRoot>
                                        </webModule>
                                    </modules>
                                </configuration>
                            </execution>
                            <execution>
                                <id>clusterbench-sso-2</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>generate-application-xml</goal>
                                    <goal>ear</goal>
                                </goals>
                                <configuration>
                                    <finalName>${project.build.finalName}-2</finalName>
                                    <workDirectory>${project.build.directory}/${project.build.finalName}-2</workDirectory>
                                    <generatedDescriptorLocation>${project.build.directory}/${project.build.finalName}-2-tmp</generatedDescriptorLocation>
                                    <version>8</version>
                                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                                    <modules>
                                        <ejbModule>
                                            <groupId>${project.groupId}</groupId>
                                            <artifactId>clusterbench-ee10-ejb</artifactId>
                                        </ejbModule>
                                        <webModule>
                                            <groupId>${project.groupId}</groupId>
                                            <artifactId>clusterbench-ee10-web</artifactId>
                                            <classifier>default</classifier>
                                            <contextRoot>/clusterbench-sso-2</contextRoot>
                                        </webModule>
                                        <webModule>
                                            <groupId>${project.groupId}</groupId>
                                            <artifactId>clusterbench-ee10-web</artifactId>
                                            <classifier>passivating</classifier>
                                            <contextRoot>/clusterbench-passivating2</contextRoot>
                                        </webModule>
                                    </modules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- just contains the interfaces for acting as an EJB client -->
            <id>2clusters</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/${project.build.finalName}/META-INF</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/2clusters/META-INF</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>default</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-ear-plugin</artifactId>
                        <configuration>
                            <version>8</version>
                            <defaultLibBundleDir>lib</defaultLibBundleDir>
                            <modules>
                                <ejbModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-ejb</artifactId>
                                    <bundleFileName>clusterbench-ee10-ejb.jar</bundleFileName>
                                </ejbModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>default</classifier>
                                    <contextRoot>/clusterbench</contextRoot>
                                    <bundleFileName>clusterbench-ee10-web.war</bundleFileName>
                                </webModule>
                                <webModule>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>clusterbench-ee10-web</artifactId>
                                    <classifier>passivating</classifier>
                                    <excluded>true</excluded>
                                </webModule>
                            </modules>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
