<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors.
-
- Licensed under the Apache License, Version 2.0 (the "License")
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-->
<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">
    <parent>
        <groupId>org.switchyard</groupId>
        <artifactId>switchyard-wildfly-parent</artifactId>
        <version>2.0.1.redhat-621117</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>switchyard-wildfly-dist</artifactId>
    <packaging>jar</packaging>
    <name>SwitchYard: Wildfly Distribution</name>
    <description>SwitchYard Wildfly Distribution</description>
    <properties>
        <staging.dir>${project.build.directory}/jboss-switchyard</staging.dir>
        <wildfly.dir>wildfly-${version.wildfly}</wildfly.dir>
        <staging.jboss.dir>${staging.dir}/${wildfly.dir}</staging.jboss.dir>
        <staging.configs.dir>${staging.dir}/configs</staging.configs.dir>
        <distro.file>switchyard-${project.version}-WildFly</distro.file>
        <distro.root.dir>/</distro.root.dir>
        <installer.root.dir>/switchyard-wildfly-installer-${version.distro}</installer.root.dir>
        <switchyard.wildfly.home>${staging.jboss.dir}</switchyard.wildfly.home>
        <zip.file.name>${distro.file}.zip</zip.file.name>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-wildfly-bundle</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-dist</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-test-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.descriptors</groupId>
            <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-arquillian-container-managed</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-arquillian-common</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- CXF client dependencies -->
        <dependency>
            <groupId>org.jboss.ws.cxf</groupId>
            <artifactId>jbossws-cxf-client</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.ws.cxf</groupId>
            <artifactId>jbossws-cxf-factories</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.ws.cxf</groupId>
            <artifactId>jbossws-cxf-transports-httpserver</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-bindings-soap</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-bindings-xml</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-databinding-jaxb</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-hl7</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-mina2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.xmlschema</groupId>
            <artifactId>xmlschema-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.picketlink</groupId>
            <artifactId>picketlink-federation</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>stage-jboss</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-dist</artifactId>
                                    <type>zip</type>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${staging.dir}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stage-jboss-configs</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-dist</artifactId>
                                    <type>zip</type>
                                    <overWrite>true</overWrite>
                                </artifactItem>
                            </artifactItems>
                            <includes>${wildfly.dir}/standalone/configuration/standalone.xml, ${wildfly.dir}/standalone/configuration/standalone-full.xml, ${wildfly.dir}/standalone/configuration/standalone.xml, ${wildfly.dir}/standalone/configuration/standalone-ha.xml, ${wildfly.dir}/standalone/configuration/standalone.xml, ${wildfly.dir}/standalone/configuration/standalone-full-ha.xml,${wildfly.dir}/domain/configuration/domain.xml</includes>
                            <outputDirectory>${staging.configs.dir}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-bundle</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.switchyard</groupId>
                                    <artifactId>switchyard-wildfly-bundle</artifactId>
                                    <type>zip</type>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${staging.jboss.dir}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-tests</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.switchyard</groupId>
                                    <artifactId>switchyard-as7-tests</artifactId>
                                    <type>test-jar</type>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <excludes>application-roles.properties, application-users.properties</excludes>
                            <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-users</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.switchyard</groupId>
                                    <artifactId>switchyard-as7-tests</artifactId>
                                    <type>test-jar</type>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <includes>application-roles.properties, application-users.properties</includes>
                            <outputDirectory>${staging.jboss.dir}/standalone/configuration</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xml-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>transform</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <forceCreation>true</forceCreation>
                    <transformationSets>
                        <transformationSet>
                            <dir>${staging.configs.dir}/${wildfly.dir}/standalone/configuration</dir>
                            <includes>
                                <include>standalone.xml</include>
                                <include>standalone-ha.xml</include>
                                <include>standalone-full-ha.xml</include>
                                <include>standalone-full.xml</include>
                            </includes>
                            <outputDir>${staging.jboss.dir}/standalone/configuration</outputDir>
                            <stylesheet>${staging.jboss.dir}/xsl/standalone.xsl</stylesheet>
                        </transformationSet>
                        <transformationSet>
                            <dir>${staging.jboss.dir}/standalone/configuration</dir>
                            <includes>
                                <include>standalone-ha.xml</include>
                                <include>standalone-full-ha.xml</include>
                            </includes>
                            <outputDir>${staging.jboss.dir}/standalone/configuration</outputDir>
                            <stylesheet>${staging.jboss.dir}/xsl/standalone-ha.xsl</stylesheet>
                        </transformationSet>
                        <transformationSet>
                            <dir>${staging.configs.dir}/${wildfly.dir}/domain/configuration</dir>
                            <includes>
                                <include>domain.xml</include>
                            </includes>
                            <outputDir>${staging.jboss.dir}/domain/configuration</outputDir>
                            <stylesheet>${staging.jboss.dir}/xsl/domain.xsl</stylesheet>
                        </transformationSet>
                    </transformationSets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>assembly-dist</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <finalName>${distro.file}</finalName>
                            <descriptors>
                                <descriptor>${basedir}/assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Configure the Surefire plugin for running the tests.  Be sure to make these same setting if running in your IDE... -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-Xms512m -Xmx512m</argLine>
                    <forkMode>always</forkMode>
                    <environmentVariables>
                        <JBOSS_HOME>${wildfly.home}</JBOSS_HOME>
                        <SWITCHYARD_VERSION>${project.version}</SWITCHYARD_VERSION>
                    </environmentVariables>
                    <systemPropertyVariables>
                        <arquillian.launch>jboss</arquillian.launch>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <jboss.home>${wildfly.home}</jboss.home>
                        <module.path>${wildfly.home}/modules</module.path>
                        <jboss.options>-Xms256m -Xmx1024m -XX:MaxPermSize=512m</jboss.options>
                    </systemPropertyVariables>
                    <redirectTestOutputToFile>false</redirectTestOutputToFile>
                    <excludes>
                        <exclude>**/*$*</exclude>
                        <exclude>**/RemoteInvokerQuickstartTest*</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <property>
                    <name>!wildfly.home</name>
                </property>
            </activation>
            <properties>
                <wildfly.home>${switchyard.wildfly.home}</wildfly.home>
            </properties>
        </profile>
        <profile>
            <id>manual</id>
            <activation>
                <property>
                    <name>wildfly.home</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare</id>
                                <phase>process-test-resources</phase>
                                <configuration>
                                    <tasks>
                                        <unzip dest="${wildfly.home}" src="${project.build.directory}/${zip.file.name}"/>
                                        <copy file="${staging.jboss.dir}/standalone/configuration/application-users.properties" todir="${wildfly.home}/standalone/configuration"/>
                                        <copy file="${staging.jboss.dir}/standalone/configuration/application-roles.properties" todir="${wildfly.home}/standalone/configuration"/>
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
