<?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">


    <parent>
        <groupId>org.wso2.carbon.business-process</groupId>
        <artifactId>bpmn-feature</artifactId>
        <version>4.5.49</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>org.wso2.carbon.bpmn.server.feature</artifactId>
    <packaging>pom</packaging>
    <name>WSO2 Carbon - BPMN Server - Core Feature</name>
    <url>http://wso2.org</url>
    <description>This feature contains the core bundles required for Back-end BPMN Server
        functionality
    </description>

    <dependencies>
        <dependency>
            <groupId>org.wso2.carbon.business-process</groupId>
            <artifactId>org.wso2.carbon.bpmn</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.business-process</groupId>
            <artifactId>org.wso2.carbon.bpmn.extensions</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>clean-bpmn-h2-database</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <delete file="resources/conf/activiti.mv.db" />
                            </tasks>
                        </configuration>
                    </execution>
                    <execution>
                        <id>create-bpel-h2-database</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <path id="h2.classpath">
                                    <path refid="maven.compile.classpath" />
                                </path>

                                <echo message="########### Create Activiti Database ##############" />

                                <sql driver="org.h2.Driver" url="jdbc:h2:${basedir}/resources/conf/activiti;create=true" userid="wso2carbon" password="wso2carbon" autocommit="true" onerror="continue">
                                    <classpath>
                                        <path refid="h2.classpath" />
                                    </classpath>
                                    <fileset file="${basedir}/resources/dbscripts/create/activiti.h2.create.engine.sql" />
                                    <fileset file="${basedir}/resources/dbscripts/create/activiti.h2.create.history.sql" />
                                    <fileset file="${basedir}/resources/dbscripts/create/activiti.h2.create.identity.sql" />
                                    <fileset file="${basedir}/resources/dbscripts/create/activiti.h2.create.substitute.sql" />
                                </sql>
                                <echo message="##################### END ############################" />
                                <echo message="********Version of H2: " />
                                <echo>${orbit.version.h2.engine}</echo>
                            </tasks>
                        </configuration>
                    </execution>
                    <execution>
                        <id>clean_target</id>
                        <phase>install</phase>
                        <configuration>
                            <tasks>
                                <delete dir="src/main/resources" />
                                <delete dir="src/main" />
                                <delete dir="src" />
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>2-copy-resources</id>
                        <!--phase>generate-resources</phase-->
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>src/main/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>resources</directory>
                                    <includes>
                                        <include>conf/datasources/activiti-datasources.xml</include>
                                        <include>conf/activiti.xml</include>
                                        <include>**/activiti.mv.db</include>
                                        <include>**/*.sql</include>
                                        <include>p2.inf</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wso2.maven</groupId>
                <artifactId>carbon-p2-plugin</artifactId>
                <version>${carbon.p2.plugin.version}</version>
                <executions>
                    <execution>
                        <id>3-p2-feature-generation</id>
                        <phase>package</phase>
                        <goals>
                            <goal>p2-feature-gen</goal>
                        </goals>
                        <configuration>
                            <id>org.wso2.carbon.bpmn.server</id>
                            <propertiesFile>../../etc/feature.properties</propertiesFile>
                            <adviceFile>
                                <properties>
                                    <propertyDef>org.wso2.carbon.p2.category.type:server
                                    </propertyDef>
                                    <propertyDef>org.eclipse.equinox.p2.type.group:false
                                    </propertyDef>
                                </properties>
                            </adviceFile>
                            <bundles>
                                <bundleDef>org.slf4j:slf4j-log4j12</bundleDef>
                                <bundleDef>org.apache.commons:commons-lang3</bundleDef>
                                <bundleDef>org.wso2.carbon.business-process:org.wso2.carbon.bpmn</bundleDef>
                                <bundleDef>org.wso2.carbon.business-process:org.wso2.carbon.bpmn.extensions</bundleDef>
                            </bundles>
                            <importBundles>
                                <importBundleDef>org.wso2.orbit.org.activiti:activiti-all:${org.activiti.wso2.version}</importBundleDef>
                                <importBundleDef>org.apache.commons:commons-lang3:${commons.lang3.version}</importBundleDef>
                                <importBundleDef>org.wso2.orbit.com.fasterxml.jackson.core:jackson-core:${orbit.fasterxml.jackson.version}</importBundleDef>
                                <importBundleDef>org.wso2.orbit.com.fasterxml.jackson.core:jackson-databind:${orbit.fasterxml.jackson.version}</importBundleDef>
                                <importBundleDef>org.wso2.orbit.com.fasterxml.jackson.core:jackson-annotations:${orbit.fasterxml.jackson.version}</importBundleDef>
                                <importBundleDef>org.wso2.orbit.joda-time:joda-time:${joda.time.version}</importBundleDef>
                                <!-- importBundleDef>org.wso2.orbit.javax.mail:mail:1.4.1.wso2v1</importBundleDef -->
                                <importBundleDef>org.mybatis:mybatis:${mybatis.version}</importBundleDef>
                                <!-- importBundleDef>commons-logging:commons-logging:1.1.3</importBundleDef -->

                                <importBundleDef>org.wso2.orbit.com.fasterxml.jackson.dataformat:jackson-dataformat:${orbit.fasterxml.jackson.version}</importBundleDef>
                                <importBundleDef>org.wso2.orbit.com.fasterxml.jackson.module:jackson-module-jaxb-annotations:${orbit.fasterxml.jackson.version}</importBundleDef>
                                <importBundleDef>org.codehaus.woodstox:woodstox-core-asl:${woodstox.core.version}</importBundleDef>
                                <importBundleDef>org.yaml:snakeyaml:${snakeyaml.version}</importBundleDef>
                                <importBundleDef>org.wso2.orbit.org.tinyjee.jgraphx:jgraphx:${org.wso2.orbit.org.tinyjee.jgraphx.version}</importBundleDef>
                                <importBundleDef>commons-io:commons-io:${commons.io.version}</importBundleDef>
                                <importBundleDef>commons-fileupload:commons-fileupload:${commons.fileupload.version}</importBundleDef>
                                <importBundleDef>org.codehaus.woodstox:stax2-api:${stax2.version}</importBundleDef>

                                <importBundleDef>org.wso2.orbit.com.jayway.jsonpath:json-path:${jsonpath.wso2.version}</importBundleDef>
                                <importBundleDef>net.minidev:json-smart:${json.smart.version}</importBundleDef>
                                <importBundleDef>net.minidev:accessors-smart:${accessors-smart.version}</importBundleDef>
                                <importBundleDef>org.ow2.asm:asm:${org.ow2.asm.version}</importBundleDef>

                            </importBundles>


                            <importFeatures>
                                <importFeatureDef>
                                    org.wso2.carbon.core.server:compatible:${carbon.kernel.feature.version}
                                </importFeatureDef>
                            </importFeatures>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
