<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2014 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.switchyard.quickstarts</groupId>
        <artifactId>switchyard-quickstart-parent</artifactId>
        <version>2.0.0.Alpha2</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <groupId>org.switchyard.quickstarts.demos</groupId>
    <artifactId>switchyard-demo-helpdesk</artifactId>
    <packaging>war</packaging>
    <name>Quickstart Demo : Help Desk</name>
    <description>Quickstart Demo : Help Desk</description>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <distribution>repo</distribution>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
        </license>
    </licenses>
    <properties>
        <deploy.skip>true</deploy.skip>
        <maven.compiler.target>1.6</maven.compiler.target>
        <maven.compiler.source>1.6</maven.compiler.source>
        <switchyard.osgi.export.pkg>
            org.switchyard.quickstarts.demos.helpdesk*
        </switchyard.osgi.export.pkg>
        <switchyard.osgi.import>
            org.switchyard.*;${switchyard.osgi.import.switchyard.version},
            org.switchyard.annotations;${switchyard.osgi.import.switchyard.version},
            org.switchyard.component.bean;${switchyard.osgi.import.switchyard.version},
            org.switchyard.component.bpm.runtime;${switchyard.osgi.import.switchyard.version},
            javax.faces.event,
            javax.servlet,
            javax.servlet.http,
            javax.xml.transform,
            javax.xml.transform.dom,
            javax.xml.transform.stream,
            org.apache.log4j,
            org.drools.persistence.info,
            org.jbpm.executor.entities,
            org.jbpm.kie.services.impl.model,
            org.jbpm.persistence.correlation,
            org.jbpm.persistence.processinstance,
            org.jbpm.process.audit,
            org.jbpm.runtime.manager.impl.jpa,
            org.jbpm.services.task.audit.impl.model,
            org.jbpm.services.task.impl.model,
            org.jbpm.services.task.internals.lifecycle,
            org.jbpm.services.task.persistence,
            org.jbpm.services.task.query,
            org.kie.api.task.model,
            org.kie.internal.executor.api,
            org.kie.internal.task.api.model,
            org.w3c.dom,
            *
        </switchyard.osgi.import>
        <switchyard.osgi.require.capability>
            org.ops4j.pax.cdi.extension; filter:="(extension=switchyard-component-bean)",
            org.ops4j.pax.cdi.extension; filter:="(extension=deltaspike-core-api)",
            osgi.extender; filter:="(osgi.extender=pax.cdi)"
        </switchyard.osgi.require.capability>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-bean</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-bpm</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-soap</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Import the CDI API, we use provided scope as the API is included in JBoss AS 7 -->
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Import the Common Annotations API (JSR-250), we use provided scope as the API is included in JBoss AS 7 -->
        <dependency>
            <groupId>org.jboss.spec.javax.annotation</groupId>
            <artifactId>jboss-annotations-api_1.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Import the JSF API, we use provided scope as the API is included in JBoss AS 7 -->
        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-test-mixin-cdi</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-test-mixin-http</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <debug>true</debug>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-plugin</artifactId>
                <configuration>
                    <scannerClassNames>
                        <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                    </scannerClassNames>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>configure</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Generate bundle manifest for OSGi -->
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <supportedProjectTypes>
                        <supportedProjectType>war</supportedProjectType>
                    </supportedProjectTypes>
                    <instructions>
                        <Bundle-ClassPath>/WEB-INF/classes/</Bundle-ClassPath>
                        <Meta-Persistence>WEB-INF/classes/META-INF/persistence-osgi.xml</Meta-Persistence>
                    </instructions>
                    <rebuildBundle>true</rebuildBundle>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <packagingExcludes>
                        WEB-INF/lib/*.jar,
                        WEB-INF/classes/META-INF/switchyard.xml,
                        WEB-INF/classes/META-INF/MANIFEST.MF,
                        WEB-INF/classes/META-INF/beans.xml,
                        WEB-INF/classes/OSGI-INF/**
                    </packagingExcludes>
                    <webResources>
                        <resource>
                            <directory>target/classes/META-INF</directory>
                            <targetPath>WEB-INF</targetPath>
                            <includes>
                                <include>switchyard.xml</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>target/classes/META-INF</directory>
                            <targetPath>META-INF</targetPath>
                            <includes>
                                <include>beans.xml</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>target/classes/OSGI-INF</directory>
                            <targetPath>OSGI-INF</targetPath>
                        </resource>
                    </webResources>
                    <archive>
                        <!-- add the generated manifest to the war -->
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-jbpm-orm-files</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.jbpm</groupId>
                                    <artifactId>jbpm-human-task-audit</artifactId>
                                    <version>${version.org.drools}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.jbpm</groupId>
                                    <artifactId>${artifactId.jbpm-human-task-orm}</artifactId>
                                    <version>${version.org.drools}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.jbpm</groupId>
                                    <artifactId>jbpm-persistence-jpa</artifactId>
                                    <version>${version.org.drools}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.jbpm</groupId>
                                    <artifactId>jbpm-executor</artifactId>
                                    <version>${version.org.drools}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.jbpm</groupId>
                                    <artifactId>jbpm-kie-services</artifactId>
                                    <version>${version.org.drools}</version>
                                </artifactItem>
                            </artifactItems>
                            <includes>META-INF/*orm.xml</includes>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/jbpm</outputDirectory>
                            <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>deploy</id>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <configuration>
                            <filename>${project.build.finalName}.jar</filename>
                            <skip>${deploy.skip}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>undeploy</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>undeploy</goal>
                        </goals>
                        <configuration>
                            <filename>${project.build.finalName}.jar</filename>
                            <skip>${deploy.skip}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <configuration>
                    <executable>java</executable>
                    <classpathScope>test</classpathScope>
                    <mainClass>org.switchyard.quickstarts.demos.helpdesk.HelpDeskMain</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>deploy</id>
            <properties>
                <deploy.skip>false</deploy.skip>
            </properties>
        </profile>
        <profile>
            <id>helpdesk-profile-product</id>
            <activation>
                <property>
                    <name>switchyard.product</name>
                </property>
            </activation>
            <properties>
                <artifactId.jbpm-human-task-orm>jbpm-human-task-core</artifactId.jbpm-human-task-orm>
            </properties>
        </profile>
        <profile>
            <id>helpdesk-profile-community</id>
            <activation>
                <property>
                    <name>!switchyard.product</name>
                </property>
            </activation>
            <properties>
                <artifactId.jbpm-human-task-orm>jbpm-human-task-jpa</artifactId.jbpm-human-task-orm>
            </properties>
        </profile>
    </profiles>
</project>
