<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.apache.tinkerpop</groupId>
        <artifactId>tinkerpop</artifactId>
        <version>3.4.7</version>
    </parent>
    <artifactId>gremlin-server</artifactId>
    <name>Apache TinkerPop :: Gremlin Server</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>tinkergraph-gremlin</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-driver</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- METRICS -->
        <dependency>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-graphite</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-ganglia</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- TESTING -->
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-test</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.carrotsearch</groupId>
            <artifactId>junit-benchmarks</artifactId>
            <version>0.7.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.171</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>neo4j-gremlin</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.kerby</groupId>
            <artifactId>kerb-simplekdc</artifactId>
            <version>2.0.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <directory>${basedir}/target</directory>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
        <resources>
            <resource>
                <directory>${basedir}/src/main/resources
                </directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>${basedir}/src/test/resources
                </directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <attach>true</attach>
                    <descriptors>
                        <descriptor>src/assembly/standalone.xml</descriptor>
                        <descriptor>src/assembly/distribution.xml</descriptor>
                    </descriptors>
                    <finalName>apache-tinkerpop-${project.artifactId}-${project.version}</finalName>
                    <outputDirectory>target</outputDirectory>
                    <workDirectory>target/assembly/work</workDirectory>
                    <tarLongFileMode>warn</tarLongFileMode>
                    <archive>
                        <manifest>
                            <mainClass>org.apache.tinkerpop.gremlin.server.GremlinServer</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>use-epoll</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>useEpoll</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <gremlin.server.epoll>true</gremlin.server.epoll>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>


        <profile>
            <!--
              This profile will include neo4j for purposes of transactional testing within Gremlin Server.
              Tests that require neo4j specifically will be "ignored" if this profile is not turned on.
            -->
            <id>include-neo4j</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>includeNeo4j</name>
                </property>
            </activation>
            <dependencies>
                <!-- TESTING -->
                <!-- *** WARNING *** -->
                <dependency>
                    <groupId>org.neo4j</groupId>
                    <artifactId>neo4j-tinkerpop-api-impl</artifactId>
                    <version>0.3-2.3.3</version>
                    <scope>test</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>org.apache.commons</groupId>
                            <artifactId>commons-lang3</artifactId>
                        </exclusion>
                        <exclusion>
                            <groupId>com.googlecode.concurrentlinkedhashmap</groupId>
                            <artifactId>concurrentlinkedhashmap-lru</artifactId>
                        </exclusion>
                        <exclusion>
                            <groupId>org.scala-lang</groupId>
                            <artifactId>scala-library</artifactId>
                        </exclusion>
                        <exclusion>
                            <groupId>org.slf4j</groupId>
                            <artifactId>slf4j-api</artifactId>
                        </exclusion>
                        <exclusion>
                            <groupId>info.ganglia.gmetric4j</groupId>
                            <artifactId>gmetric4j</artifactId>
                        </exclusion>
                        <exclusion>
                            <groupId>org.ow2.asm</groupId>
                            <artifactId>asm</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <!-- *** WARNING *** -->
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>docker-images</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>dockerImages</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!--
                    Deploying docker images will happen out of the normal jvm artifact deployment flow, so disable that
                    -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.spotify</groupId>
                        <artifactId>dockerfile-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>docker-image-build</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <tag>${project.version}</tag>
                                    <buildArgs>
                                        <GREMLIN_SERVER_DIR>target/apache-tinkerpop-${project.artifactId}-${project.version}-standalone</GREMLIN_SERVER_DIR>
                                    </buildArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>docker-image-tag-minor-version</id>
                                <goals>
                                    <goal>tag</goal>
                                </goals>
                                <configuration>
                                    <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}</tag>
                                    <skip>${only.when.is.prerelease.version}</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>docker-image-tag-latest</id>
                                <goals>
                                    <goal>tag</goal>
                                </goals>
                                <configuration>
                                    <tag>latest</tag>
                                    <skip>${only.when.is.prerelease.version}</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>docker-image-push</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                                <configuration>
                                    <tag>${project.version}</tag>
                                    <skip>${only.when.is.snapshot.used}</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>docker-image-push-minor-version</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                                <configuration>
                                    <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}</tag>
                                    <skip>${only.when.is.prerelease.version}</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>docker-image-push-latest</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                                <configuration>
                                    <tag>latest</tag>
                                    <skip>${only.when.is.prerelease.version}</skip>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <repository>tinkerpop/gremlin-server</repository>
                        </configuration>
                    </plugin>
                </plugins>                
            </build>
        </profile>
    </profiles>
</project>
