<?xml version="1.0" encoding="UTF-8"?>

<!-- ~ Copyright 2010-2012 Luca Garulli (l.garulli(at)orientechnologies.com) 
    ~ ~ 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">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-parent</artifactId>
        <version>2.2.36</version>
        <relativePath>../</relativePath>
    </parent>

    <artifactId>orientdb-community</artifactId>

    <name>OrientDB Community Distribution</name>

    <properties>
        <VERSION>${project.version}</VERSION>
        <BUILD>${implementation.build}; ${maven.build.timestamp}</BUILD>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <argLine>-ea -Xmx${heapSize} -XX:MaxDirectMemorySize=512g -Dstorage.diskCache.bufferSize=4096</argLine>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-test-commons</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.testng</groupId>
                    <artifactId>testng</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-client</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-server</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-object</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-tools</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-distributed</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-graphdb</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- #5256 removed dep from orientdb-graphdb -->
        <dependency>
            <groupId>com.tinkerpop.rexster</groupId>
            <artifactId>rexster-core</artifactId>
            <version>${blueprints.version}</version>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.gremlin</groupId>
            <artifactId>gremlin-java</artifactId>
            <version>${blueprints.version}</version>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.gremlin</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>${blueprints.version}</version>
        </dependency>

        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-etl</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-lucene</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-jdbc</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.orientechnologies</groupId>
            <artifactId>orientdb-studio</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
        </dependency>


    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                    <execution>
                        <id>build-db</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/bin/java</executable>
                            <workingDirectory>${project.basedir}</workingDirectory>
                            <arguments>
                                <argument>-Xmx${heapSize}</argument>
                                <argument>-XX:MaxDirectMemorySize=512g</argument>
                                <argument>-classpath</argument>
                                <classpath/>
                                <argument>com.orientechnologies.orient.graph.console.OInternalGraphImporter</argument>
                                <argument>${project.basedir}/../graphdb/src/test/resources/graph-example-2.xml</argument>
                                <argument>plocal:${project.basedir}/target/databases/GratefulDeadConcerts</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>distribution-package</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>${basedir}/src/main/assembly/archive.xml</descriptor>
                            </descriptors>
                            <filters>
                                <filter></filter>
                            </filters>
                            <ignoreDirFormatExtensions>false</ignoreDirFormatExtensions>
                            <tarLongFileMode>gnu</tarLongFileMode>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.4.13</version>
                <configuration>
                    <imageName>orientdb/orientdb</imageName>
                    <imageTags>
                        <imageTag>${project.version}</imageTag>
                    </imageTags>
                    <dockerDirectory>docker</dockerDirectory>
                    <!-- copy the service's jar file from target into the root directory of the image -->
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}/</directory>
                            <include>${project.build.finalName}.tar.gz</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>qa</id>
            <build>
                <plugins>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.4.0</version>
                        <executions>
                            <execution>
                                <id>build-demodb</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${java.home}/bin/java</executable>
                                    <workingDirectory>${project.basedir}</workingDirectory>
                                    <arguments>
                                        <argument>-XX:MaxDirectMemorySize=512g</argument>
                                        <argument>-classpath</argument>
                                        <classpath/>
                                        <argument>com.orientechnologies.orient.console.OConsoleDatabaseApp</argument>
                                        <argument>CREATE DATABASE plocal:./target/databases/demodb;</argument>
                                        <argument>LOAD SCRIPT ./src/test/resources/demoDB.osql;</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                            <execution>
                                <id>start-orient</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target name="start OrientDB server on localhost">
                                        <exec executable="${project.build.directory}/${project.build.finalName}.dir/${project.build.finalName}/bin/server.sh"
                                              spawn="true">
                                            <env key="ORIENTDB_ROOT_PASSWORD" value="root"/>
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>

                            <execution>
                                <id>stop-orient</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target name="stop the running OrientDB server on localhost">
                                        <exec executable="${project.build.directory}/${project.build.finalName}.dir/${project.build.finalName}/bin/shutdown.sh"
                                              spawn="false">
                                        </exec>
                                    </target>
                                </configuration>

                            </execution>
                        </executions>
                    </plugin>

                </plugins>
            </build>

        </profile>

    </profiles>
</project>
