<!--
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>
        <artifactId>tinkerpop</artifactId>
        <groupId>org.apache.tinkerpop</groupId>
        <version>3.7.3</version>
    </parent>
    <artifactId>gremlin-console</artifactId>
    <name>Apache TinkerPop :: Gremlin Console</name>
    <properties>
        <docker.platforms>linux/amd64,linux/arm64/v8</docker.platforms>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>tinkergraph-gremlin</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
        <!-- commons-codec is a dependency of httpclient - excluded in root pom to bring all commons-codec versions inline -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-driver</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.fusesource.jansi</groupId>
            <artifactId>jansi</artifactId>
            <version>1.17.1</version>
        </dependency>
        <!-- TESTING -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-server</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-test</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock</artifactId>
            <version>1.58</version>
            <scope>test</scope>
            <classifier>standalone</classifier>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.skyscreamer</groupId>
                    <artifactId>jsonassert</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xmlunit</groupId>
                    <artifactId>xmlunit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.jayway.jsonpath</groupId>
                    <artifactId>json-path</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>net.sf.jopt-simple</groupId>
                    <artifactId>jopt-simple</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.groovy</groupId>
            <artifactId>groovy-cli-picocli</artifactId>
            <version>${groovy.version}</version>
        </dependency>
    </dependencies>
    <build>
        <directory>${basedir}/target</directory>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <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-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
            <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.console.Console</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>addSources</goal>
                            <goal>addTestSources</goal>
                            <goal>generateStubs</goal>
                            <goal>compile</goal>
                            <goal>generateTestStubs</goal>
                            <goal>compileTests</goal>
                            <goal>removeStubs</goal>
                            <goal>removeTestStubs</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>uber</shadedClassifierName>
                            <shadeSourcesContent>true</shadeSourcesContent>
                            <createSourcesJar>true</createSourcesJar>
                            <relocations>
                                <relocation>
                                    <pattern>io.netty</pattern>
                                    <shadedPattern>io.shaded.netty</shadedPattern>
                                </relocation>
                            </relocations>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"></transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                    <resources>
                                        <resource>LICENSE.txt</resource>
                                        <resource>LICENSE</resource>
                                        <resource>NOTICE.txt</resource>
                                        <resource>NOTICE</resource>
                                        <resource>licenses</resource>
                                        <!--Exclude kryo, minlog and bigint licenses to avoid conflict as they are included in
                                            both gremlin-shaded and gremlin-driver-->
                                        <resource>META-INF/licenses/kryo</resource>
                                        <resource>META-INF/licenses/minlog</resource>
                                        <resource>META-INF/licenses/bigint</resource>
                                    </resources>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/LICENSE</resource>
                                    <file>src/main/static/LICENSE</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/NOTICE</resource>
                                    <file>src/main/static/NOTICE</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/foundation</resource>
                                    <file>src/main/static/licenses/foundation</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/jbcrypt</resource>
                                    <file>src/main/static/licenses/jbcrypt</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/jline2</resource>
                                    <file>src/main/static/licenses/jline2</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/kryo</resource>
                                    <file>src/main/static/licenses/kryo</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/minlog</resource>
                                    <file>src/main/static/licenses/minlog</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/bigint</resource>
                                    <file>src/main/static/licenses/bigint</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/ganymed-ssh</resource>
                                    <file>src/main/static/licenses/ganymed-ssh</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/normalize</resource>
                                    <file>src/main/static/licenses/normalize</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/slf4j</resource>
                                    <file>src/main/static/licenses/slf4j</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/treelayout</resource>
                                    <file>src/main/static/licenses/treelayout</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/logback</resource>
                                    <file>src/main/static/licenses/logback</file>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>META-INF/licenses/antlr4</resource>
                                    <file>src/main/static/licenses/antlr4</file>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <configuration>
                        <images>
                            <image>
                                <name>tinkerpop/gremlin-console:${project.version}</name>
                                <build>
                                    <dockerFile>${project.build.directory}/../Dockerfile</dockerFile>
                                    <args>
                                        <GREMLIN_CONSOLE_DIR>target/apache-tinkerpop-${project.artifactId}-${project.version}-standalone</GREMLIN_CONSOLE_DIR>
                                    </args>
                                    <tags>
                                        <!-- docker.tags.* properties are empty if project.version is a pre-release
                                            resulting in no additional tags -->
                                        <tag>${docker.tags.majorVersion.minorVersion}</tag>
                                        <tag>${docker.tags.latest}</tag>
                                    </tags>
                                    <buildx>
                                        <platforms>
                                            <platform>${docker.platforms}</platform>
                                        </platforms>
                                    </buildx>
                                </build>
                            </image>
                        </images>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <!-- activates the building of python components through Docker.
             use the .glv file in gremlin-python as an indicator to activate -->
        <profile>
            <id>console-integration-tests</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <!-- can't use variable here - maven no likey -->
                    <exists>../gremlin-python/.glv</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <!--
                            use pytest to execute native python tests - output of xunit output is configured in setup.cfg.
                            must run on integration tests because package phase has to execute to get the console binaries
                            available for testing
                            -->
                            <execution>
                                <id>native-python-test</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipIntegrationTests}</skip>
                                    <target>
                                        <exec executable="docker" failonerror="true">
                                            <!-- This build command relies on Docker's caching mechanism to reduce the amount of times it is run. -->
                                            <arg line="build -t gremlin-console-test:py3.9jre11 ./src/test/python/docker"/>
                                        </exec>
                                        <exec executable="docker" failonerror="true">
                                            <arg line="run --rm --mount type=bind,src=${project.basedir}/src/test/python,dst=/console_app
                                            --mount type=bind,src=${project.basedir}/target/apache-tinkerpop-gremlin-console-${project.version}-standalone,dst=/console_app/gremlin-console
                                            gremlin-console-test:py3.9jre11"/>
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </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>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>docker:build</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                            <execution>
                                <id>docker:push</id>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                                <phase>deploy</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
