<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--
  ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~
  ~ 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.wso2.carbon.analytics</groupId>
        <artifactId>org.wso2.carbon.analytics.parent</artifactId>
        <version>2.0.32</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>org.wso2.carbon.analytics.test.distribution</artifactId>
    <packaging>pom</packaging>
    <name>WSO2 Carbon Analytics - Test Distribution</name>
    <description>
        This module generates the product distribution (zip) by installing sample in-memory user store and
        carbon-security feature on top of kernel core and runtime features and finally assembles product specific
        configurations files and startup scripts using assembly plugin.
    </description>
    <url>http://wso2.com</url>
    <dependencies>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.kernel.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.runtime.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.utils</groupId>
            <artifactId>org.wso2.carbon.utils.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.transport</groupId>
            <artifactId>org.wso2.carbon.transport.http.netty.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.transport</groupId>
            <artifactId>org.wso2.carbon.connector.framework.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.messaging</groupId>
            <artifactId>org.wso2.carbon.messaging.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.datasources</groupId>
            <artifactId>org.wso2.carbon.datasource.core.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.jndi</groupId>
            <artifactId>org.wso2.carbon.jndi.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.caching</groupId>
            <artifactId>org.wso2.carbon.caching.feature</artifactId>
            <type>zip</type>
        </dependency>

        <!-- Metrics Features -->
        <dependency>
            <groupId>org.wso2.carbon.metrics</groupId>
            <artifactId>org.wso2.carbon.metrics.core.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.metrics</groupId>
            <artifactId>org.wso2.carbon.metrics.jdbc.core.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.metrics</groupId>
            <artifactId>org.wso2.carbon.metrics.das.core.feature</artifactId>
            <type>zip</type>
        </dependency>

        <!-- MSF4J Features-->
        <dependency>
            <groupId>org.wso2.msf4j</groupId>
            <artifactId>org.wso2.msf4j.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.deployment</groupId>
            <artifactId>org.wso2.carbon.deployment.engine.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.deployment</groupId>
            <artifactId>org.wso2.carbon.deployment.notifier.feature</artifactId>
            <type>zip</type>
        </dependency>


        <!-- Stream Processor related Features-->
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.stream.processor.core.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.stream.processor.common.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.siddhi.editor.core.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.event.simulator.core.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.das.jobmanager.core.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.siddhi.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.security.caas</groupId>
            <artifactId>org.wso2.carbon.security.caas.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.databridge.feature</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.pax.exam.feature</artifactId>
            <type>zip</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <configuration>
                    <format>{0,date,dd MMM yyyy}</format>
                    <items>
                        <item>timestamp</item>
                    </items>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                </configuration>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>unpack-equinox-executable</id>
                        <phase>test</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.eclipse.equinox</groupId>
                                    <artifactId>org.eclipse.equinox.executable</artifactId>
                                    <version>3.5.0.v20110530-7P7NFUFFLWUl76mart</version>
                                    <type>zip</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>target</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wso2.carbon.maven</groupId>
                <artifactId>carbon-feature-plugin</artifactId>
                <version>${carbon.feature.plugin.version}</version>
                <executions>
                    <execution>
                        <id>p2-repo-generation</id>
                        <phase>package</phase>
                        <goals>
                            <goal>generate-repo</goal>
                        </goals>
                        <configuration>
                            <targetRepository>file:${basedir}/target/p2-repo</targetRepository>
                            <features>
                                <feature>
                                    <id>org.wso2.carbon.utils.feature</id>
                                    <version>${carbon.utils.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.kernel.feature</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.runtime.feature</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.transport.http.netty.feature</id>
                                    <version>${org.wso2.carbon.transport.http.netty.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.connector.framework.feature</id>
                                    <version>${org.wso2.carbon.transport.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.messaging.feature</id>
                                    <version>${carbon.messaging.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.caching.feature</id>
                                    <version>${carbon.cache.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.datasource.core.feature</id>
                                    <version>${carbon.datasources.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.jndi.feature</id>
                                    <version>${carbon.jndi.version}</version>
                                </feature>

                                <!-- Metrics Features -->
                                <feature>
                                    <id>org.wso2.carbon.metrics.core.feature</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.metrics.jdbc.core.feature</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.metrics.das.core.feature</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>

                                <!-- MSF4J Features -->
                                <feature>
                                    <id>org.wso2.msf4j.feature</id>
                                    <version>${msf4j.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.deployment.engine.feature</id>
                                    <version>${carbon.deployment.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.deployment.notifier.feature</id>
                                    <version>${carbon.deployment.version}</version>
                                </feature>

                                <!-- Stream Processor Features -->
                                <feature>
                                    <id>org.wso2.carbon.stream.processor.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.stream.processor.common.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.siddhi.editor.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.event.simulator.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.das.jobmanager.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.siddhi.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>

                                <!-- CAAS Security Feature -->
                                <feature>
                                    <id>org.wso2.carbon.security.caas.feature</id>
                                    <version>${carbon.security.caas.version}</version>
                                </feature>


                                <feature>
                                    <id>org.wso2.carbon.databridge.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.pax.exam.feature</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>

                            </features>
                        </configuration>
                    </execution>
                    <execution>
                        <id>publishing products</id>
                        <phase>package</phase>
                        <goals>
                            <goal>publish-product</goal>
                        </goals>
                        <configuration>
                            <productConfigurationFile>${basedir}/carbon.product
                            </productConfigurationFile>
                            <executable>
                                ${basedir}/target/org.eclipse.equinox.executable_3.5.0.v20110530-7P7NFUFFLWUl76mart
                            </executable>
                            <repositoryURL>file:${basedir}/target/p2-repo</repositoryURL>
                        </configuration>
                    </execution>
                    <execution>
                        <id>materialize-worker</id>
                        <phase>package</phase>
                        <goals>
                            <goal>generate-runtime</goal>
                        </goals>
                        <configuration>
                            <productConfigurationFile>${basedir}/carbon.product
                            </productConfigurationFile>
                            <repositoryURL>file:${basedir}/target/p2-repo</repositoryURL>
                            <targetPath>
                                file:${basedir}/target/carbon-analytics/wso2
                            </targetPath>
                            <runtime>worker</runtime>
                        </configuration>
                    </execution>
                    <execution>
                        <id>materialize-editor</id>
                        <phase>package</phase>
                        <goals>
                            <goal>generate-runtime</goal>
                        </goals>
                        <configuration>
                            <productConfigurationFile>${basedir}/carbon.product
                            </productConfigurationFile>
                            <repositoryURL>file:${basedir}/target/p2-repo</repositoryURL>
                            <targetPath>
                                file:${basedir}/target/carbon-analytics/wso2
                            </targetPath>
                            <runtime>editor</runtime>
                        </configuration>
                    </execution>
                    <execution>
                        <id>feature-installation-worker</id>
                        <phase>package</phase>
                        <goals>
                            <goal>install</goal>
                        </goals>
                        <configuration>
                            <runtime>worker</runtime>
                            <repositoryURL>file:${basedir}/target/p2-repo</repositoryURL>
                            <destination>
                                ${basedir}/target/carbon-analytics/wso2
                            </destination>
                            <deleteOldRuntimeFiles>true</deleteOldRuntimeFiles>
                            <features>
                                <feature>
                                    <id>org.wso2.carbon.kernel.feature.group</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.caching.feature.group</id>
                                    <version>${carbon.cache.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.runtime.feature.group</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.transport.http.netty.feature.group</id>
                                    <version>${org.wso2.carbon.transport.http.netty.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.messaging.feature.group</id>
                                    <version>${carbon.messaging.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.jndi.feature.group</id>
                                    <version>${carbon.jndi.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.datasource.core.feature.group</id>
                                    <version>${carbon.datasources.version}</version>
                                </feature>

                                <!-- Metrics Features -->
                                <feature>
                                    <id>org.wso2.carbon.metrics.core.feature.group</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.metrics.jdbc.core.feature.group</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.metrics.das.core.feature.group</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>

                                <!-- MSF4J Features -->
                                <feature>
                                    <id>org.wso2.msf4j.feature.group</id>
                                    <version>${msf4j.version}</version>
                                </feature>

                                <!-- Stream Processor Features -->
                                <feature>
                                    <id>org.wso2.carbon.stream.processor.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.stream.processor.common.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.event.simulator.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.siddhi.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>

                                <!-- CAAS Security Feature -->
                                <feature>
                                    <id>org.wso2.carbon.security.caas.feature</id>
                                    <version>${carbon.security.caas.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.databridge.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.pax.exam.feature</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                            </features>
                        </configuration>
                    </execution>
                    <execution>
                        <id>feature-installation-editor</id>
                        <phase>package</phase>
                        <goals>
                            <goal>install</goal>
                        </goals>
                        <configuration>
                            <runtime>editor</runtime>
                            <repositoryURL>file:${basedir}/target/p2-repo</repositoryURL>
                            <destination>
                                ${basedir}/target/carbon-analytics/wso2
                            </destination>
                            <deleteOldRuntimeFiles>true</deleteOldRuntimeFiles>
                            <features>
                                <feature>
                                    <id>org.wso2.carbon.kernel.feature.group</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.caching.feature.group</id>
                                    <version>${carbon.cache.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.runtime.feature.group</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.transport.http.netty.feature.group</id>
                                    <version>${org.wso2.carbon.transport.http.netty.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.utils.feature.group</id>
                                    <version>${carbon.utils.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.messaging.feature.group</id>
                                    <version>${carbon.messaging.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.jndi.feature.group</id>
                                    <version>${carbon.jndi.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.datasource.core.feature.group</id>
                                    <version>${carbon.datasources.version}</version>
                                </feature>

                                <!-- Metrics Features -->
                                <feature>
                                    <id>org.wso2.carbon.metrics.core.feature.group</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.metrics.jdbc.core.feature.group</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.metrics.das.core.feature.group</id>
                                    <version>${carbon.metrics.version}</version>
                                </feature>

                                <!-- MSF4J Features -->
                                <feature>
                                    <id>org.wso2.msf4j.feature.group</id>
                                    <version>${msf4j.version}</version>
                                </feature>

                                <!-- Stream Processor Features -->
                                <feature>
                                    <id>org.wso2.carbon.stream.processor.common.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.siddhi.editor.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.siddhi.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>

                                <!--simulator feature-->
                                <feature>
                                    <id>org.wso2.carbon.event.simulator.core.feature</id>
                                    <version>${carbon.analytics.version}</version>
                                </feature>

                                <!-- CAAS Security Feature -->
                                <feature>
                                    <id>org.wso2.carbon.security.caas.feature</id>
                                    <version>${carbon.security.caas.version}</version>
                                </feature>
                                <feature>
                                    <id>org.wso2.carbon.pax.exam.feature</id>
                                    <version>${carbon.kernel.version}</version>
                                </feature>
                            </features>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <replace dir="target/carbon-analytics/wso2" token="false" value="true">
                                    <include name="**/bundles.info" />
                                </replace>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>clean_target</id>
                        <phase>install</phase>
                        <configuration>
                            <target>
                                <delete dir="target/archive-tmp" />
                                <delete dir="target/dependency-maven-plugin-markers" />
                                <delete dir="target/org.eclipse.equinox.executable-3.5.0.v20110530-7P7NFUFFLWUl76mart" />
                                <delete dir="target/p2-repo" />
                                <!-- Figure out a way to delete tmp.* files -->
                                <delete file="target/tmp" />
                                <delete dir="target/carbon-analytics" />
                                <delete dir="target/antrun" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>distribution</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/bin.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
        <resources>
            <resource>
                <directory>carbon-home/bin/</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/version.txt</include>
                </includes>
            </resource>
        </resources>
    </build>
</project>
